-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathtasks.py
57 lines (40 loc) · 1.17 KB
/
tasks.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from invoke import task
from app.settings import settings
DEV_ENV = {
"DATABASE_URL": settings.DATABASE_URL,
"PYTHONPATH": "."
}
@task
def generate_migrations(ctx):
ctx.run("alembic revision --autogenerate", env=DEV_ENV)
@task
def migrate_dev(ctx):
ctx.run("alembic upgrade head", env=DEV_ENV)
@task
def downgrade_dev(ctx):
ctx.run("alembic downgrade -1", env=DEV_ENV)
@task
def clear_dev_db(ctx):
ctx.run('psql postgres -c "drop database textbook;"')
@task
def create_dev_db(ctx):
ctx.run('psql postgres -c "create database textbook;"')
@task
def reset_dev_db(ctx):
clear_dev_db(ctx)
create_dev_db(ctx)
migrate_dev(ctx)
@task
def reset_migrations(ctx):
ctx.run("rm -rf alembic/versions/*")
generate_migrations(ctx)
migrate_dev(ctx)
@task
def lint(ctx):
ctx.run("pylint --load-plugins pylint_pydantic app")
@task
def black(ctx):
ctx.run(
"autoflake --imports=sqlmodel,sqlalchemy,typing --recursive --in-place app --exclude=__init__.py,tables.py,main.py,db.py,alembic,data,cache")
ctx.run("isort app --profile black")
ctx.run("black app --exclude tables.py,main.py,db.py,__init__.py,alembic,data,cache")