This feature is part of spludo since 1.1.
Spludo also features a database migration system. The commands are inspired by ruby on rails. All commands will run on all configured database connection.
You may issue any of the migration logic, by calling ant with the correct target
$ ant db:migrate
The available targets are:
db:bootstrap Load the fixtures and execute pending migrations.
db:fixtures:dump Dump the current database as fixtures.
db:fixtures:load Load the fixtures into the database structure.
db:fixtures:reset Remove the current database fixtures dump.
db:migrate Execute all pending migrations and create a structure dump.
db:rollback Rollback all migrations.
db:structure:dump Dump the current database structure to a structure dump.
db:structure:load Load the current database structure from a structure dump.
db:structure:reset Remove the current database structure dump.
If you want to create a new migration, you need to use the spludo-gen tool.
$ spludo-gen migration-create-table
Create a migration, which creates a database table.
$ spludo-gen migration-add-column
Create a migration, which adds a column to a database table.
After the migration is generated, it's located at dev/migrations/CONNECTION_NAME/TIMESTAMP_Name.js.
The identifier for the migrations is the timestamp, which decreases the
possibility that two co workers create a migration with the same identifier.
Migrations are database connection name specific. Thus you can migrate multiple data sources for your application idenpenden from each other.
The db:structure:* targets are used for setting up an initial database
structure or storing the current one. This structure file is located at dev/migrations/CONNECTION_NAME_structure.sql.
If no migrations have been executed on the database, yet, the db:migrate target will call db:structure:load
first and afterwards migrate. This will avoid heavy migration work, if you just want to setup a working copy from
scratch.
The db:fixtures:* targets are used for loading a fixtures dump or storing
the current database as fixtures. This fixtures file is located at dev/migrations/CONNECTION_NAME_fixtures.sql.
You should use
$ ant db:bootstrap
on a fresh working copy. This target executes db:fixtures:load and afterwards
db:migrate. This is also helpful for tests!