@@ -4,7 +4,7 @@ This package contains a library for the creation, management, and installation
44of schema updates (called "migrations") for a relational database. In
55particular, this package lets the migration author express explicit dependencies
66between migrations. This library is accompanied by a number database-specific
7- packages that contain the management tools to automatically install or revert
7+ executables that contain the management tools to automatically install or revert
88migrations accordingly.
99
1010This package operates on two logical entities:
@@ -18,35 +18,48 @@ This package operates on two logical entities:
1818
1919## Getting started
2020
21- To get started, install the right database-specific dbmigrations package for
22- your database. Current options are:
21+ To get started, install with the right database-specific flag for your database.
2322
24- - ` dbmigrations-postgresql `
25- - ` dbmigrations-mysql `
26- - ` dbmigrations-sqlite `
23+ ``` console
24+ stack install dbmigrations --flag dbmigrations:<backend>
25+ `` `
2726
28- Each package provides a CLI suitable for the given backend .
27+ Then run the database-specific executable that was installed .
2928
30- The database type-specific packages that work as a companion to this library
31- contain tools called ` moo-postgresql ` , ` moo-mysql ` , ` moo-sqlite ` , etc. They are
32- responsible for creating, installing, and reverting migrations in your database
33- backend. Since all of these command line tools offer the exact same interface,
34- they are described here in a single document. The executables mentioned above
35- are simply called ` moo ` for the rest of this document. That is, given an example
36- that reads as ` moo command ` you actually have to execute `moo-postgresql
37- command` or ` moo-mysql command` and so on.
29+ ``` console
30+ dbm-<backend> help
31+ ```
32+
33+ For example,
34+
35+ ``` console
36+ stack install dbmigrations --flag dbmigrations:postgresql
37+ ```
3838
39- At present, MySQL, PostgreSQL and Sqlite3 are the only supported database
40- backends.
39+ ``` console
40+ dbm-postgresql help
41+ ```
42+
43+ Available backends are:
44+
45+ - ` sqlite `
46+ - ~~ ` mysql ` ~~ _ temporarily disabled due to upstream issue_
47+ - ` postgresql `
4148
42- The moo tools work by creating migration files in a specific location, called a
49+ Since all of ` dbm-<backend> ` command line tools offer the exact same interface,
50+ they are described here in a single document. The executables mentioned above
51+ are simply called ` dbm ` for the rest of this document. That is, given an example
52+ that reads as ` dbm command ` you actually have to execute `dbm-postgresql
53+ command` or ` dbm-mysql command` and so on.
54+
55+ The DBM tools work by creating migration files in a specific location, called a
4356migration store, on your filesystem. This directory is where all possible
44- migrations for your project will be kept. Moo allows you to create migrations
45- that depend on each other. When you use moo to upgrade your database schema, it
57+ migrations for your project will be kept. DBM allows you to create migrations
58+ that depend on each other. When you use DBM to upgrade your database schema, it
4659determines which migrations are missing, what their dependencies are, and
4760installs the required migrations in the correct order (based on dependencies).
4861
49- Moo works by prompting you for new migration information. It then creates a
62+ DBM works by prompting you for new migration information. It then creates a
5063migration YAML file (whose format is described below), which you then edit by
5164hand.
5265
@@ -56,8 +69,6 @@ database.
5669
5770## Example
5871
59- _ In the examples below, replace any ` moo ` command shown with ` moo-<backend> ` ._
60-
61721 . Create a directory in which to store migration files.
6273
63742 . Set an environment variable ` DBM_MIGRATION_STORE ` to the path to the
@@ -68,7 +79,7 @@ _In the examples below, replace any `moo` command shown with `moo-<backend>`._
6879 depend on the database type, see the "Environment" documentation section for
6980 more information.
7081
71- 4 . Run ` moo upgrade` . This command will not actually install any migrations,
82+ 4 . Run ` dbm upgrade` . This command will not actually install any migrations,
7283 since you have not created any, but it will attempt to connect to your
7384 database and install a migration-tracking table.
7485
@@ -78,10 +89,10 @@ _In the examples below, replace any `moo` command shown with `moo-<backend>`._
7889 Database is up to date.
7990 ```
8091
81- 5 . Create a migration with ` moo new` . Here is an example output:
92+ 5 . Create a migration with ` dbm new` . Here is an example output:
8293
8394 ``` console
84- % moo new hello-world
95+ % dbm new hello-world
8596 Selecting dependencies for new migration: hello-world
8697
8798 Confirm: create migration 'hello-world'
@@ -90,7 +101,7 @@ _In the examples below, replace any `moo` command shown with `moo-<backend>`._
90101 Migration created successfully: ".../hello-world.yml"
91102 ```
92103
93- 6 . Edit the migration you created. In this case, moo created a file
104+ 6 . Edit the migration you created. In this case, DBM created a file
94105 ` $DBM_MIGRATION_STORE/hello_world.yml ` that looks like this:
95106
96107 ``` yaml
@@ -115,61 +126,61 @@ _In the examples below, replace any `moo` command shown with `moo-<backend>`._
115126 DROP TABLE foo;
116127 ` ` `
117128
118- 7. Test the new migration with ` moo test`. This will install the migration in a
129+ 7. Test the new migration with ` dbm test`. This will install the migration in a
119130 transaction and roll it back. Here is example output :
120131
121132 ` ` ` console
122- % moo test hello-world
133+ % dbm test hello-world
123134 Applying: hello-world... done.
124135 Reverting: hello-world... done.
125136 Successfully tested migrations.
126137 ` ` `
127138
128139<!-- prettier-ignore-start -->
129- <!-- it gets confused on the line-break-within-code of moo upgrade -->
140+ <!-- it gets confused on the line-break-within-code of dbm upgrade -->
130141
131- 8. Install the migration. This can be done in one of two ways : with `moo
132- upgrade` or with `moo apply`. Here are examples :
142+ 8. Install the migration. This can be done in one of two ways : with `dbm
143+ upgrade` or with `dbm apply`. Here are examples :
133144
134145
135146 ` ` ` console
136- % moo apply hello-world
147+ % dbm apply hello-world
137148 Applying: hello-world... done.
138149 Successfully applied migrations.
139150
140- % moo upgrade
151+ % dbm upgrade
141152 Applying: hello-world... done.
142153 Database successfully upgraded.
143154 ` ` `
144155
145156<!-- prettier-ignore-end -->
146157
147- 9. List installed migrations with `moo list`.
158+ 9. List installed migrations with `dbm list`.
148159
149160 ` ` ` console
150- % moo list
161+ % dbm list
151162 hello-world
152163 ` ` `
153164
15416510. Revert the migration.
155166
156167 ` ` ` console
157- % moo revert hello-world
168+ % dbm revert hello-world
158169 Reverting: hello-world... done.
159170 Successfully reverted migrations.
160171 ` ` `
161172
16217311. List migrations that have not been installed.
163174
164175 ` ` ` console
165- % moo upgrade-list
176+ % dbm upgrade-list
166177 Migrations to install:
167178 hello-world
168179 ` ` `
169180
170181# # Configuration File Format
171182
172- All moo commands accept a `--config-file` option which you can use to specify
183+ All DBM commands accept a `--config-file` option which you can use to specify
173184the path to a configuration file containing your settings. This approach is an
174185alternative to setting environment variables. The configuration file format uses
175186the same environment variable names for its fields. An example configuration is
@@ -182,8 +193,8 @@ DBM_LINEAR_MIGRATIONS = on/off (or true/false; defaults to off)
182193DBM_TIMESTAMP_FILENAMES = on/off (or true/false; defaults to off)
183194` ` `
184195
185- Alternatively, you may save your settings to `moo .cfg` file in the current
186- directory (probably a project root) and moo will load it automatically, if
196+ Alternatively, you may save your settings to `dbm .cfg` file in the current
197+ directory (probably a project root) and DBM will load it automatically, if
187198present. Specifying `--config-file` disables this behavior.
188199
189200If you use a config file (either the default one or the one specified with
@@ -250,7 +261,7 @@ treatment of this behavior, see the YAML spec.
250261
251262# # Environment
252263
253- Moo depends on these environment variables / configuration file
264+ DBM depends on these environment variables / configuration file
254265settings :
255266
256267` ` `
@@ -284,10 +295,10 @@ DBM_DATABASE
284295DBM_MIGRATION_STORE
285296
286297 The path to the filesystem directory where your migrations will be
287- kept. moo will create new migrations in this directory and use
298+ kept. DBM will create new migrations in this directory and use
288299 the migrations in this directory when updating the database
289300 schema. Initially, you'll probably set this to an extant (but
290- empty) directory. moo will not create it for you.
301+ empty) directory. DBM will not create it for you.
291302
292303DBM_LINEAR_MIGRATIONS
293304
@@ -313,12 +324,12 @@ DBM_TIMESTAMP_FILENAMES
313324 apply <migration name>: apply the specified migration (and its
314325 dependencies) to the database. This operation will be performed
315326 in a single transaction which will be rolled back if an error
316- occurs. moo will output updates as each migration is applied.
327+ occurs. DBM will output updates as each migration is applied.
317328
318329 revert <migration name>: revert the specified migration (and its
319330 reverse dependencies -- the migrations which depend on it) from
320331 the database. This operation will be performed in a single
321- transaction which will be rolled back if an error occurs. moo
332+ transaction which will be rolled back if an error occurs. DBM
322333 will output updates as each migration is reverted.
323334
324335 test <migration name>: once you've created a migration, you might
@@ -351,7 +362,7 @@ DBM_TIMESTAMP_FILENAMES
351362## Linear Migrations
352363
353364If you know that every migration needs to depend on all previous ones, consider
354- enabling this feature. When enabled, ` moo new` will automatically select
365+ enabling this feature. When enabled, ` dbm new` will automatically select
355366smallest subset of existing migrations that will make the new one indirectly
356367depend on every other already in the store. This in turn makes the store
357368linear-ish (in terms of order of execution) and helps managing the migrations by
0 commit comments