mirror of
https://github.com/logos-co/open-law.git
synced 2025-02-16 00:37:07 +00:00
183 lines
5.9 KiB
Python
183 lines
5.9 KiB
Python
"""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 ###
|