-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTaskfile.prod.yml
38 lines (35 loc) · 1.15 KB
/
Taskfile.prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
version: '3'
dotenv: ['.env']
tasks:
db:alembic:
desc: arbitrary alembic command in the container
cmds:
- |
alembic -c /opt/$PROJ_NAME/alembic.ini {{.CLI_ARGS}}
db:migrate:
desc: migrates models to HEAD
cmds:
- |
alembic -c /opt/$PROJ_NAME/alembic.ini upgrade head
db:alembic:heads:
desc: shows the HEAD SHA for alembic migrations
cmds:
- |
alembic -c /opt/$PROJ_NAME/alembic.ini heads
db:alembic:attach:
desc: join the database container to alembic migrations
summary: |
This is useful if you have nuked your database and re-initialised
the schema and want to join back to the head alembic migrations.
We will attempt to create the alebmic_version table and populate
the version_num field with the current head value.
vars:
HEAD_SHA:
sh: "task db:alembic:heads | sed -e 's/ (head)//g'"
cmds:
- |
psql \
-U {{.POSTGRES_USER}} \
-d {{.POSTGRES_DB}} -c \" \
CREATE TABLE IF NOT EXISTS alembic_version ( version_num VARCHAR ); \
INSERT INTO alembic_version ( version_num ) VALUES ( '{{.HEAD_SHA}}' );\"