Added migrations script

This commit is contained in:
julien
2026-03-09 03:01:13 +01:00
parent 7424928003
commit 84cd2a8268
3 changed files with 38 additions and 14 deletions

34
scripts/migrations.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use Medoo\Medoo;
$dbFile = __DIR__ . '/../database/app.sqlite';
if (!file_exists($dbFile)) {
if (!is_dir(dirname($dbFile))) {
mkdir(dirname($dbFile), 0755, true);
}
touch($dbFile);
chmod($dbFile, 0664);
}
$database = new Medoo([
'database_type' => 'sqlite',
'database_file' => $dbFile,
]);
// schéma minimal — CREATE TABLE IF NOT EXISTS est idempotent
$database->query(
<<<'SQL'
CREATE TABLE IF NOT EXISTS post (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT NOT NULL
);
SQL
);
echo "Migrations applied (minimal).\n";