These are the commands in the wheels dbmigrate
namespace. They allow you to manipulate the database structure and script the changes. This makes is easy to share your changes with coworkers, check them into source control, or apply them automatically when you deploy your code to production.
wheels dbmigrate
This is another namespace with sub commands within it. It also has an alias of wheels db
which allows you to shorten the command you need to type.
wheels dbmigrate info
This command doesn't take any inputs but simply tries to communicate with the running server and gather information about your migrations and displays them in a table.
From the information presented in the two tables you can see how many migration files are in your application and of those how many have already been applied and available to be applied. You are also presented with the datasource name and database type information.
wheels dbmigrate latest
This command will migrate the database to the latest version. This command will apply each migration file from the current state all the way to the latest one at a time. If a SQL error is encountered in one of the files, the command will stop at that point and report the error.
wheels dbmigrate reset
This command will migrate the database to version 0 effectively resetting the database to nothing.
wheels dbmigrate up
This command will process the next migration file from the current state. If the database is already at the latest version this command will have no effect.
wheels dbmigrate down
This command will reverse the current migration file and take the database one step backwards. If the database is already at version 0 then this command will have no effect.
wheels dbmigrate exec
This command will run a particular migration file and take the database to that version. The four directional migration commands above latest
, reset
, up
, and down
each in turn call this command to process their intended action.
version
true
The version to migrate the database to
wheels dbmigrate create table
This command will generate a new migration file for creating a table in the database. Keep in mind you will still have to run the migration file but this will add it to the migration history.
name
true
The name of the database table to create
force
false
false
Force the creation of the table
id
false
true
Auto create ID column as autoincrement ID
primaryKey
false
ID
Overrides the default primary key column name
wheels dbmigrate create column
This command will generate a new migration file for adding a new column to an existing table.
name
true
The name of the database table to modify
columnType
true
The column type to add
columnName
false
The column name to add
default
false
The default value to set for the column
null
false
true
Should the column allow nulls
limit
false
The character limit of the column
precision
false
The precision of the numeric column
scale
false
The scale of the numeric column
wheels dbmigrate create blank
wheels dbmigrate remove table
This command generates a migration file to remove a table. The migration file is will still need to be run individual but this command gets the migration generated and into the history.
name
true
The name of the database table to remove