[migrations]link in the debug footer to load the built in GUI. Naturally, you will need your application's datasource setup and ready to go to get started.
Numericis perfectly valid, but we recommend the
Timestampprefix if you're just starting out. Once you have a migration file, this section will disappear as it will get that info from the existing files.
userstable. So under
Create a Template, we will select
Create tableand add a migration description of
Create User Table.
Create Migration Filewill then create a CFC at
/db/migrate/20170420100502_Create_User_Table.cfc. The system will also display all messages at the top of the GUI whenever it does something - so for this command, we see
The migration 20170420100502_Create_User_Table.cfc file was created
Create_User_Table.cfctemplate we just created. There are two functions to any migration file:
up()will be executed when migrating your schema forward, and
down()when you're rolling back.
up()function will look something like this. Most of it you can actually ignore, as it's just wrapped in a transaction with some error handling. The important lines to look at are:
createTable()is the command to actually make the table: so we need to change this to
t.create();is the final statement which executes the actual action.
down()function needs to reverse these changes. so in our
down()code block, we're going to change the
firstname. Here's an example of a slightly more fleshed out migration file to give you some inspiration:
t = createTable(name='users');will create a standard auto-increment numeric ID, sometimes you need to create a table which has a composite, or non standard primary key. In this example, we're setting
createTable()call to bypass the default behavior, then specifying our primarykeys seperately via