-
Notifications
You must be signed in to change notification settings - Fork 13
Usage
Normally a user will only execute the following commands:
-
Check the status of the database patches:
$ dbpatch status
-
And update the database:
$ dbpatch update
Other commands are explained in the Available commands chapter.
When you start using DbPatch and already use patch files, you can use the sync command to sync the patches with the database.
$ dbpatch sync
When you already have a database and patch files, but never used DbPatch you first need to synchronize the patches. The sync command will add the current patches to the database with the status executed.
For example:
$ dbpatch sync
If you only need to sync patches from a specific branch, you can add the branch name with the --branch parameter.
When you need to update the database with the latest patches you can use the update command.
For example:
$ dbpatch update
If you only need to update patches from a specific branch, you can add the branch name with the --branch parameter. It's also possible to skip certain patches with the --skip parameter. When you are going to update the database and there is a patch missing the script will stop. With the --force parameter you can tell the script to continue.
To show the status of the patches (which patches still need to be applied and what are the latest patches that are applied) you can use the status command. If you use branches it will give you an overview of the patches that need to be applied for each branch.
For example:
$ dbpatch status
If you want to see a specific patch you can use the show command.
For example:
$ dbpatch show --patch=5
When a patch is in an other branch then default, you can specify the branch name with the --branch parameter.
If you need to remove a patch file from the database changelog to execute it again, you can use the remove command.
For example:
$ dbpatch remove --patch=10
When a patch is in an other branch then default, you can specify the branch name with the --branch parameter.
Sometimes you want to create an empty patch file to reserve the filename allready.
For example:
$ dbpatch create --type=sql --number=19
If you want to create a php file, just change the type into php. When you need to create a patch for a specific branch, you can add the branch name with the --branch parameter.
With the 'dump' command it's possible to make a database dump. By default the name of the dump file is named after the database with the current date and time (database_20110812_1223.sql) and written in the current directory. If you want a different name or directory you can specify this with the --file parameter.
For example:
$ dbpatch dump --file=/tmp/live_dump.sql
Each command has his own help that can be called like this:
$ dbpatch help create
Available commands are create, sync, status, dump, remove, show, update
Each command also has a shortcut:
- create -> cr
- sync -> sy
- status -> st
- dump -> du
- remove -> re
- show -> sh
- update -> up