-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 2-import-koodistot
- Loading branch information
Showing
5 changed files
with
236 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
database/migrations/versions/2024_02_05_1807-c882368ce708_add_plan_regulation_group_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""add_plan_regulation_group_table | ||
Revision ID: c882368ce708 | ||
Revises: 84c37bffeca0 | ||
Create Date: 2024-02-05 18:07:16.739686 | ||
""" | ||
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 = "c882368ce708" | ||
down_revision: Union[str, None] = "84c37bffeca0" | ||
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.create_table( | ||
"plan_regulation_group", | ||
sa.Column("short_name", sa.String(), nullable=False), | ||
sa.Column( | ||
"name", | ||
postgresql.JSONB(astext_type=sa.Text()), | ||
server_default='{"fin": "", "swe": "", "eng": ""}', | ||
nullable=False, | ||
), | ||
sa.Column( | ||
"id", sa.UUID(), server_default=sa.text("gen_random_uuid()"), nullable=False | ||
), | ||
sa.Column( | ||
"created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False | ||
), | ||
sa.Column( | ||
"modified_at", | ||
sa.DateTime(), | ||
server_default=sa.text("now()"), | ||
nullable=False, | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
schema="hame", | ||
) | ||
op.create_index( | ||
op.f("ix_hame_plan_regulation_group_short_name"), | ||
"plan_regulation_group", | ||
["short_name"], | ||
unique=True, | ||
schema="hame", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index( | ||
op.f("ix_hame_plan_regulation_group_short_name"), | ||
table_name="plan_regulation_group", | ||
schema="hame", | ||
) | ||
op.drop_table("plan_regulation_group", schema="hame") | ||
# ### end Alembic commands ### |
73 changes: 73 additions & 0 deletions
73
...base/migrations/versions/2024_02_08_1423-811b23178cef_edit_plan_regulation_group_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ### |
84 changes: 84 additions & 0 deletions
84
...migrations/versions/2024_02_08_1613-6ee06a6e634a_edit_plan_regulation_group_base_class.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters