Skip to content

Commit

Permalink
Change plan regulation group base class to VersionedBase
Browse files Browse the repository at this point in the history
  • Loading branch information
mipeso committed Feb 8, 2024
1 parent e846984 commit c5f660e
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
2 changes: 1 addition & 1 deletion database/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class VersionedBase(Base):
"""

__abstract__ = True
__table_args__ = {"schema": "hame"}

id: Mapped[uuid_pk]
created_at: Mapped[timestamp]
Expand Down Expand Up @@ -105,7 +106,6 @@ class PlanBase(VersionedBase):
"""

__abstract__ = True
__table_args__ = {"schema": "hame"}

exported_at: Mapped[Optional[datetime]]
valid_from: Mapped[Optional[datetime]]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""edit_plan_regulation_group_base_class
Revision ID: 6ee06a6e634a
Revises: 811b23178cef
Create Date: 2024-02-08 16:13:11.875724
"""
from typing import Sequence, Union

# import geoalchemy2
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "6ee06a6e634a"
down_revision: Union[str, None] = "811b23178cef"
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.drop_constraint(
"plan_lifecycle_status_id_fkey",
"plan_regulation_group",
schema="hame",
type_="foreignkey",
)
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")
op.drop_column("plan_regulation_group", "lifecycle_status_id", schema="hame")
op.drop_column("plan_regulation_group", "repealed_at", schema="hame")
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"plan_regulation_group",
sa.Column(
"repealed_at", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column(
"lifecycle_status_id", sa.UUID(), autoincrement=False, nullable=False
),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column(
"exported_at", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column(
"valid_from", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
),
schema="hame",
)
op.add_column(
"plan_regulation_group",
sa.Column(
"valid_to", postgresql.TIMESTAMP(), autoincrement=False, nullable=True
),
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 ###
4 changes: 2 additions & 2 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, language_str, unique_str
from base import PlanBase, VersionedBase, 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(PlanBase):
class PlanRegulationGroup(VersionedBase):
"""
Kaavamääräysryhmä
"""
Expand Down

0 comments on commit c5f660e

Please sign in to comment.