main
py 68 lines 3.29 KB
Raw
1 """Add notification tablesv2
2
3 Revision ID: 260371af0a48
4 Revises: 458e2a7b6b11
5 Create Date: 2026-04-29 11:17:25.975308
6
7 """
8 from typing import Sequence
9 from typing import Union
10
11 import sqlalchemy as sa
12
13 from alembic import op
14
15 # revision identifiers, used by Alembic.
16 revision: str = "260371af0a48"
17 down_revision: Union[str, None] = "458e2a7b6b11"
18 branch_labels: Union[str, Sequence[str], None] = None
19 depends_on: Union[str, Sequence[str], None] = None
20
21
22 def upgrade() -> None:
23 # ### commands auto generated by Alembic - please adjust! ###
24 op.create_table(
25 "customer_shuffle_integration",
26 sa.Column("id", sa.Integer(), nullable=False),
27 sa.Column("customer_code", sa.String(length=64), nullable=False),
28 sa.Column("shuffle_org_id", sa.String(length=64), nullable=False),
29 sa.Column("display_name", sa.String(length=128), nullable=False),
30 sa.Column("enabled", sa.Boolean(), nullable=False),
31 sa.Column("last_used_at", sa.DateTime(), nullable=True),
32 sa.Column("created_by", sa.String(length=128), nullable=True),
33 sa.Column("created_at", sa.DateTime(), nullable=False),
34 sa.Column("updated_at", sa.DateTime(), nullable=True),
35 sa.ForeignKeyConstraint(
36 ["customer_code"],
37 ["customers.customer_code"],
38 ),
39 sa.PrimaryKeyConstraint("id"),
40 )
41 op.create_index(op.f("ix_customer_shuffle_integration_created_at"), "customer_shuffle_integration", ["created_at"], unique=False)
42 op.create_index(op.f("ix_customer_shuffle_integration_customer_code"), "customer_shuffle_integration", ["customer_code"], unique=False)
43 op.add_column("customer_notification_route", sa.Column("shuffle_integration_id", sa.Integer(), nullable=True))
44 op.add_column("customer_notification_route", sa.Column("shuffle_app_id", sa.String(length=64), nullable=True))
45 op.add_column("customer_notification_route", sa.Column("shuffle_app_name", sa.String(length=128), nullable=True))
46 op.create_index(
47 op.f("ix_customer_notification_route_shuffle_integration_id"),
48 "customer_notification_route",
49 ["shuffle_integration_id"],
50 unique=False,
51 )
52 op.create_foreign_key(None, "customer_notification_route", "customer_shuffle_integration", ["shuffle_integration_id"], ["id"])
53 op.add_column("notification_dispatch_log", sa.Column("shuffle_execution_id", sa.String(length=128), nullable=True))
54 # ### end Alembic commands ###
55
56
57 def downgrade() -> None:
58 # ### commands auto generated by Alembic - please adjust! ###
59 op.drop_column("notification_dispatch_log", "shuffle_execution_id")
60 op.drop_constraint(None, "customer_notification_route", type_="foreignkey")
61 op.drop_index(op.f("ix_customer_notification_route_shuffle_integration_id"), table_name="customer_notification_route")
62 op.drop_column("customer_notification_route", "shuffle_app_name")
63 op.drop_column("customer_notification_route", "shuffle_app_id")
64 op.drop_column("customer_notification_route", "shuffle_integration_id")
65 op.drop_index(op.f("ix_customer_shuffle_integration_customer_code"), table_name="customer_shuffle_integration")
66 op.drop_index(op.f("ix_customer_shuffle_integration_created_at"), table_name="customer_shuffle_integration")
67 op.drop_table("customer_shuffle_integration")
68 # ### end Alembic commands ###