Add Postbox message authoring and concurrency
This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
"""v0.1.2 message authoring and optimistic concurrency
|
||||
|
||||
Revision ID: f5c8d0e3b7a2
|
||||
Revises: e4b7c9d2a6f1
|
||||
Create Date: 2026-07-31 16:30:00.000000
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "f5c8d0e3b7a2"
|
||||
down_revision = "e4b7c9d2a6f1"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
for table_name in (
|
||||
"postbox_templates",
|
||||
"postboxes",
|
||||
"postbox_groupings",
|
||||
):
|
||||
with op.batch_alter_table(table_name) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column(
|
||||
"resource_revision",
|
||||
sa.Integer(),
|
||||
nullable=False,
|
||||
server_default=sa.text("1"),
|
||||
)
|
||||
)
|
||||
|
||||
with op.batch_alter_table("postbox_messages") as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column("authoring_key", sa.String(length=255), nullable=True)
|
||||
)
|
||||
batch_op.create_index(
|
||||
"ix_postbox_messages_authoring_key",
|
||||
("authoring_key",),
|
||||
unique=False,
|
||||
)
|
||||
batch_op.create_unique_constraint(
|
||||
"uq_postbox_messages_authoring_key",
|
||||
("tenant_id", "postbox_id", "authoring_key"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
with op.batch_alter_table("postbox_messages") as batch_op:
|
||||
batch_op.drop_constraint(
|
||||
"uq_postbox_messages_authoring_key",
|
||||
type_="unique",
|
||||
)
|
||||
batch_op.drop_index("ix_postbox_messages_authoring_key")
|
||||
batch_op.drop_column("authoring_key")
|
||||
|
||||
for table_name in (
|
||||
"postbox_groupings",
|
||||
"postboxes",
|
||||
"postbox_templates",
|
||||
):
|
||||
with op.batch_alter_table(table_name) as batch_op:
|
||||
batch_op.drop_column("resource_revision")
|
||||
Reference in New Issue
Block a user