Skip to content

Commit 93500ca

Browse files
pbrisbinnuttycom
authored andcommitted
Rename Moo to DBM
1 parent daa09c4 commit 93500ca

File tree

15 files changed

+94
-154
lines changed

15 files changed

+94
-154
lines changed

CHANGELOG.md

Lines changed: 5 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,9 @@
1+
## [_Unreleased_](https://github.com/pbrisbin/dbmigrations/compare/v3.0.0.0...main)
12

2-
2.1.0
3-
-----
3+
## [v3.0.0.0](https://github.com/pbrisbin/dbmigrations/tree/v3.0.0.0)
44

5-
Package changes:
6-
- Migrated from `yaml-light` to `yaml` package for YAML parsing (thanks
7-
Hank Levsen <hlevsen@atlassian.com>)
5+
First release after change of maintainer.
86

9-
Other changes:
10-
- `Text` is now used instead of `String` in most parts of the codebase
11-
(thanks Vitalii Guzeev <vitaliy@getshoptv.com>)
12-
- New migrations now get the `.yml` file extension, but old migration
13-
`txt` files are also supported.
7+
## v2
148

15-
2.0.0
16-
-----
17-
18-
This release contains breaking changes!
19-
20-
- Factored out all database-specific functionality into separate
21-
packages (thanks Bastian Krol)
22-
- Replaced "moo" program with one that emits an error instructing users
23-
to use backend-specific dbmigrations packages
24-
- Added missing test data files to package
25-
- Removed `DBM_DATABASE_TYPE` environment variable in favor of backend
26-
selection by use of backend-specific packages
27-
- Allow `DBM_TIMESTAMP_FILENAMES` to be set via environment variable
28-
(thanks Alexander Lippling)
29-
30-
1.1.1
31-
-----
32-
33-
- Improve configuration validation error messages and clean up
34-
validation routine
35-
- Reinstate support for GHC 7.8
36-
37-
1.1
38-
---
39-
40-
- Add support for MySQL databases (thanks Ollie Charles
41-
<ollie@ocharles.org.uk>). Please see MOO.TXT for a disclaimer about this
42-
feature!
43-
44-
1.0
45-
---
46-
47-
- Added support for (optionally) adding timestamps to generated
48-
migration filenames (thanks Matt Parsons <parsonsmatt@gmail.com>)
49-
* Adds flag for time stamp on file names
50-
* Adds configuration for timestamping filenames
51-
- Added new "linear migrations" feature (thanks Jakub Fijałkowski
52-
<fiolek94@gmail.com>, Andrew Martin <amartin@layer3com.com>). This
53-
feature is an optional alternative to the default behavior: rather than
54-
prompting the user for dependencies of new migrations (the default
55-
behavior), linear mode automatically selects dependencies for new
56-
migrations such that they depend on the smallest subset of migrations
57-
necessary to (effectively) depend on all existing migrations, thus
58-
"linearizing" the migration sequence. See MOO.TXT for details.
59-
- Configuration file loading now defaults to "moo.cfg" in the CWD if
60-
--config-file is not specified, and environment variables override
61-
settings in the config file
62-
63-
0.9.1
64-
-----
65-
66-
- Restored default timestamp and description values in migrations
67-
created by new migration command
68-
69-
0.9
70-
---
71-
72-
- Fix 'moo' usage output to use correct program name
73-
- Replaced Backend type class in favor of concrete Backend record type
74-
- Added hdbcBackend constructor
75-
- Backends now always run in IO rather than some MonadIO
76-
- Removed monad parameter from MigrationStore (always use IO)
77-
- Replaced MigrationStore type class with concrete MigrationStore type
78-
- Added filesystem migration store constructor
79-
- Improve configuration type so that it has been implicitly validated
80-
- Made newMigration pure, made migration timestamps optional
81-
- createNewMigration now takes a Migration for greater caller control
9+
See https://github.com/jtdaugherty/dbmigrations.

README.md

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This package contains a library for the creation, management, and installation
44
of schema updates (called "migrations") for a relational database. In
55
particular, this package lets the migration author express explicit dependencies
66
between 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
88
migrations accordingly.
99

1010
This 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
4356
migration 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
4659
determines which migrations are missing, what their dependencies are, and
4760
installs 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
5063
migration YAML file (whose format is described below), which you then edit by
5164
hand.
5265

@@ -56,8 +69,6 @@ database.
5669

5770
## Example
5871

59-
_In the examples below, replace any `moo` command shown with `moo-<backend>`._
60-
6172
1. Create a directory in which to store migration files.
6273

6374
2. 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

154165
10. 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

162173
11. 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
173184
the path to a configuration file containing your settings. This approach is an
174185
alternative to setting environment variables. The configuration file format uses
175186
the 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)
182193
DBM_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
187198
present. Specifying `--config-file` disables this behavior.
188199

189200
If 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
254265
settings:
255266

256267
```
@@ -284,10 +295,10 @@ DBM_DATABASE
284295
DBM_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

292303
DBM_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

353364
If 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
355366
smallest subset of existing migrations that will make the new one indirectly
356367
depend on every other already in the store. This in turn makes the store
357368
linear-ish (in terms of order of execution) and helps managing the migrations by

dbmigrations.cabal

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ extra-source-files:
2222
tests/example_store/update2
2323
tests/config_loading/cfg1.cfg
2424
tests/config_loading/cfg_ts.cfg
25+
tests/config_loading/dbm.cfg
2526
tests/config_loading/invalid.cfg
2627
tests/config_loading/missing.cfg
27-
tests/config_loading/moo.cfg
2828
tests/migration_parsing/invalid_field_name.txt
2929
tests/migration_parsing/invalid_missing_required_fields.txt
3030
tests/migration_parsing/invalid_syntax.txt
@@ -68,11 +68,11 @@ library
6868
Database.Schema.Migrations.Migration
6969
Database.Schema.Migrations.Store
7070
Database.Schema.Migrations.Test.BackendTest
71-
Moo.CommandHandlers
72-
Moo.CommandInterface
73-
Moo.CommandUtils
74-
Moo.Core
75-
Moo.Main
71+
DBM.CommandHandlers
72+
DBM.CommandInterface
73+
DBM.CommandUtils
74+
DBM.Core
75+
DBM.Main
7676
other-modules:
7777
Paths_dbmigrations
7878
hs-source-dirs:

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ executables:
102102
- condition: ! "!(flag(sqlite))"
103103
buildable: false
104104

105+
# TODO: HDBC-mysql fails to compile
105106
# dbm-mysql:
106107
# source-dirs: mysql/app
107108
# ghc-options: -threaded -rtsopts "-with-rtsopts=-N"

postgresql/app/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module Main (main) where
22

33
import Prelude
44

5+
import DBM.Main
56
import Database.HDBC.PostgreSQL (connectPostgreSQL)
6-
import Moo.Main
77

88
main :: IO ()
99
main = hdbcMain connectPostgreSQL

sqlite/app/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module Main (main) where
22

33
import Prelude
44

5+
import DBM.Main
56
import Database.HDBC.Sqlite3 (connectSqlite3)
6-
import Moo.Main
77

88
main :: IO ()
99
main = hdbcMain connectSqlite3

0 commit comments

Comments
 (0)