mirror of https://github.com/logos-co/open-law.git
200 lines
8.7 KiB
Python
200 lines
8.7 KiB
Python
"""empty message
|
|
|
|
Revision ID: 02f6f2ebad1b
|
|
Revises:
|
|
Create Date: 2023-04-21 17:26:06.003994
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '02f6f2ebad1b'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('tags',
|
|
sa.Column('name', sa.String(length=32), nullable=False),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('name')
|
|
)
|
|
op.create_table('users',
|
|
sa.Column('username', sa.String(length=60), nullable=False),
|
|
sa.Column('password_hash', sa.String(length=255), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('username')
|
|
)
|
|
op.create_table('books',
|
|
sa.Column('label', sa.String(length=1024), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('book_contributors',
|
|
sa.Column('role', sa.Enum('UNKNOWN', 'MODERATOR', 'EDITOR', name='roles'), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('book_id', sa.Integer(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('book_versions',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('semver', sa.String(length=1024), nullable=False),
|
|
sa.Column('exported', sa.Boolean(), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
|
sa.Column('derivative_id', sa.Integer(), nullable=True),
|
|
sa.Column('book_id', sa.Integer(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
|
|
sa.ForeignKeyConstraint(['derivative_id'], ['book_versions.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('books_stars',
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('book_id', sa.Integer(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('collections',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('label', sa.String(length=1024), nullable=False),
|
|
sa.Column('about', sa.Text(), nullable=False),
|
|
sa.Column('is_root', sa.Boolean(), nullable=True),
|
|
sa.Column('is_leaf', sa.Boolean(), nullable=True),
|
|
sa.Column('version_id', sa.Integer(), nullable=True),
|
|
sa.Column('parrent_id', sa.Integer(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['parrent_id'], ['collections.id'], ),
|
|
sa.ForeignKeyConstraint(['version_id'], ['book_versions.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('sections',
|
|
sa.Column('label', sa.String(length=1024), nullable=False),
|
|
sa.Column('about', sa.Text(), nullable=True),
|
|
sa.Column('collection_id', sa.Integer(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('version_id', sa.Integer(), nullable=True),
|
|
sa.Column('selected_interpretation_id', sa.Integer(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['collection_id'], ['collections.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.ForeignKeyConstraint(['version_id'], ['book_versions.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('interpretations',
|
|
sa.Column('label', sa.String(length=1024), nullable=False),
|
|
sa.Column('text', sa.Text(), nullable=False),
|
|
sa.Column('marked', sa.Boolean(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('section_id', sa.Integer(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['section_id'], ['sections.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('comments',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('text', sa.Text(), nullable=False),
|
|
sa.Column('marked', sa.Boolean(), nullable=True),
|
|
sa.Column('included_with_interpreation', sa.Boolean(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('parrent_id', sa.Integer(), nullable=True),
|
|
sa.Column('interpretation_id', sa.Integer(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['interpretation_id'], ['interpretations.id'], ),
|
|
sa.ForeignKeyConstraint(['parrent_id'], ['comments.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('interpretation_tags',
|
|
sa.Column('tag_id', sa.Integer(), nullable=True),
|
|
sa.Column('interpretation_id', sa.Integer(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['interpretation_id'], ['interpretations.id'], ),
|
|
sa.ForeignKeyConstraint(['tag_id'], ['tags.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('interpretation_votes',
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('interpretation_id', sa.Integer(), nullable=True),
|
|
sa.Column('possitive', sa.Boolean(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['interpretation_id'], ['interpretations.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('comment_tags',
|
|
sa.Column('tag_id', sa.Integer(), nullable=True),
|
|
sa.Column('comment_id', sa.Integer(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['comment_id'], ['comments.id'], ),
|
|
sa.ForeignKeyConstraint(['tag_id'], ['tags.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('comment_votes',
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('comment_id', sa.Integer(), nullable=True),
|
|
sa.Column('possitive', sa.Boolean(), nullable=True),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('is_deleted', sa.Boolean(), nullable=True),
|
|
sa.ForeignKeyConstraint(['comment_id'], ['comments.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('comment_votes')
|
|
op.drop_table('comment_tags')
|
|
op.drop_table('interpretation_votes')
|
|
op.drop_table('interpretation_tags')
|
|
op.drop_table('comments')
|
|
op.drop_table('interpretations')
|
|
op.drop_table('sections')
|
|
op.drop_table('collections')
|
|
op.drop_table('books_stars')
|
|
op.drop_table('book_versions')
|
|
op.drop_table('book_contributors')
|
|
op.drop_table('books')
|
|
op.drop_table('users')
|
|
op.drop_table('tags')
|
|
# ### end Alembic commands ###
|