From ae8b8c371ba4ba4456999e5be40c45a1a0960349 Mon Sep 17 00:00:00 2001 From: shri Date: Sun, 11 Aug 2024 20:01:00 +0200 Subject: [PATCH] Fix location and funding type --- ..._id_mandatory_in_user_and__a05c476c0ae9.py | 142 +++++++++--------- 1 file changed, 73 insertions(+), 69 deletions(-) diff --git a/src/app/db/migrations/versions/2024-07-30_make_tenant_id_mandatory_in_user_and__a05c476c0ae9.py b/src/app/db/migrations/versions/2024-07-30_make_tenant_id_mandatory_in_user_and__a05c476c0ae9.py index e8bba0b3..a0d5c3ef 100644 --- a/src/app/db/migrations/versions/2024-07-30_make_tenant_id_mandatory_in_user_and__a05c476c0ae9.py +++ b/src/app/db/migrations/versions/2024-07-30_make_tenant_id_mandatory_in_user_and__a05c476c0ae9.py @@ -18,6 +18,7 @@ from sqlalchemy.dialects import postgresql from app.db.models.custom_types import LocationType, FundingType + if TYPE_CHECKING: from collections.abc import Sequence @@ -30,8 +31,8 @@ sa.EncryptedText = EncryptedText # revision identifiers, used by Alembic. -revision = 'a05c476c0ae9' -down_revision = 'b6ffcfae703a' +revision = "a05c476c0ae9" +down_revision = "b6ffcfae703a" branch_labels = None depends_on = None @@ -43,6 +44,7 @@ def upgrade() -> None: schema_upgrades() data_upgrades() + def downgrade() -> None: with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=UserWarning) @@ -50,89 +52,91 @@ def downgrade() -> None: data_downgrades() schema_downgrades() + def schema_upgrades() -> None: """schema upgrade migrations go here.""" # ### commands auto generated by Alembic - please adjust! ### - op.create_table('company', - sa.Column('id', sa.GUID(length=16), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.Column('description', sa.String(length=500), nullable=True), - sa.Column('type', sa.String(), nullable=True), - sa.Column('industry', sa.String(), nullable=True), - sa.Column('headcount', sa.Integer(), nullable=True), - sa.Column('founded_year', sa.Integer(), nullable=True), - sa.Column('url', sa.String(length=2083), nullable=True), - sa.Column('profile_pic_url', sa.String(), nullable=True), - sa.Column('linkedin_profile_url', sa.String(), nullable=True), - sa.Column('hq_location', LocationType(astext_type=Text()), nullable=True), - sa.Column('last_funding', FundingType(astext_type=Text()), nullable=True), - sa.Column('slug', sa.String(length=100), nullable=False), - sa.Column('sa_orm_sentinel', sa.Integer(), nullable=True), - sa.Column('created_at', sa.DateTimeUTC(timezone=True), nullable=False), - sa.Column('updated_at', sa.DateTimeUTC(timezone=True), nullable=False), - sa.PrimaryKeyConstraint('id', name=op.f('pk_company')), - sa.UniqueConstraint('slug', name='uq_company_slug') + op.create_table( + "company", + sa.Column("id", sa.GUID(length=16), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.Column("description", sa.String(length=500), nullable=True), + sa.Column("type", sa.String(), nullable=True), + sa.Column("industry", sa.String(), nullable=True), + sa.Column("headcount", sa.Integer(), nullable=True), + sa.Column("founded_year", sa.Integer(), nullable=True), + sa.Column("url", sa.String(length=2083), nullable=True), + sa.Column("profile_pic_url", sa.String(), nullable=True), + sa.Column("linkedin_profile_url", sa.String(), nullable=True), + sa.Column("hq_location", LocationType(), nullable=True), + sa.Column("last_funding", FundingType(), nullable=True), + sa.Column("slug", sa.String(length=100), nullable=False), + sa.Column("sa_orm_sentinel", sa.Integer(), nullable=True), + sa.Column("created_at", sa.DateTimeUTC(timezone=True), nullable=False), + sa.Column("updated_at", sa.DateTimeUTC(timezone=True), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_company")), + sa.UniqueConstraint("slug", name="uq_company_slug"), ) - with op.batch_alter_table('company', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_company_headcount'), ['headcount'], unique=False) - batch_op.create_index(batch_op.f('ix_company_industry'), ['industry'], unique=False) - batch_op.create_index(batch_op.f('ix_company_name'), ['name'], unique=False) - batch_op.create_index('ix_company_slug_unique', ['slug'], unique=True) - batch_op.create_index(batch_op.f('ix_company_type'), ['type'], unique=False) - - op.create_table('job_post', - sa.Column('id', sa.GUID(length=16), nullable=False), - sa.Column('title', sa.String(), nullable=False), - sa.Column('body', sa.Text(), nullable=True), - sa.Column('location', LocationType(astext_type=Text()), nullable=True), - sa.Column('seniority_level', sa.String(), nullable=True), - sa.Column('employment_type', sa.String(), nullable=True), - sa.Column('job_functions', postgresql.JSONB(astext_type=sa.Text()), nullable=True), - sa.Column('total_applicants', sa.Integer(), nullable=True), - sa.Column('url', sa.String(length=2083), nullable=True), - sa.Column('apply_url', sa.String(length=2083), nullable=True), - sa.Column('external_id', sa.String(), nullable=True), - sa.Column('company_id', sa.GUID(length=16), nullable=True), - sa.Column('sa_orm_sentinel', sa.Integer(), nullable=True), - sa.Column('created_at', sa.DateTimeUTC(timezone=True), nullable=False), - sa.Column('updated_at', sa.DateTimeUTC(timezone=True), nullable=False), - sa.ForeignKeyConstraint(['company_id'], ['company.id'], name=op.f('fk_job_post_company_id_company')), - sa.PrimaryKeyConstraint('id', name=op.f('pk_job_post')) + with op.batch_alter_table("company", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_company_headcount"), ["headcount"], unique=False) + batch_op.create_index(batch_op.f("ix_company_industry"), ["industry"], unique=False) + batch_op.create_index(batch_op.f("ix_company_name"), ["name"], unique=False) + batch_op.create_index("ix_company_slug_unique", ["slug"], unique=True) + batch_op.create_index(batch_op.f("ix_company_type"), ["type"], unique=False) + + op.create_table( + "job_post", + sa.Column("id", sa.GUID(length=16), nullable=False), + sa.Column("title", sa.String(), nullable=False), + sa.Column("body", sa.Text(), nullable=True), + sa.Column("location", LocationType(), nullable=True), + sa.Column("seniority_level", sa.String(), nullable=True), + sa.Column("employment_type", sa.String(), nullable=True), + sa.Column("job_functions", postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column("total_applicants", sa.Integer(), nullable=True), + sa.Column("url", sa.String(length=2083), nullable=True), + sa.Column("apply_url", sa.String(length=2083), nullable=True), + sa.Column("external_id", sa.String(), nullable=True), + sa.Column("company_id", sa.GUID(length=16), nullable=True), + sa.Column("sa_orm_sentinel", sa.Integer(), nullable=True), + sa.Column("created_at", sa.DateTimeUTC(timezone=True), nullable=False), + sa.Column("updated_at", sa.DateTimeUTC(timezone=True), nullable=False), + sa.ForeignKeyConstraint(["company_id"], ["company.id"], name=op.f("fk_job_post_company_id_company")), + sa.PrimaryKeyConstraint("id", name=op.f("pk_job_post")), ) - with op.batch_alter_table('job_post', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_job_post_title'), ['title'], unique=False) + with op.batch_alter_table("job_post", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_job_post_title"), ["title"], unique=False) - with op.batch_alter_table('user_account', schema=None) as batch_op: - batch_op.alter_column('tenant_id', - existing_type=sa.UUID(), - nullable=False) + with op.batch_alter_table("user_account", schema=None) as batch_op: + batch_op.alter_column("tenant_id", existing_type=sa.UUID(), nullable=False) # ### end Alembic commands ### + def schema_downgrades() -> None: """schema downgrade migrations go here.""" # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('user_account', schema=None) as batch_op: - batch_op.alter_column('tenant_id', - existing_type=sa.UUID(), - nullable=True) - - with op.batch_alter_table('job_post', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_job_post_title')) - - op.drop_table('job_post') - with op.batch_alter_table('company', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_company_type')) - batch_op.drop_index('ix_company_slug_unique') - batch_op.drop_index(batch_op.f('ix_company_name')) - batch_op.drop_index(batch_op.f('ix_company_industry')) - batch_op.drop_index(batch_op.f('ix_company_headcount')) - - op.drop_table('company') + with op.batch_alter_table("user_account", schema=None) as batch_op: + batch_op.alter_column("tenant_id", existing_type=sa.UUID(), nullable=True) + + with op.batch_alter_table("job_post", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_job_post_title")) + + op.drop_table("job_post") + with op.batch_alter_table("company", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_company_type")) + batch_op.drop_index("ix_company_slug_unique") + batch_op.drop_index(batch_op.f("ix_company_name")) + batch_op.drop_index(batch_op.f("ix_company_industry")) + batch_op.drop_index(batch_op.f("ix_company_headcount")) + + op.drop_table("company") # ### end Alembic commands ### + def data_upgrades() -> None: """Add any optional data upgrade migrations here!""" + def data_downgrades() -> None: """Add any optional data downgrade migrations here!"""