luthor/luthor/alembic/versions/74058d75b7a0_initial_commit.py

300 lines
17 KiB
Python

"""Initial Commit
Revision ID: 74058d75b7a0
Revises:
Create Date: 2020-12-29 18:58:42.976796
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
from sqlalchemy.sql import expression
revision = "74058d75b7a0"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"acts",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_acts")),
sa.UniqueConstraint("name", name=op.f("uq_acts_name")),
)
op.create_table(
"advocates",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.Column("mobile", sa.Unicode(length=255), nullable=False),
sa.Column("landline", sa.Unicode(length=255), nullable=False),
sa.Column("address", sa.Unicode(length=255), nullable=False),
sa.Column("email", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_advocates")),
)
op.create_table(
"case_sources",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.Column("prefix", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_case_sources")),
sa.UniqueConstraint("name", name=op.f("uq_case_sources_name")),
sa.UniqueConstraint("prefix", name=op.f("uq_case_sources_prefix")),
)
op.create_table(
"case_types",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_case_types")),
sa.UniqueConstraint("name", name=op.f("uq_case_types_name")),
)
op.create_table(
"court_statuses",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_court_statuses")),
sa.UniqueConstraint("name", name=op.f("uq_court_statuses_name")),
)
op.create_table(
"courts",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_courts")),
sa.UniqueConstraint("name", name=op.f("uq_courts_name")),
)
op.create_table(
"departments",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_departments")),
sa.UniqueConstraint("name", name=op.f("uq_departments_name")),
)
op.create_table(
"natures",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_natures")),
sa.UniqueConstraint("name", name=op.f("uq_natures_name")),
)
op.create_table(
"office_statuses",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_office_statuses")),
sa.UniqueConstraint("name", name=op.f("uq_office_statuses_name")),
)
op.create_table(
"permissions",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint("id", name=op.f("pk_permissions")),
sa.UniqueConstraint("name", name=op.f("uq_permissions_name")),
)
op.create_table(
"roles",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=True),
sa.PrimaryKeyConstraint("id", name=op.f("pk_roles")),
sa.UniqueConstraint("name", name=op.f("uq_roles_name")),
)
op.create_table(
"users",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.Column("password", sa.Unicode(length=60), nullable=False),
sa.Column("locked_out", sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_users")),
sa.UniqueConstraint("name", name=op.f("uq_users_name")),
)
op.create_table(
"offices",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("department_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_department_id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.Column("address", sa.Unicode(length=255), nullable=True),
sa.Column("email", sa.Unicode(length=255), nullable=True),
sa.ForeignKeyConstraint(
["department_id"], ["departments.id"], name=op.f("fk_offices_department_id_departments")
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_offices")),
)
op.create_table(
"role_permissions",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("role_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_user_id", sa.Integer(), nullable=False),
sa.Column("permission_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_permission_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["permission_id"], ["permissions.id"], name=op.f("fk_role_permissions_permission_id_permissions")
),
sa.ForeignKeyConstraint(["role_id"], ["roles.id"], name=op.f("fk_role_permissions_role_id_roles")),
sa.PrimaryKeyConstraint("id", name=op.f("pk_role_permissions")),
sa.UniqueConstraint("permission_id", "role_id", name=op.f("uq_role_permissions_permission_id")),
)
op.create_table(
"user_roles",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("role_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.ForeignKeyConstraint(["role_id"], ["roles.id"], name=op.f("fk_user_roles_role_id_roles")),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], name=op.f("fk_user_roles_user_id_users")),
sa.PrimaryKeyConstraint("id", name=op.f("pk_user_roles")),
sa.UniqueConstraint("user_id", "role_id", name=op.f("uq_user_roles_user_id")),
)
op.create_table(
"cases",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("old_office_file_number", sa.Unicode(length=255), nullable=False),
sa.Column("office_file_number", sa.Integer(), nullable=False),
sa.Column("court_case_number", sa.Unicode(length=255), nullable=True),
sa.Column("year", sa.Unicode(length=255), nullable=False),
sa.Column("title", sa.Unicode(length=255), nullable=True),
sa.Column("docket_number", sa.Unicode(length=255), nullable=True),
sa.Column("receipt_date", sa.DateTime(), nullable=True),
sa.Column("limitation_date", sa.DateTime(), nullable=True),
sa.Column("filing_date", sa.DateTime(), nullable=True),
sa.Column("appear_on_behalf_of", sa.Unicode(length=255), nullable=True),
sa.Column("question_of_law", sa.Unicode(length=4000), nullable=True),
sa.Column("aor_name", sa.Unicode(length=255), nullable=True),
sa.Column("opposing_council_aor", sa.Unicode(length=255), nullable=True),
sa.Column("opposing_council_detail", sa.Unicode(length=255), nullable=True),
sa.Column("lower_court_case_number", sa.Unicode(length=2000), nullable=True),
sa.Column("date_of_impugned_judgement", sa.DateTime(), nullable=True),
sa.Column("brief_description", sa.Unicode(length=10000), nullable=True),
sa.Column("remarks", sa.Unicode(length=10000), nullable=True),
sa.Column("slp_counter", sa.Unicode(length=255), nullable=True),
sa.Column("contact_detail", sa.Unicode(length=255), nullable=True),
sa.Column("case_connected_with", sa.Unicode(length=255), nullable=True),
sa.Column("bunch_cases", sa.Unicode(length=255), nullable=True),
sa.Column("is_deleted", sa.Boolean(), nullable=False, server_default=expression.false()),
sa.Column("court_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_court_id", sa.Integer(), nullable=True),
sa.Column("department_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_department_id", sa.Integer(), nullable=True),
sa.Column("office_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_office_id", sa.Integer(), nullable=True),
sa.Column("case_type_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_case_type_id", sa.Integer(), nullable=True),
sa.Column("act_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_act_id", sa.Integer(), nullable=True),
sa.Column("nature_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_nature_id", sa.Integer(), nullable=True),
sa.Column("office_status_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_office_status_id", sa.Integer(), nullable=True),
sa.Column("court_status_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_court_status_id", sa.Integer(), nullable=True),
sa.Column("case_source_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.ForeignKeyConstraint(["act_id"], ["acts.id"], name=op.f("fk_cases_act_id_acts")),
sa.ForeignKeyConstraint(["case_type_id"], ["case_types.id"], name=op.f("fk_cases_case_type_id_case_types")),
sa.ForeignKeyConstraint(["court_id"], ["courts.id"], name=op.f("fk_cases_court_id_courts")),
sa.ForeignKeyConstraint(
["court_status_id"], ["court_statuses.id"], name=op.f("fk_cases_court_status_id_court_statuses")
),
sa.ForeignKeyConstraint(["department_id"], ["departments.id"], name=op.f("fk_cases_department_id_departments")),
sa.ForeignKeyConstraint(["nature_id"], ["natures.id"], name=op.f("fk_cases_nature_id_natures")),
sa.ForeignKeyConstraint(["office_id"], ["offices.id"], name=op.f("fk_cases_office_id_offices")),
sa.ForeignKeyConstraint(
["office_status_id"], ["office_statuses.id"], name=op.f("fk_cases_office_status_id_office_statuses")
),
sa.ForeignKeyConstraint(
["case_source_id"], ["case_sources.id"], name=op.f("fk_cases_case_source_id_case_sources")
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_cases")),
)
op.create_index(op.f("ix_cases_date_of_impugned_judgement"), "cases", ["date_of_impugned_judgement"], unique=False)
op.create_index(op.f("ix_cases_filing_date"), "cases", ["filing_date"], unique=False)
op.create_index(op.f("ix_cases_limitation_date"), "cases", ["limitation_date"], unique=False)
op.create_index(op.f("ix_cases_receipt_date"), "cases", ["receipt_date"], unique=False)
op.create_table(
"contacts",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("office_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("department_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("name", sa.Unicode(length=255), nullable=False),
sa.Column("mobile", sa.Unicode(length=255), nullable=False),
sa.Column("landline", sa.Unicode(length=255), nullable=False),
sa.Column("address", sa.Unicode(length=255), nullable=True),
sa.Column("email", sa.Unicode(length=255), nullable=True),
sa.ForeignKeyConstraint(
["department_id"], ["departments.id"], name=op.f("fk_contacts_department_id_departments")
),
sa.ForeignKeyConstraint(["office_id"], ["offices.id"], name=op.f("fk_contacts_office_id_offices")),
sa.PrimaryKeyConstraint("id", name=op.f("pk_contacts")),
sa.UniqueConstraint("landline", name=op.f("uq_contacts_landline")),
sa.UniqueConstraint("mobile", name=op.f("uq_contacts_mobile")),
)
op.create_table(
"hearings",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False),
sa.Column("old_id", sa.Integer(), nullable=False),
sa.Column("case_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_case_id", sa.Integer(), nullable=False),
sa.Column("court_number", sa.Unicode(length=255), nullable=True),
sa.Column("item_number", sa.Unicode(length=255), nullable=True),
sa.Column("bench", sa.Unicode(length=255), nullable=True),
sa.Column("proceedings", sa.Unicode(length=2000), nullable=True),
sa.Column("compliance_date", sa.DateTime(), nullable=True),
sa.Column("next_hearing_date", sa.DateTime(), nullable=False),
sa.Column("court_status_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("old_court_status_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(["case_id"], ["cases.id"], name=op.f("fk_hearings_case_id_cases")),
sa.ForeignKeyConstraint(
["court_status_id"], ["court_statuses.id"], name=op.f("fk_hearings_court_status_id_court_statuses")
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_hearings")),
sa.UniqueConstraint("next_hearing_date", "case_id", name=op.f("uq_hearings_next_hearing_date")),
)
op.create_index(op.f("ix_hearings_case_id"), "hearings", ["case_id"], unique=False)
op.create_index(op.f("ix_hearings_next_hearing_date"), "hearings", ["next_hearing_date"], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_hearings_next_hearing_date"), table_name="hearings")
op.drop_index(op.f("ix_hearings_case_id"), table_name="hearings")
op.drop_table("hearings")
op.drop_table("contacts")
op.drop_index(op.f("ix_cases_receipt_date"), table_name="cases")
op.drop_index(op.f("ix_cases_limitation_date"), table_name="cases")
op.drop_index(op.f("ix_cases_filing_date"), table_name="cases")
op.drop_index(op.f("ix_cases_date_of_impugned_judgement"), table_name="cases")
op.drop_table("cases")
op.drop_table("user_roles")
op.drop_table("role_permissions")
op.drop_table("offices")
op.drop_table("users")
op.drop_table("roles")
op.drop_table("permissions")
op.drop_table("office_statuses")
op.drop_table("natures")
op.drop_table("departments")
op.drop_table("courts")
op.drop_table("court_statuses")
op.drop_table("case_types")
op.drop_table("advocates")
op.drop_table("acts")
# ### end Alembic commands ###