-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft migration to add TemplateCategories table
- Initial work on the models
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 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
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,55 @@ | ||
""" | ||
Revision ID: 0454_add_template_category | ||
Revises: 0453_add_callback_failure_email | ||
Create Date: 2024-06-11 13:32:00 | ||
""" | ||
|
||
from datetime import datetime | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"template_categories", | ||
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), | ||
sa.Column("name_en", sa.String(length=255), nullable=False), | ||
sa.Column("name_fr", sa.String(length=255), nullable=False), | ||
sa.Column("description_en", sa.String(length=255), nullable=True), | ||
sa.Column("description_fr", sa.String(length=255), nullable=True), | ||
sa.Column("sms_process_type", sa.String(length=255), nullable=False), | ||
sa.Column("email_process_type", sa.String(length=255), nullable=False), | ||
sa.Column("hidden", sa.Boolean(), nullable=False), | ||
) | ||
|
||
op.add_column( | ||
"templates", | ||
sa.Colum("template_category_id", postgresql.UUID(as_uuid=True), nullable=True) | ||
) | ||
op.create_index( | ||
op.f("ix_template_category_id", "templates", ["template_category_id"], unique=False) | ||
) | ||
op.create_foreign_key( | ||
"fk_template_template_categories", | ||
"template", | ||
"template_category", | ||
["template_category_id"], | ||
["id"] | ||
) | ||
op.get_bind() | ||
|
||
# Insert the generic Low priority (bulk) category | ||
# op.execute(""" | ||
# INSERT INTO template_category (id, name_en, name_fr, sms_process_type, email_process_type, hidden) | ||
# VALUES ('00000000-0000-0000-0000-000000000000', 'Low Category (Bulk)', 'Catégorie Basse (En Vrac)', true | ||
# """ | ||
# ) | ||
|
||
def downgrade(): | ||
op.drop_constraint("fk_template_template_category", "templates", type_="foreignkey") | ||
op.drop_index(op.f("ix_template_category_id"), table_name="templates") | ||
op.drop_column("templates", "template_category_id") | ||
op.drop_table("template_category_id") |