diff --git a/README.md b/README.md index b047ff2..c692d8d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,25 @@ php -m | grep -i sqlite # doit afficher pdo_sqlite et/ou sqlite3 php -S localhost:8000 -t public ``` -La base `database/api_tube.sqlite` et son schéma sont créés automatiquement au premier appel. +La base `database/api_tube.sqlite` et son schéma sont créés automatiquement au premier appel (via les migrations). + +## Migrations + +Les migrations sont des fichiers SQL numérotés dans `database/migrations/`, appliqués une seule fois et tracés dans la table `migrations`. + +Elles sont exécutées automatiquement à la connexion à la base. Pour les appliquer manuellement (hors serveur web) : + +```bash +php database/migrate.php +``` + +Ajouter une migration : + +```bash +# fichier database/migrations/002_ajout_colonne.sql +echo "ALTER TABLE links ADD COLUMN visible INTEGER DEFAULT 1;" > database/migrations/002_ajout_colonne.sql +php database/migrate.php +``` ## Endpoints @@ -65,10 +83,11 @@ public/ index.php # point d'entrée unique .htaccess # réécriture vers index.php src/ - Database.php # connexion PDO SQLite (+ création du schéma) + Database.php # connexion PDO SQLite + exécution des migrations LinkRepository.php # CRUD SQL JsonExporter.php # écriture de data.json LinkController.php # routage, validation, orchestration database/ - schema.sql # schéma de la table links + migrate.php # runner de migrations (CLI) + migrations/ # fichiers SQL versionnés ``` \ No newline at end of file