Documentation | 中文文档
Blueprint is a lightweight database migration CLI tool written in Go, inspired by Laravel Migrations.
If you are an independent developer or a startup team, tools like Bytebase may feel a little heavy, but Blueprint will be your powerful assistant😎
Visit the release page and download the corresponding binary file.
Then move the downloaded file to any directory included in the PATH
environment variable (e.g., /usr/local/bin/blueprint
), and run the following command:
blueprint help
If the setup is successful, you will see the help message output.
Navigate to your project migrations directory and run the following command:
blueprint init
And this directory will be initialized as a Blueprint repository for storing .sql
files.
blueprint create user
# or specify table name later:
blueprint create
# and you can use update for a update migration:
blueprint update
The create
command wille create a pair of .sql
files suce as 202411181653_create_user.sql
and 202411181653_create_user_rollback.sql
, and you just need to edit these files for your migration.
And update
command is similar to create
, the diffrence between them is just the .sql
filename.
blueprint
# or
blueprint run
Blueprint will executes all .sql
files those not executed before, and these files will have same batch number.
# to rollback the last batch of migrations, run the following command:
blueprint rollback
# or
blueprint rollback --batch 1
# or rollback the last step of migrations:
blueprint rollback --step 1
You can specify how many step(s) you need to rollback, one step means a .sql
file.
Or you can specify how many batch(es) you need to rollback, the batch
is introduced at Run migration
Only one of --step
or --batch
can be specified at a time, default is --batch 1