From bb08ba2bf97f4e42e0a8915f970ad278a057eb7f Mon Sep 17 00:00:00 2001 From: dextmorgn Date: Thu, 6 Nov 2025 14:43:04 +0100 Subject: [PATCH] feat(api): migration to add custom_types table --- .../8173aba964e7_add_custom_types_table.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 flowsint-api/alembic/versions/8173aba964e7_add_custom_types_table.py diff --git a/flowsint-api/alembic/versions/8173aba964e7_add_custom_types_table.py b/flowsint-api/alembic/versions/8173aba964e7_add_custom_types_table.py new file mode 100644 index 00000000..85841cce --- /dev/null +++ b/flowsint-api/alembic/versions/8173aba964e7_add_custom_types_table.py @@ -0,0 +1,50 @@ +"""add custom_types table + +Revision ID: 8173aba964e7 +Revises: 8d0e12b68d1e +Create Date: 2025-11-06 11:15:59.143311 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = '8173aba964e7' +down_revision: Union[str, None] = '8d0e12b68d1e' +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! ### + op.create_table('custom_types', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('name', sa.Text(), nullable=False), + sa.Column('owner_id', sa.UUID(), nullable=False), + sa.Column('schema', postgresql.JSONB(astext_type=sa.Text()), nullable=False), + sa.Column('status', sa.String(), server_default='draft', nullable=False), + sa.Column('checksum', sa.String(), nullable=True), + sa.Column('description', sa.Text(), nullable=True), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), + sa.ForeignKeyConstraint(['owner_id'], ['profiles.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('idx_custom_types_name', 'custom_types', ['name'], unique=False) + op.create_index('idx_custom_types_owner_id', 'custom_types', ['owner_id'], unique=False) + op.create_index('idx_custom_types_status', 'custom_types', ['status'], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + """Downgrade schema.""" + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('idx_custom_types_status', table_name='custom_types') + op.drop_index('idx_custom_types_owner_id', table_name='custom_types') + op.drop_index('idx_custom_types_name', table_name='custom_types') + op.drop_table('custom_types') + # ### end Alembic commands ###