diff --git a/migrations/versions/03e8384a23e1_bookversion_is_active.py b/migrations/versions/03e8384a23e1_bookversion_is_active.py deleted file mode 100644 index 64ef9e2..0000000 --- a/migrations/versions/03e8384a23e1_bookversion_is_active.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/3d45df38ffa9_add_fields_to_notification.py b/migrations/versions/3d45df38ffa9_add_fields_to_notification.py deleted file mode 100644 index 2025b24..0000000 --- a/migrations/versions/3d45df38ffa9_add_fields_to_notification.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/776fd9579f1f_remove_selected_interpretation_id.py b/migrations/versions/776fd9579f1f_remove_selected_interpretation_id.py deleted file mode 100644 index 0e0a7ec..0000000 --- a/migrations/versions/776fd9579f1f_remove_selected_interpretation_id.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/7c8a5aefe801_remove_mark_fields.py b/migrations/versions/7c8a5aefe801_remove_mark_fields.py deleted file mode 100644 index 03a4a71..0000000 --- a/migrations/versions/7c8a5aefe801_remove_mark_fields.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/8f11cadae6a8_fork.py b/migrations/versions/8f11cadae6a8_fork.py deleted file mode 100644 index bbe174e..0000000 --- a/migrations/versions/8f11cadae6a8_fork.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/8f9233babba4_notifications.py b/migrations/versions/8f9233babba4_notifications.py deleted file mode 100644 index e5da4f7..0000000 --- a/migrations/versions/8f9233babba4_notifications.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/79e8c7bff9c9_init.py b/migrations/versions/94ee8daa0c25_init.py similarity index 87% rename from migrations/versions/79e8c7bff9c9_init.py rename to migrations/versions/94ee8daa0c25_init.py index 7a4c682..61d3891 100644 --- a/migrations/versions/79e8c7bff9c9_init.py +++ b/migrations/versions/94ee8daa0c25_init.py @@ -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 ### - - -"" diff --git a/migrations/versions/96995454b90d_ordering.py b/migrations/versions/96995454b90d_ordering.py deleted file mode 100644 index 76e6445..0000000 --- a/migrations/versions/96995454b90d_ordering.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/a41f004cad1a_user_is_super_user.py b/migrations/versions/a41f004cad1a_user_is_super_user.py deleted file mode 100644 index 0e55827..0000000 --- a/migrations/versions/a41f004cad1a_user_is_super_user.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/a8184a265190_version_user_id.py b/migrations/versions/a8184a265190_version_user_id.py deleted file mode 100644 index 79bd3d7..0000000 --- a/migrations/versions/a8184a265190_version_user_id.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/ad0ed27f417f_entity_id.py b/migrations/versions/ad0ed27f417f_entity_id.py deleted file mode 100644 index 729c6db..0000000 --- a/migrations/versions/ad0ed27f417f_entity_id.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/ef2254f9bc92_copy_of_fields.py b/migrations/versions/ef2254f9bc92_copy_of_fields.py deleted file mode 100644 index 09d1654..0000000 --- a/migrations/versions/ef2254f9bc92_copy_of_fields.py +++ /dev/null @@ -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 ### diff --git a/migrations/versions/f104cc0131c5_score.py b/migrations/versions/f104cc0131c5_score.py deleted file mode 100644 index b294629..0000000 --- a/migrations/versions/f104cc0131c5_score.py +++ /dev/null @@ -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 ###