generated from dopt-python/py311
Dev #7
@@ -0,0 +1,33 @@
|
|||||||
|
"""add unique constraint for company person linking table
|
||||||
|
|
||||||
|
Revision ID: 03d4f000f445
|
||||||
|
Revises: 85577ce9f2ab
|
||||||
|
Create Date: 2026-07-22 09:17:46.576581
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "03d4f000f445"
|
||||||
|
down_revision: Union[str, Sequence[str], None] = "85577ce9f2ab"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table("zuordnung_personen_unternehmen") as batch_op:
|
||||||
|
batch_op.create_unique_constraint("uq_un_id_pers_id", ["un_id", "pers_id"])
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table("zuordnung_personen_unternehmen") as batch_op:
|
||||||
|
batch_op.drop_constraint("uq_un_id_pers_id")
|
||||||
|
# ### end Alembic commands ###
|
||||||
+2
-1
@@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
import polars as pl
|
import polars as pl
|
||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
from sqlalchemy import Column, String, Table, TypeDecorator, event
|
from sqlalchemy import Column, String, Table, TypeDecorator, UniqueConstraint, event
|
||||||
|
|
||||||
from wce_crm import constants
|
from wce_crm import constants
|
||||||
from wce_crm import types as t
|
from wce_crm import types as t
|
||||||
@@ -420,6 +420,7 @@ zuordnung_personen_unternehmen: sql.Table = Table(
|
|||||||
UTCDateTime,
|
UTCDateTime,
|
||||||
nullable=True,
|
nullable=True,
|
||||||
),
|
),
|
||||||
|
UniqueConstraint("un_id", "pers_id", name="uq_un_id_pers_id"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user