This directory contains database migrations managed by Phinx.
-
Install dependencies (if not already done):
cd web composer install -
Ensure config.json exists:
# From the project root cp config.example.json config.json # Edit config.json with your database credentials
All Phinx commands should be run from the project root directory (not the web directory).
./web/vendor/bin/phinx statusThis shows which migrations have been run and which are pending.
To apply all pending migrations:
./web/vendor/bin/phinx migrateTo rollback the last migration:
./web/vendor/bin/phinx rollbackTo rollback to a specific version:
./web/vendor/bin/phinx rollback -t 20250101000000./web/vendor/bin/phinx create MyNewMigrationThis creates a new migration file in db/migrations/ with a timestamp prefix.
The initial migration (20250101000000_initial_schema.php) represents the baseline schema from commit 0d308b92127df05420a1417eb7c635ead8348b9a. This is the schema currently deployed on the production server.
Important: If you already have the database tables created via tables.sql, you should mark the initial migration as complete without running it:
./web/vendor/bin/phinx migrate -t 20250101000000 --fakeThe --fake flag records the migration as run without actually executing it.
- Always test migrations on a development database before running on production
- Write both up and down migrations to ensure rollbacks work correctly
- Never edit a migration after it has been run on production
- Use descriptive names for migrations that explain what they do
- Keep migrations focused - one migration should do one logical thing
- Commit migrations to git so all team members stay in sync
db/
├── migrations/ # Migration files (versioned, committed to git)
│ └── 20250101000000_initial_schema.php
├── seeds/ # Seed files for test data (optional)
└── README.md # This file
The Phinx configuration is in phinx.php at the project root. It automatically reads database credentials from config.json.
Make sure you're running commands from the project root and that config.json exists.
Check that your MySQL database is running and the credentials in config.json are correct.
Phinx creates a phinxlog table in your database to track which migrations have been run. Don't modify this table manually.