-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththrowaway.py
48 lines (35 loc) · 1.18 KB
/
throwaway.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
"""create_users_table
Revision ID: ffdc0a98111c
Revises:
Create Date: 2020-11-20 15:06:02.230689
"""
from alembic import op
import sqlalchemy as sa
import os
environment = os.getenv("FLASK_ENV")
SCHEMA = os.environ.get("SCHEMA")
# revision identifiers, used by Alembic.
revision = 'ffdc0a98111c'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=40), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('hashed_password', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email'),
sa.UniqueConstraint('username')
)
if environment == "production":
op.execute(f"ALTER TABLE users SET SCHEMA {SCHEMA};")
# ### end Alembic commands ###qqqqqqqqq
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('users')
# ### end Alembic commands ###
# file name
# migrations/versions/20201120_150602_create_users_table.py