# SQL 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:

ts-node maker 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

ts-node maker run-sql-migration

# To List both completed and pending migrations

ts-node maker show-sql-list

# To rollback the last batch of migrations:

ts-node maker sql-rollback

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

ts-node maker sql-rollup

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

ts-node maker sql-rollup [MIGRATION_NAME]

# To undo the last migration that was run

ts-node maker sql-rolldown

# To undo the specified migration that was run:

ts-node maker sql-rolldown [MIGRATION_NAME]