You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
4.6 KiB
Python
95 lines
4.6 KiB
Python
"""empty message
|
|
|
|
Revision ID: f4e1b4727000
|
|
Revises:
|
|
Create Date: 2020-03-09 12:32:25.827118
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
import sqlalchemy_utc
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'f4e1b4727000'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('tag',
|
|
sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('content', sa.String(length=128), nullable=False),
|
|
sa.Column('category', sa.Enum('general', 'style', 'circle', 'artist', 'character', 'copyright', name='tag_category'), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('content')
|
|
)
|
|
op.create_table('user',
|
|
sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('username', sa.String(length=128), nullable=False),
|
|
sa.Column('email', sa.String(length=256), nullable=True),
|
|
sa.Column('pass_hash', sa.String(length=128), nullable=True),
|
|
sa.Column('op_level', sa.Enum('user', 'creator', 'moderator', 'admin', name='op_level'), nullable=False),
|
|
sa.Column('user_status', sa.Enum('active', 'inactive', 'banned', name='user_status'), nullable=False),
|
|
sa.Column('last_login', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('email'),
|
|
sa.UniqueConstraint('username')
|
|
)
|
|
op.create_table('post',
|
|
sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('md5', sa.String(length=32), nullable=False),
|
|
sa.Column('filetype', sa.Enum('png', 'jpeg', name='filetype'), nullable=False),
|
|
sa.Column('rating', sa.Enum('safe', 'questionable', 'explicit', name='rating'), nullable=False),
|
|
sa.Column('status', sa.Enum('pending', 'active', 'deleted', name='post_status'), nullable=False),
|
|
sa.Column('width', sa.Integer(), nullable=True),
|
|
sa.Column('height', sa.Integer(), nullable=True),
|
|
sa.Column('filesize', sa.Integer(), nullable=True),
|
|
sa.Column('source', sa.String(length=2048), nullable=True),
|
|
sa.Column('origin_filename', sa.String(length=255), nullable=True),
|
|
sa.Column('author_id', sa.Integer(), nullable=True),
|
|
sa.Column('approver_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['approver_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['author_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('md5')
|
|
)
|
|
op.create_table('comment',
|
|
sa.Column('created', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('updated', sqlalchemy_utc.sqltypes.UtcDateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('content', sa.String(length=512), nullable=False),
|
|
sa.Column('deleted', sa.Boolean(), nullable=True),
|
|
sa.Column('delete_reason', sa.String(length=512), nullable=True),
|
|
sa.Column('post_id', sa.Integer(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['post_id'], ['post.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('post_tags',
|
|
sa.Column('post_id', sa.Integer(), nullable=True),
|
|
sa.Column('tag_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('post_tags')
|
|
op.drop_table('comment')
|
|
op.drop_table('post')
|
|
op.drop_table('user')
|
|
op.drop_table('tag')
|
|
# ### end Alembic commands ###
|