mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2026-02-02 09:25:07 +01:00
Add support for options; transaction option (#68)
* Add support for options; transaction option
This commit is contained in:
parent
7400451fba
commit
7ac46ff0f3
4 changed files with 219 additions and 47 deletions
18
README.md
18
README.md
|
|
@ -205,6 +205,24 @@ Rolling back: 20151127184807_create_users_table.sql
|
|||
Writing: ./db/schema.sql
|
||||
```
|
||||
|
||||
### Migration Options
|
||||
|
||||
dbmate supports options passed to a migration block in the form of `key:value` pairs. List of supported options:
|
||||
|
||||
* `transaction`
|
||||
|
||||
#### transaction
|
||||
|
||||
`transaction` is useful if you need to run some SQL which cannot be executed from within a transaction. For example, in Postgres, you would need to disable transactions for migrations that alter an enum type to add a value:
|
||||
|
||||
```sql
|
||||
-- migrate:up transaction:false
|
||||
ALTER TYPE colors ADD VALUE 'orange' AFTER 'red';
|
||||
ALTER TYPE colors ADD VALUE 'yellow' AFTER 'orange';
|
||||
```
|
||||
|
||||
`transaction` will default to `true` for if your database supports it.
|
||||
|
||||
### Schema File
|
||||
|
||||
When you run the `up`, `migrate`, or `rollback` commands, dbmate will automatically create a `./db/schema.sql` file containing a complete representation of your database schema. Dbmate keeps this file up to date for you, so you should not manually edit it.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue