re-init migrations

This commit is contained in:
SvyatoslavArtymovych 2023-06-15 11:13:27 +03:00
parent 7c9f626e23
commit 70dffa874f
13 changed files with 65 additions and 527 deletions

View File

@ -1,36 +0,0 @@
"""BookVersion.is_active
Revision ID: 03e8384a23e1
Revises: a41f004cad1a
Create Date: 2023-06-12 12:38:03.152423
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "03e8384a23e1"
down_revision = "a41f004cad1a"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("book_versions", schema=None) as batch_op:
batch_op.add_column(sa.Column("is_active", sa.Boolean(), nullable=True))
batch_op.drop_column("exported")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("book_versions", schema=None) as batch_op:
batch_op.add_column(
sa.Column("exported", sa.BOOLEAN(), autoincrement=False, nullable=True)
)
batch_op.drop_column("is_active")
# ### end Alembic commands ###

View File

@ -1,104 +0,0 @@
"""add_fields_to_notification
Revision ID: 3d45df38ffa9
Revises: 8f9233babba4
Create Date: 2023-06-09 17:23:32.809580
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "3d45df38ffa9"
down_revision = "8f9233babba4"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
action = postgresql.ENUM(
"CREATE",
"EDIT",
"DELETE",
"VOTE",
"APPROVE",
"CONTRIBUTING",
"MENTION",
name="actions",
)
action.create(op.get_bind())
entity = postgresql.ENUM(
"SECTION",
"COLLECTION",
"INTERPRETATION",
"COMMENT",
"BOOK",
name="entities",
)
entity.create(op.get_bind())
with op.batch_alter_table("notifications", schema=None) as batch_op:
batch_op.add_column(
sa.Column(
"action",
sa.Enum(
"CREATE",
"EDIT",
"DELETE",
"VOTE",
"APPROVE",
"CONTRIBUTING",
"MENTION",
name="actions",
),
nullable=True,
)
)
batch_op.add_column(
sa.Column(
"entity",
sa.Enum(
"SECTION",
"COLLECTION",
"INTERPRETATION",
"COMMENT",
"BOOK",
name="entities",
),
nullable=True,
)
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
action = postgresql.ENUM(
"CREATE",
"EDIT",
"DELETE",
"VOTE",
"APPROVE",
"CONTRIBUTING",
"MENTION",
name="actions",
)
action.drop(op.get_bind())
entity = postgresql.ENUM(
"SECTION",
"COLLECTION",
"INTERPRETATION",
"COMMENT",
"BOOK",
name="entities",
)
entity.drop(op.get_bind())
with op.batch_alter_table("notifications", schema=None) as batch_op:
batch_op.drop_column("entity")
batch_op.drop_column("action")
# ### end Alembic commands ###

View File

@ -1,39 +0,0 @@
"""remove selected_interpretation_id
Revision ID: 776fd9579f1f
Revises: 7c8a5aefe801
Create Date: 2023-05-26 14:38:44.858319
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "776fd9579f1f"
down_revision = "96995454b90d"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("sections", schema=None) as batch_op:
batch_op.drop_column("selected_interpretation_id")
# ### 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(
"selected_interpretation_id",
sa.INTEGER(),
autoincrement=False,
nullable=True,
)
)
# ### end Alembic commands ###

View File

@ -1,42 +0,0 @@
"""remove mark fields
Revision ID: 7c8a5aefe801
Revises: 776fd9579f1f
Create Date: 2023-05-25 15:44:06.072076
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7c8a5aefe801"
down_revision = "776fd9579f1f"
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.drop_column("marked")
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.drop_column("marked")
# ### 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.add_column(
sa.Column("marked", sa.BOOLEAN(), autoincrement=False, nullable=True)
)
with op.batch_alter_table("comments", schema=None) as batch_op:
batch_op.add_column(
sa.Column("marked", sa.BOOLEAN(), autoincrement=False, nullable=True)
)
# ### end Alembic commands ###

View File

@ -1,34 +0,0 @@
"""fork
Revision ID: 8f11cadae6a8
Revises: a8184a265190
Create Date: 2023-06-14 14:18:04.714697
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8f11cadae6a8'
down_revision = 'a8184a265190'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('books', schema=None) as batch_op:
batch_op.add_column(sa.Column('original_book_id', sa.Integer(), nullable=True))
batch_op.create_foreign_key(None, 'books', ['original_book_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('books', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.drop_column('original_book_id')
# ### end Alembic commands ###

View File

@ -1,42 +0,0 @@
"""notifications
Revision ID: 8f9233babba4
Revises: 96995454b90d
Create Date: 2023-06-08 14:49:51.600531
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "8f9233babba4"
down_revision = "a41f004cad1a"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"notifications",
sa.Column("link", sa.String(length=256), nullable=False),
sa.Column("text", sa.String(length=256), nullable=False),
sa.Column("is_read", sa.Boolean(), 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"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("notifications")
# ### end Alembic commands ###

View File

@ -1,8 +1,8 @@
"""init
Revision ID: 79e8c7bff9c9
Revision ID: 94ee8daa0c25
Revises:
Create Date: 2023-06-01 15:31:33.635236
Create Date: 2023-06-15 11:12:23.898629
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "79e8c7bff9c9"
revision = "94ee8daa0c25"
down_revision = None
branch_labels = None
depends_on = None
@ -55,6 +55,7 @@ def upgrade():
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("is_super_user", 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),
@ -66,6 +67,53 @@ def upgrade():
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("original_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(
["original_book_id"],
["books.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"notifications",
sa.Column(
"action",
sa.Enum(
"CREATE",
"EDIT",
"DELETE",
"VOTE",
"APPROVE",
"CONTRIBUTING",
"MENTION",
name="actions",
),
nullable=True,
),
sa.Column(
"entity",
sa.Enum(
"SECTION",
"COLLECTION",
"INTERPRETATION",
"COMMENT",
"BOOK",
name="entities",
),
nullable=True,
),
sa.Column("entity_id", sa.Integer(), nullable=False),
sa.Column("link", sa.String(length=256), nullable=False),
sa.Column("text", sa.String(length=256), nullable=False),
sa.Column("is_read", sa.Boolean(), 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),
@ -131,10 +179,11 @@ def upgrade():
"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("is_active", 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("user_id", sa.Integer(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(
@ -145,6 +194,10 @@ def upgrade():
["derivative_id"],
["book_versions.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
@ -188,6 +241,8 @@ def upgrade():
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("position", sa.Integer(), nullable=True),
sa.Column("copy_of", sa.Integer(), 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),
@ -256,10 +311,11 @@ def upgrade():
op.create_table(
"sections",
sa.Column("label", sa.String(length=256), nullable=False),
sa.Column("position", sa.Integer(), nullable=True),
sa.Column("copy_of", sa.Integer(), 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),
@ -282,9 +338,10 @@ def upgrade():
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("copy_of", sa.Integer(), nullable=True),
sa.Column("user_id", sa.Integer(), nullable=True),
sa.Column("section_id", sa.Integer(), nullable=True),
sa.Column("score", 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),
@ -337,8 +394,8 @@ def upgrade():
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("copy_of", sa.Integer(), 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),
@ -470,11 +527,9 @@ def downgrade():
op.drop_table("book_tags")
op.drop_table("book_contributors")
op.drop_table("access_groups")
op.drop_table("notifications")
op.drop_table("books")
op.drop_table("users")
op.drop_table("tags")
op.drop_table("permissions")
# ### end Alembic commands ###
""

View File

@ -1,38 +0,0 @@
"""ordering
Revision ID: 96995454b90d
Revises: 79e8c7bff9c9
Create Date: 2023-06-01 17:01:00.877443
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "96995454b90d"
down_revision = "79e8c7bff9c9"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("collections", schema=None) as batch_op:
batch_op.add_column(sa.Column("position", sa.Integer(), nullable=True))
with op.batch_alter_table("sections", schema=None) as batch_op:
batch_op.add_column(sa.Column("position", sa.Integer(), nullable=True))
# ### 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.drop_column("position")
with op.batch_alter_table("collections", schema=None) as batch_op:
batch_op.drop_column("position")
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""user.is_super_user
Revision ID: a41f004cad1a
Revises: 7c8a5aefe801
Create Date: 2023-05-25 14:31:14.046066
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "a41f004cad1a"
down_revision = "7c8a5aefe801"
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_super_user", sa.Boolean(), 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("is_super_user")
# ### end Alembic commands ###

View File

@ -1,34 +0,0 @@
"""version_user_id
Revision ID: a8184a265190
Revises: ef2254f9bc92
Create Date: 2023-06-14 14:04:38.690202
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a8184a265190'
down_revision = 'ef2254f9bc92'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('book_versions', schema=None) as batch_op:
batch_op.add_column(sa.Column('user_id', sa.Integer(), nullable=True))
batch_op.create_foreign_key(None, 'users', ['user_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('book_versions', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.drop_column('user_id')
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""entity_id
Revision ID: ad0ed27f417f
Revises: 3d45df38ffa9
Create Date: 2023-06-12 12:03:44.954134
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "ad0ed27f417f"
down_revision = "3d45df38ffa9"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("notifications", schema=None) as batch_op:
batch_op.add_column(sa.Column("entity_id", sa.Integer(), nullable=False))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("notifications", schema=None) as batch_op:
batch_op.drop_column("entity_id")
# ### end Alembic commands ###

View File

@ -1,50 +0,0 @@
"""copy of fields
Revision ID: ef2254f9bc92
Revises: 03e8384a23e1
Create Date: 2023-06-13 09:43:26.575245
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "ef2254f9bc92"
down_revision = "03e8384a23e1"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("collections", schema=None) as batch_op:
batch_op.add_column(sa.Column("copy_of", sa.Integer(), nullable=True))
with op.batch_alter_table("comments", schema=None) as batch_op:
batch_op.add_column(sa.Column("copy_of", sa.Integer(), nullable=True))
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.add_column(sa.Column("copy_of", sa.Integer(), nullable=True))
with op.batch_alter_table("sections", schema=None) as batch_op:
batch_op.add_column(sa.Column("copy_of", sa.Integer(), nullable=True))
# ### 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.drop_column("copy_of")
with op.batch_alter_table("interpretations", schema=None) as batch_op:
batch_op.drop_column("copy_of")
with op.batch_alter_table("comments", schema=None) as batch_op:
batch_op.drop_column("copy_of")
with op.batch_alter_table("collections", schema=None) as batch_op:
batch_op.drop_column("copy_of")
# ### end Alembic commands ###

View File

@ -1,34 +0,0 @@
"""score
Revision ID: f104cc0131c5
Revises: ad0ed27f417f
Create Date: 2023-06-13 17:04:08.590895
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "f104cc0131c5"
down_revision = "ad0ed27f417f"
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("score", sa.Integer(), nullable=True, server_default="0")
)
# ### 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("score")
# ### end Alembic commands ###