Skip to content

Commit

Permalink
Change inherited base class
Browse files Browse the repository at this point in the history
  • Loading branch information
mipeso committed Feb 8, 2024
1 parent c6c445f commit e846984
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""Edit plan regulation group table
Revision ID: 811b23178cef
Revises: c882368ce708
Create Date: 2024-02-08 14:23:00.747678
"""
from typing import Sequence, Union

# import geoalchemy2
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "811b23178cef"
down_revision: Union[str, None] = "c882368ce708"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"plan_regulation_group",
sa.Column("exported_at", sa.DateTime(), nullable=True),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column("valid_from", sa.DateTime(), nullable=True),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column("valid_to", sa.DateTime(), nullable=True),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column("repealed_at", sa.DateTime(), nullable=True),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column("lifecycle_status_id", sa.UUID(), nullable=False),
schema="hame",
)
op.create_foreign_key(
"plan_lifecycle_status_id_fkey",
"plan_regulation_group",
"lifecycle_status",
["lifecycle_status_id"],
["id"],
source_schema="hame",
referent_schema="codes",
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"plan_lifecycle_status_id_fkey",
"plan_regulation_group",
schema="hame",
type_="foreignkey",
)
op.drop_column("plan_regulation_group", "lifecycle_status_id", schema="hame")
op.drop_column("plan_regulation_group", "repealed_at", schema="hame")
op.drop_column("plan_regulation_group", "valid_to", schema="hame")
op.drop_column("plan_regulation_group", "valid_from", schema="hame")
op.drop_column("plan_regulation_group", "exported_at", schema="hame")
# ### end Alembic commands ###
6 changes: 2 additions & 4 deletions database/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
from typing import Optional

from base import PlanBase, VersionedBase, language_str, unique_str
from base import PlanBase, language_str, unique_str
from shapely.geometry import Polygon
from sqlalchemy.orm import Mapped

Expand All @@ -18,7 +18,7 @@ class Plan(PlanBase):
geom: Mapped[Polygon]


class PlanRegulationGroup(VersionedBase):
class PlanRegulationGroup(PlanBase):
"""
Kaavamääräysryhmä
"""
Expand All @@ -27,5 +27,3 @@ class PlanRegulationGroup(VersionedBase):

short_name: Mapped[unique_str]
name: Mapped[language_str]

__table_args__ = {"schema": "hame"}

0 comments on commit e846984

Please sign in to comment.