From 57dde28cbe36fcfa758f1df52476f4f69dd92b3c Mon Sep 17 00:00:00 2001 From: Matt Button Date: Sat, 19 Feb 2011 20:13:49 +0000 Subject: [PATCH] Adding basic docs --- guide/minion-migrations/index.md | 8 +++++++ guide/minion-migrations/menu.md | 4 ++++ guide/minion-migrations/running.md | 36 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 guide/minion-migrations/index.md create mode 100644 guide/minion-migrations/menu.md create mode 100644 guide/minion-migrations/running.md diff --git a/guide/minion-migrations/index.md b/guide/minion-migrations/index.md new file mode 100644 index 0000000..42c2cbd --- /dev/null +++ b/guide/minion-migrations/index.md @@ -0,0 +1,8 @@ +# Minion Migrations + +## Migrations? But I'm not leaving the country! + +The term "Migrations" is used to describe the movement from one location to another. +In the context of databases it refers to managing differences between schemas. In essence, it's version control for databases. + +When you make a change to your schema you store a copy of the SQL you ran in a migration file, along with SQL that will revert the changes you made. diff --git a/guide/minion-migrations/menu.md b/guide/minion-migrations/menu.md new file mode 100644 index 0000000..e20bf0a --- /dev/null +++ b/guide/minion-migrations/menu.md @@ -0,0 +1,4 @@ +## [Minion Migrations]() +- [Generating Migrations](generating) +- [Running Migrations](running) + diff --git a/guide/minion-migrations/running.md b/guide/minion-migrations/running.md new file mode 100644 index 0000000..a1dc172 --- /dev/null +++ b/guide/minion-migrations/running.md @@ -0,0 +1,36 @@ +# Running Migrations + +## Going up + +To migrate your schema to the latest possible version run the command: + + ./minion db:migrate + +This command is synonomous with + + ./minion db:migrate --migrate-up + +Which will run all migrations that haven't yet been applied to the schema, bringing it back in sync with the migrations in the filesystem. + +## Going down + +To unapply all migrations (i.e. to delete all the tables in your schema) run this command: + + ./minion db:migrate --migrate-down + +## Going over there + +If you want to a specific version of your schema then you can use the `--migrate-to` switch, which accepts either a migration's timestamp or a relative pointer to a migration. + + // Migrate the schema 5 versions down + --migrate-to=-5 + + // Migrate the schema 10 versions up + --migrate-to=+5 + + // Migrate to a specific version + --migrate-to=201102190811 + +## Look before you leap + +If you want to see what SQL is going to be executed by the migrate task then simply pass the `--dry-run` switch and the SQL will be printed to the console instead of being executed.