57 lines
1.6 KiB
Markdown
57 lines
1.6 KiB
Markdown
# DB Morph
|
|
|
|
This tool allows a simple DB migration based on SQL and TS files as part of
|
|
automated CI/CD activities. It also supports seeding database tables.
|
|
|
|
## Syntax
|
|
|
|
```
|
|
dbmorph migrate|seed|make[:seed] [options]
|
|
```
|
|
|
|
- `migrate` runs all migrations that have not yet been applied for the current
|
|
database. It will pull all migrations from the `db/migrations` directory
|
|
- `seed` runs all (or just the given) seeds. It will pull the seed information
|
|
from the `db/seeds` directory.
|
|
- `make` creates an empty migration template. If the `db/migrations` directory
|
|
does not exist, it is created. For each migration, an "up" and a "down" file
|
|
is being generated. "Up" will be used for the migration, whereas "down" is
|
|
used if the migration fails - in order to roll the changes back in a
|
|
controlled manner.
|
|
- `make:seed` creates a new template for seeding data.
|
|
|
|
### Seed Options
|
|
|
|
The `seed` command allows for one option:
|
|
|
|
```
|
|
dbmorph seed [name]
|
|
```
|
|
|
|
If `name` is not provided, all seeds will be run. Otherwise only the seed that
|
|
matches the given name. This can also be a partial match.
|
|
|
|
### Make Options
|
|
|
|
The `make` command accepts two options:
|
|
|
|
```
|
|
dbmorph make <name> [ts]|[sql]
|
|
```
|
|
|
|
The `<name>` is used to provide a unique human-readable name for the migration.
|
|
|
|
the `ts` / `sql` options determine which type of a migration is supposed to be
|
|
created: if `ts` is provided, a template for a Typescript file will be created,
|
|
otherwise an empty SQL file is provided.
|
|
|
|
### make:seed Options
|
|
|
|
The `make:seed` command accepts one option:
|
|
|
|
```
|
|
dbmorph make:seed <name>
|
|
```
|
|
|
|
The `<name>` is used to provide a unique human-readable name for the seed.
|