1
0
Fork 0
mirror of https://github.com/Oreolek/kohana-migrations.git synced 2024-06-16 15:01:08 +03:00

Merge remote-tracking branch 'origin/feature/docs' into guide

This commit is contained in:
Sam Wilson 2013-05-29 15:03:11 +08:00
commit e0a26722ad
3 changed files with 48 additions and 0 deletions

View file

@ -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.

View file

@ -0,0 +1,4 @@
## [Minion Migrations]()
- [Generating Migrations](generating)
- [Running Migrations](running)

View file

@ -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.