reinit migrations

This commit is contained in:
SvyatoslavArtymovych 2023-06-01 15:34:24 +03:00
parent 4083d7fa57
commit f7701b78a0
14 changed files with 311 additions and 930 deletions

View File

@ -1,34 +0,0 @@
"""user wallet_id
Revision ID: 067a10a531d7
Revises: bbc4b55246ba
Create Date: 2023-05-03 11:53:14.455999
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "067a10a531d7"
down_revision = "bbc4b55246ba"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.add_column(
sa.Column("wallet_id", sa.String(length=255), nullable=True)
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.drop_column("wallet_id")
# ### end Alembic commands ###

View File

@ -1,44 +0,0 @@
"""book-tags
Revision ID: 0961578f302a
Revises: 5df1fabbee7d
Create Date: 2023-05-16 10:58:44.518470
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0961578f302a"
down_revision = "a9df3da8cd00"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"book_tags",
sa.Column("tag_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(
["tag_id"],
["tags.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("book_tags")
# ### end Alembic commands ###

View File

@ -1,182 +0,0 @@
"""access_groups
Revision ID: 0fc51411af21
Revises: 7baa732e01c6
Create Date: 2023-05-25 12:44:41.843011
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "0fc51411af21"
down_revision = "7baa732e01c6"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"permissions",
sa.Column("access", sa.Integer(), nullable=True),
sa.Column(
"entity_type",
sa.Enum(
"UNKNOWN",
"BOOK",
"COLLECTION",
"SECTION",
"INTERPRETATION",
"COMMENT",
name="entity",
),
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"),
)
op.create_table(
"access_groups",
sa.Column("name", sa.String(length=32), nullable=False),
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.PrimaryKeyConstraint("id"),
)
op.create_table(
"books_access_groups",
sa.Column("book_id", sa.Integer(), nullable=True),
sa.Column("access_group_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(
["access_group_id"],
["access_groups.id"],
),
sa.ForeignKeyConstraint(
["book_id"],
["books.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"permissions_access_groups",
sa.Column("permission_id", sa.Integer(), nullable=True),
sa.Column("access_group_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(
["access_group_id"],
["access_groups.id"],
),
sa.ForeignKeyConstraint(
["permission_id"],
["permissions.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"users_access_groups",
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("access_group_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(
["access_group_id"],
["access_groups.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"collections_access_groups",
sa.Column("collection_id", sa.Integer(), nullable=True),
sa.Column("access_group_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(
["access_group_id"],
["access_groups.id"],
),
sa.ForeignKeyConstraint(
["collection_id"],
["collections.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"sections_access_groups",
sa.Column("section_id", sa.Integer(), nullable=True),
sa.Column("access_group_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(
["access_group_id"],
["access_groups.id"],
),
sa.ForeignKeyConstraint(
["section_id"],
["sections.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"interpretations_access_groups",
sa.Column("interpretation_id", sa.Integer(), nullable=True),
sa.Column("access_group_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(
["access_group_id"],
["access_groups.id"],
),
sa.ForeignKeyConstraint(
["interpretation_id"],
["interpretations.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("interpretations_access_groups")
op.drop_table("sections_access_groups")
op.drop_table("collections_access_groups")
op.drop_table("users_access_groups")
op.drop_table("permissions_access_groups")
op.drop_table("books_access_groups")
op.drop_table("access_groups")
op.drop_table("permissions")
entity = postgresql.ENUM(
"UNKNOWN",
"BOOK",
"COLLECTION",
"SECTION",
"INTERPRETATION",
"COMMENT",
name="entity",
)
entity.drop(op.get_bind())
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""comment_edited
Revision ID: 1dfa1f2c208f
Revises: 2ec60080de3b
Create Date: 2023-05-09 17:22:23.028408
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "1dfa1f2c208f"
down_revision = "2ec60080de3b"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("comments", schema=None) as batch_op:
batch_op.add_column(sa.Column("edited", sa.Boolean(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("comments", schema=None) as batch_op:
batch_op.drop_column("edited")
# ### end Alembic commands ###

View File

@ -1,42 +0,0 @@
"""wallet_id length
Revision ID: 2ec60080de3b
Revises: 4ce4bacc7c06
Create Date: 2023-05-05 16:47:55.533205
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "2ec60080de3b"
down_revision = "4ce4bacc7c06"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.alter_column(
"wallet_id",
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=64),
existing_nullable=True,
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.alter_column(
"wallet_id",
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=256),
existing_nullable=True,
)
# ### end Alembic commands ###

View File

@ -1,38 +0,0 @@
"""user_is_activated
Revision ID: 377fc0b7e4bb
Revises: a1345b416f81
Create Date: 2023-05-04 11:14:58.810826
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "377fc0b7e4bb"
down_revision = "a1345b416f81"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.add_column(sa.Column("is_activated", sa.Boolean(), nullable=True))
batch_op.alter_column(
"username", existing_type=sa.VARCHAR(length=60), nullable=True
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.alter_column(
"username", existing_type=sa.VARCHAR(length=60), nullable=False
)
batch_op.drop_column("is_activated")
# ### end Alembic commands ###

View File

@ -1,66 +0,0 @@
"""created_at_on_inter
Revision ID: 4ce4bacc7c06
Revises: 377fc0b7e4bb
Create Date: 2023-05-05 16:31:52.963720
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "4ce4bacc7c06"
down_revision = "377fc0b7e4bb"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.alter_column(
"username",
existing_type=sa.VARCHAR(length=60),
type_=sa.String(length=64),
existing_nullable=True,
)
batch_op.alter_column(
"password_hash",
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=256),
existing_nullable=True,
)
batch_op.alter_column(
"wallet_id",
existing_type=sa.VARCHAR(length=255),
type_=sa.String(length=256),
existing_nullable=True,
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.alter_column(
"wallet_id",
existing_type=sa.String(length=256),
type_=sa.VARCHAR(length=255),
existing_nullable=True,
)
batch_op.alter_column(
"password_hash",
existing_type=sa.String(length=256),
type_=sa.VARCHAR(length=255),
existing_nullable=True,
)
batch_op.alter_column(
"username",
existing_type=sa.String(length=64),
type_=sa.VARCHAR(length=60),
existing_nullable=True,
)
# ### end Alembic commands ###

View File

@ -1,47 +0,0 @@
"""approved fields
Revision ID: 5df1fabbee7d
Revises: 1dfa1f2c208f
Create Date: 2023-05-11 15:06:42.883725
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5df1fabbee7d"
down_revision = "1dfa1f2c208f"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("comments", schema=None) as batch_op:
batch_op.add_column(sa.Column("approved", sa.Boolean(), nullable=True))
batch_op.drop_column("included_with_interpretation")
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.add_column(sa.Column("approved", sa.Boolean(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.drop_column("approved")
with op.batch_alter_table("comments", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"included_with_interpretation",
sa.BOOLEAN(),
autoincrement=False,
nullable=True,
)
)
batch_op.drop_column("approved")
# ### end Alembic commands ###

View File

@ -0,0 +1,311 @@
"""init
Revision ID: 79e8c7bff9c9
Revises:
Create Date: 2023-06-01 15:31:33.635236
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '79e8c7bff9c9'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('permissions',
sa.Column('access', sa.Integer(), nullable=True),
sa.Column('entity_type', sa.Enum('UNKNOWN', 'BOOK', 'COLLECTION', 'SECTION', 'INTERPRETATION', 'COMMENT', name='entity'), 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')
)
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=64), nullable=True),
sa.Column('password_hash', sa.String(length=256), nullable=True),
sa.Column('is_activated', sa.Boolean(), nullable=True),
sa.Column('wallet_id', sa.String(length=64), nullable=True),
sa.Column('avatar_img', sa.Text(), 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=256), nullable=False),
sa.Column('about', sa.Text(), nullable=True),
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('access_groups',
sa.Column('name', sa.String(length=32), nullable=False),
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.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_tags',
sa.Column('tag_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(['tag_id'], ['tags.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('book_versions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('semver', sa.String(length=16), 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('books_access_groups',
sa.Column('book_id', sa.Integer(), nullable=True),
sa.Column('access_group_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(['access_group_id'], ['access_groups.id'], ),
sa.ForeignKeyConstraint(['book_id'], ['books.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('collections',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('label', sa.String(length=256), nullable=False),
sa.Column('about', sa.Text(), nullable=True),
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('parent_id', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('is_deleted', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['parent_id'], ['collections.id'], ),
sa.ForeignKeyConstraint(['version_id'], ['book_versions.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('permissions_access_groups',
sa.Column('permission_id', sa.Integer(), nullable=True),
sa.Column('access_group_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(['access_group_id'], ['access_groups.id'], ),
sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('users_access_groups',
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('access_group_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(['access_group_id'], ['access_groups.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('collections_access_groups',
sa.Column('collection_id', sa.Integer(), nullable=True),
sa.Column('access_group_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(['access_group_id'], ['access_groups.id'], ),
sa.ForeignKeyConstraint(['collection_id'], ['collections.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('sections',
sa.Column('label', sa.String(length=256), nullable=False),
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('text', sa.Text(), nullable=False),
sa.Column('plain_text', sa.Text(), nullable=True),
sa.Column('approved', sa.Boolean(), nullable=True),
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('section_tags',
sa.Column('tag_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(['tag_id'], ['tags.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('sections_access_groups',
sa.Column('section_id', sa.Integer(), nullable=True),
sa.Column('access_group_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(['access_group_id'], ['access_groups.id'], ),
sa.ForeignKeyConstraint(['section_id'], ['sections.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('comments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('text', sa.Text(), nullable=False),
sa.Column('approved', sa.Boolean(), nullable=True),
sa.Column('marked', sa.Boolean(), nullable=True),
sa.Column('edited', sa.Boolean(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('parent_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(['parent_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('positive', 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('interpretations_access_groups',
sa.Column('interpretation_id', sa.Integer(), nullable=True),
sa.Column('access_group_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(['access_group_id'], ['access_groups.id'], ),
sa.ForeignKeyConstraint(['interpretation_id'], ['interpretations.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('positive', 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('interpretations_access_groups')
op.drop_table('interpretation_votes')
op.drop_table('interpretation_tags')
op.drop_table('comments')
op.drop_table('sections_access_groups')
op.drop_table('section_tags')
op.drop_table('interpretations')
op.drop_table('sections')
op.drop_table('collections_access_groups')
op.drop_table('users_access_groups')
op.drop_table('permissions_access_groups')
op.drop_table('collections')
op.drop_table('books_access_groups')
op.drop_table('books_stars')
op.drop_table('book_versions')
op.drop_table('book_tags')
op.drop_table('book_contributors')
op.drop_table('access_groups')
op.drop_table('books')
op.drop_table('users')
op.drop_table('tags')
op.drop_table('permissions')
# ### end Alembic commands ###

View File

@ -1,44 +0,0 @@
"""section-tags
Revision ID: 7baa732e01c6
Revises: 0961578f302a
Create Date: 2023-05-17 18:34:29.178354
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7baa732e01c6"
down_revision = "0961578f302a"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"section_tags",
sa.Column("tag_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(
["tag_id"],
["tags.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("section_tags")
# ### end Alembic commands ###

View File

@ -1,44 +0,0 @@
"""remove fields from section and interpretation
Revision ID: 883298018384
Revises: 5df1fabbee7d
Create Date: 2023-05-18 15:49:20.145655
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "883298018384"
down_revision = "5df1fabbee7d"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.drop_column("label")
with op.batch_alter_table("sections", schema=None) as batch_op:
batch_op.drop_column("about")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("sections", schema=None) as batch_op:
batch_op.add_column(
sa.Column("about", sa.TEXT(), autoincrement=False, nullable=True)
)
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"label", sa.VARCHAR(length=256), autoincrement=False, nullable=False
)
)
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""user avatar_img
Revision ID: a1345b416f81
Revises: 067a10a531d7
Create Date: 2023-05-04 09:11:09.406698
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "a1345b416f81"
down_revision = "067a10a531d7"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.add_column(sa.Column("avatar_img", sa.Text(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("users", schema=None) as batch_op:
batch_op.drop_column("avatar_img")
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""plain_text
Revision ID: a9df3da8cd00
Revises: 883298018384
Create Date: 2023-05-23 10:42:06.239982
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "a9df3da8cd00"
down_revision = "883298018384"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.add_column(sa.Column("plain_text", sa.Text()))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.drop_column("plain_text")
# ### end Alembic commands ###

View File

@ -1,293 +0,0 @@
"""init
Revision ID: bbc4b55246ba
Revises:
Create Date: 2023-04-28 10:13:52.011272
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "bbc4b55246ba"
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=256), nullable=False),
sa.Column("about", sa.Text(), nullable=True),
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=16), 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=256), nullable=False),
sa.Column("about", sa.Text(), nullable=True),
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("parent_id", sa.Integer(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
["parent_id"],
["collections.id"],
),
sa.ForeignKeyConstraint(
["version_id"],
["book_versions.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"sections",
sa.Column("label", sa.String(length=256), 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=256), 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_interpretation", sa.Boolean(), nullable=True),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("parent_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(
["parent_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("positive", 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("positive", 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 ###