# Migrations

Migrations are like version control for your database, allowing your team to modify and share the application’s database schema. Migrations are typically paired with schema builder to build your application’s database schema. If you have ever had to tell a teammate to manually add a column to their local database schema, you’ve faced the problem that database migrations solve.

# Generating Migrations

To create a migration, use the make-sql-migration command:

expresswebcli make-sql-migration [MIGRATION_NAME]

The new migration will be placed in your database/migrations directory. Each migration file name contains a timestamp, which allows expresswebjs to determine the order of the migrations.

# To run your migrations

expresswebcli run-sql-migration

# To List both completed and pending migrations

expresswebcli show-sql-list

# To rollback the last batch of migrations:

expresswebcli sql-rollback

# To run the next migration that has not yet been run:

expresswebcli sql-rollup

# To run the specified migration that has not yet been run

expresswebcli sql-rollup [MIGRATION_NAME]

# To undo the last migration that was run

expresswebcli sql-rolldown

# To undo the specified migration that was run:

expresswebcli sql-rolldown [MIGRATION_NAME]

Other Interesting Commands:

# To create new route folder

expresswebcli make-route [ROUTE_NAME] [ROUTE_PATH]

# To create authentication

expresswebcli make-nosql-auth

# To create nosql model

expresswebcli make-nosql-model [MODEL_NAME]

# To create sql model with migration

expresswebcli make-sql-model [NODEL_NAME] [--m]