aboutsummaryrefslogtreecommitdiff
path: root/migrations/versions/81173c1d4f0a_initial_migration.py
blob: f96ff2156914d14592aad1b1618145ac1ce6863a (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""Initial migration

Revision ID: 81173c1d4f0a
Revises: 
Create Date: 2022-07-25 13:13:29.135474

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '81173c1d4f0a'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('role',
    sa.Column('id', sa.String(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('description', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('user',
    sa.Column('id', sa.String(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('password', sa.String(), nullable=False),
    sa.Column('pref_name', sa.String(), nullable=False),
    sa.Column('last_login', sa.DateTime(), nullable=False),
    sa.Column('fs_uniquifier', sa.String(), nullable=False),
    sa.Column('active', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('fs_uniquifier')
    )
    op.drop_table('enroll_requests')
    op.drop_table('_sqlx_migrations')
    op.drop_table('networks')
    op.drop_table('peers')
    op.drop_table('users')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('email', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('pref_name', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('pw_hash', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('last_login', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='users_pkey'),
    postgresql_ignore_search_path=False
    )
    op.create_table('peers',
    sa.Column('id', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('addr', postgresql.CIDR(), autoincrement=False, nullable=False),
    sa.Column('public_key', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('owner', sa.TEXT(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['owner'], ['users.id'], name='peers_owner_fkey'),
    sa.PrimaryKeyConstraint('id', name='peers_pkey')
    )
    op.create_table('networks',
    sa.Column('id', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('subnet', postgresql.CIDR(), autoincrement=False, nullable=False),
    sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='networks_pkey')
    )
    op.create_table('_sqlx_migrations',
    sa.Column('version', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('description', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('installed_on', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False),
    sa.Column('success', sa.BOOLEAN(), autoincrement=False, nullable=False),
    sa.Column('checksum', postgresql.BYTEA(), autoincrement=False, nullable=False),
    sa.Column('execution_time', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('version', name='_sqlx_migrations_pkey')
    )
    op.create_table('enroll_requests',
    sa.Column('token', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('expires', postgresql.TIMESTAMP(), server_default=sa.text("(CURRENT_TIMESTAMP + ((30)::double precision * '00:01:00'::interval))"), autoincrement=False, nullable=False),
    sa.Column('confirmed', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('token', name='enroll_requests_pkey')
    )
    op.drop_table('user')
    op.drop_table('role')
    # ### end Alembic commands ###