Skip to content

Commit

Permalink
Fix location and funding type
Browse files Browse the repository at this point in the history
  • Loading branch information
shri committed Aug 11, 2024
1 parent bd138f9 commit ae8b8c3
Showing 1 changed file with 73 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -43,96 +44,99 @@ def upgrade() -> None:
schema_upgrades()
data_upgrades()


def downgrade() -> None:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
with op.get_context().autocommit_block():
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!"""

0 comments on commit ae8b8c3

Please sign in to comment.