db:migrate
Runs all pending database migrations.--environment=<env>- Specify the environment (development, staging, production)--withSeeds- Run all seeders after migrations--seed=<seeder>- Run specific seeders (can be used multiple times)
The
db:migrate command automatically creates the app/Database/migrations/ and app/Database/seeds/ directories if they don’t exist.run:database
Sets up and creates database environments. This command is useful for initial database configuration.-c, --create- Create the database-e, --seed- Seed the database after creation-d, --development=<name>- Create development database with specified name-s, --staging=<name>- Create staging database with specified name-p, --production=<name>- Create production database with specified name-a, --all- Create all environment databases (prompts for base name)
Supported Database Drivers
The command supports multiple database systems:MySQL/MariaDB
MySQL/MariaDB
PostgreSQL
PostgreSQL
SQLite
SQLite
SQL Server
SQL Server
Configuration Updates
Therun:database command automatically:
- Updates
.envfile withDB_DATABASEvalue - Creates
phinx.jsonif it doesn’t exist - Updates
phinx.jsonwith environment-specific database names
Creating Migrations and Seeders
While you can use Phinx commands directly, Aeros provides convenient make commands:Create Migration
Create Seeder
Combined Approach
You can create both a migration and seeder in one command:Database Workflow
Here’s a typical database workflow when starting a new Aeros project:Direct Phinx Usage
You can also use Phinx commands directly if needed:Refer to the Phinx documentation for advanced migration features.
Troubleshooting
Migration directory not found
Migration directory not found
The
db:migrate command automatically creates missing directories. If you see this error, ensure your application has write permissions.Database connection failed
Database connection failed
Verify your
.env database configuration and ensure the database server is running.phinx.json missing
phinx.json missing
Run
php aeros run:database -c -a to generate the configuration file.Permission denied creating database
Permission denied creating database
Ensure your database user has
CREATE DATABASE privileges.Next Steps
Make Commands
Learn about scaffolding migrations and seeders
Database Usage
Learn how to use the database in your application