Migrations & Seeds
Flowra wraps Knex migrations and seeds with CLI commands that read orm.cli.config.js.
Create a migration
flowra db:migrate:make create_users_table
By default, migrations are stored in app/Database/Migrations.
Run migrations
flowra db:migrate:latest
Roll back
flowra db:rollback
flowra db:rollback --all
Migration status
flowra db:status
Seeds
Create a seed:
flowra db:seed:make seed_users
Run seeds:
flowra db:seed:run
Example migration
app/Database/Migrations/20251025213153_create_table_users.js
exports.up = function(knex) {
return knex.schema.createTable('users', function(table) {
table.increments('id').primary();
table.string('username').notNullable().unique();
table.string('email').notNullable().unique();
table.string('password').notNullable();
table.timestamp('createdAt').nullable();
table.timestamp('updatedAt').nullable();
table.timestamp('deletedAt').nullable();
});
};
exports.down = function(knex) {
return knex.schema.dropTableIfExists('users');
};
Connection aliases
Use --env <alias> on migration and seed commands to target a specific database configuration.