blog/migrations/versions/d091fbf48f6f_001.py
2021-05-01 16:19:02 +02:00

107 lines
4.1 KiB
Python

"""001
Revision ID: d091fbf48f6f
Revises:
Create Date: 2021-05-01 11:54:58.288320
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd091fbf48f6f'
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.Integer(), nullable=False),
sa.Column('uuid', sa.Unicode(), nullable=True),
sa.Column('name', sa.Unicode(), nullable=True),
sa.Column('description', sa.Unicode(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_index(op.f('ix_role_uuid'), 'role', ['uuid'], unique=False)
op.create_table('task',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(), nullable=True),
sa.Column('uuid', sa.Unicode(), nullable=True),
sa.Column('status', sa.Unicode(), nullable=True),
sa.Column('func_name', sa.Unicode(), nullable=True),
sa.Column('args', sa.Unicode(), nullable=True),
sa.Column('kwargs', sa.Unicode(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('uuid', sa.Unicode(), nullable=True),
sa.Column('email', sa.Unicode(), nullable=True),
sa.Column('password', sa.Unicode(), nullable=True),
sa.Column('active', sa.Boolean(), nullable=True),
sa.Column('confirmed_at', sa.DateTime(), nullable=True),
sa.Column('timezone', sa.String(), nullable=True),
sa.Column('tz_offset_seconds', sa.Integer(), nullable=True),
sa.Column('locale', sa.String(length=4), nullable=True),
sa.Column('name', sa.Unicode(), nullable=True),
sa.Column('profile_image_url', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
op.create_index(op.f('ix_user_uuid'), 'user', ['uuid'], unique=False)
op.create_table('blog_post',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('uuid', sa.Unicode(), nullable=True),
sa.Column('filename', sa.UnicodeText(), nullable=True),
sa.Column('title', sa.UnicodeText(), nullable=True),
sa.Column('body', sa.UnicodeText(), nullable=True),
sa.Column('created_dt', sa.UnicodeText(), nullable=True),
sa.Column('updated_dt', sa.UnicodeText(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_blog_post_uuid'), 'blog_post', ['uuid'], unique=False)
op.create_table('roles_users',
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('role_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
)
op.create_table('tag',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('uuid', sa.Unicode(), nullable=True),
sa.Column('name', sa.UnicodeText(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tag_uuid'), 'tag', ['uuid'], unique=False)
op.create_table('blog_post__tag',
sa.Column('blog_post_id', sa.Integer(), nullable=True),
sa.Column('tag_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['blog_post_id'], ['blog_post.id'], ),
sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], )
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('blog_post__tag')
op.drop_index(op.f('ix_tag_uuid'), table_name='tag')
op.drop_table('tag')
op.drop_table('roles_users')
op.drop_index(op.f('ix_blog_post_uuid'), table_name='blog_post')
op.drop_table('blog_post')
op.drop_index(op.f('ix_user_uuid'), table_name='user')
op.drop_table('user')
op.drop_table('task')
op.drop_index(op.f('ix_role_uuid'), table_name='role')
op.drop_table('role')
# ### end Alembic commands ###