pyproger/migrations/versions/68537cc1688c_initial_migrat...

127 lines
5.2 KiB
Python
Raw Permalink Normal View History

2023-10-10 22:44:32 +03:00
"""initial_migration
Revision ID: 68537cc1688c
Revises:
Create Date: 2023-10-10 22:17:40.476992
"""
from alembic import op
import sqlalchemy as sa
import flask_security
# revision identifiers, used by Alembic.
revision = '68537cc1688c'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('footer_icons',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=30), nullable=True),
sa.Column('bootstrap_ico', sa.String(length=20), nullable=True),
sa.Column('link', sa.String(length=100), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
)
op.create_table('page',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=20), nullable=True),
sa.Column('slug', sa.String(length=50), nullable=False),
sa.Column('text', sa.Text(), nullable=True),
sa.Column('update_datetime', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
)
op.create_table('role',
sa.Column('name', sa.String(length=80), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('description', sa.String(length=255), nullable=True),
sa.Column('permissions', flask_security.datastore.AsaList(), nullable=True),
sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('site_headers',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.String(length=20), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('enabled', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
)
op.create_table('tag',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('tag', sa.String(length=20), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('first_name', sa.String(length=255), nullable=True),
sa.Column('last_name', sa.String(length=255), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('username', sa.String(length=255), nullable=True),
sa.Column('password', sa.String(length=255), nullable=False),
sa.Column('active', sa.Boolean(), nullable=False),
sa.Column('fs_uniquifier', sa.String(length=64), nullable=False),
sa.Column('confirmed_at', sa.DateTime(), nullable=True),
sa.Column('last_login_at', sa.DateTime(), nullable=True),
sa.Column('current_login_at', sa.DateTime(), nullable=True),
sa.Column('last_login_ip', sa.String(length=64), nullable=True),
sa.Column('current_login_ip', sa.String(length=64), nullable=True),
sa.Column('login_count', sa.Integer(), nullable=True),
sa.Column('tf_primary_method', sa.String(length=64), nullable=True),
sa.Column('tf_totp_secret', sa.String(length=255), nullable=True),
sa.Column('tf_phone_number', sa.String(length=128), nullable=True),
sa.Column('create_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('update_datetime', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email'),
sa.UniqueConstraint('fs_uniquifier')
)
op.create_table('post',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('author', sa.Integer(), nullable=True),
sa.Column('slug', sa.String(length=100), nullable=False),
sa.Column('title', sa.Text(), nullable=False),
sa.Column('description', sa.Text(), nullable=False),
sa.Column('published', sa.Boolean(), nullable=True),
sa.Column('create_datetime', sa.DateTime(), nullable=True),
sa.Column('update_datetime', sa.DateTime(), nullable=True),
sa.Column('text', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['author'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
)
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_post',
sa.Column('tag_id', sa.Integer(), nullable=True),
sa.Column('post_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['post_id'], ['post.id'], ),
sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], )
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('tag_post')
op.drop_table('roles_users')
op.drop_table('post')
op.drop_table('user')
op.drop_table('tag')
op.drop_table('site_headers')
op.drop_table('role')
op.drop_table('page')
op.drop_table('footer_icons')
# ### end Alembic commands ###