110 lines
4.1 KiB
Python
110 lines
4.1 KiB
Python
"""Initial migration
|
|
|
|
Revision ID: 575a8924eb16
|
|
Revises:
|
|
Create Date: 2021-06-12 13:18:24.903142
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '575a8924eb16'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('contacttype',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=25), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('language',
|
|
sa.Column('id', sa.String(length=2), nullable=False),
|
|
sa.Column('name', sa.String(length=25), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('skill',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=25), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('name')
|
|
)
|
|
op.create_table('user',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('nickname', sa.String(length=25), nullable=False),
|
|
sa.Column('pronouns', sa.String(length=25), nullable=True),
|
|
sa.Column('volunteerwork', sa.String(length=4000), nullable=True),
|
|
sa.Column('freetext', sa.String(length=4000), nullable=True),
|
|
sa.Column('created', sa.DateTime(), nullable=False),
|
|
sa.Column('updated', sa.DateTime(), nullable=False),
|
|
sa.Column('auth_id', sa.String(length=50), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('auth_id'),
|
|
sa.UniqueConstraint('nickname')
|
|
)
|
|
op.create_table('address',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=25), nullable=True),
|
|
sa.Column('street', sa.String(length=25), nullable=True),
|
|
sa.Column('house_number', sa.String(length=10), nullable=True),
|
|
sa.Column('additional', sa.String(length=25), nullable=True),
|
|
sa.Column('postcode', sa.String(length=10), nullable=True),
|
|
sa.Column('city', sa.String(length=25), nullable=True),
|
|
sa.Column('country', sa.String(length=25), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('contact',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('contacttype_id', sa.Integer(), nullable=True),
|
|
sa.Column('content', sa.String(length=200), nullable=False),
|
|
sa.ForeignKeyConstraint(['contacttype_id'], ['contacttype.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('token',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('token', sa.String(length=36), nullable=False),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('user_language',
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('language_id', sa.Integer(), nullable=False),
|
|
sa.Column('level', sa.SmallInteger(), nullable=False),
|
|
sa.ForeignKeyConstraint(['language_id'], ['language.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('user_id', 'language_id')
|
|
)
|
|
op.create_table('user_skill',
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('skill_id', sa.Integer(), nullable=False),
|
|
sa.Column('level', sa.SmallInteger(), nullable=False),
|
|
sa.ForeignKeyConstraint(['skill_id'], ['skill.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('user_id', 'skill_id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('user_skill')
|
|
op.drop_table('user_language')
|
|
op.drop_table('token')
|
|
op.drop_table('contact')
|
|
op.drop_table('address')
|
|
op.drop_table('user')
|
|
op.drop_table('skill')
|
|
op.drop_table('language')
|
|
op.drop_table('contacttype')
|
|
# ### end Alembic commands ###
|