|
| 1 | +"""change schema |
| 2 | +
|
| 3 | +Revision ID: 150ac8a20e59 |
| 4 | +Revises: 7334713b30a6 |
| 5 | +Create Date: 2025-07-29 12:44:15.804586 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +from alembic import op |
| 10 | +import sqlalchemy as sa |
| 11 | +from sqlalchemy.dialects import postgresql |
| 12 | + |
| 13 | +# revision identifiers, used by Alembic. |
| 14 | +revision = "150ac8a20e59" |
| 15 | +down_revision = "7334713b30a6" |
| 16 | +branch_labels = None |
| 17 | +depends_on = None |
| 18 | + |
| 19 | + |
| 20 | +def upgrade(): |
| 21 | + # ### commands auto generated by Alembic - please adjust! ### |
| 22 | + op.create_table( |
| 23 | + "sharepoint_property_sync", |
| 24 | + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), |
| 25 | + sa.Column("created_by", postgresql.UUID(as_uuid=True), nullable=True), |
| 26 | + sa.Column("created_at", sa.DateTime(), nullable=True), |
| 27 | + sa.Column("updated_at", sa.DateTime(), nullable=True), |
| 28 | + sa.Column("integration_id", postgresql.UUID(as_uuid=True), nullable=True), |
| 29 | + sa.Column("config", sa.JSON(), nullable=True), |
| 30 | + sa.Column("logs", sa.ARRAY(sa.String()), nullable=True), |
| 31 | + sa.Column("state", sa.String(), nullable=True), |
| 32 | + sa.ForeignKeyConstraint(["created_by"], ["user.id"], ondelete="SET NULL"), |
| 33 | + sa.ForeignKeyConstraint( |
| 34 | + ["integration_id"], ["cognition.integration.id"], ondelete="CASCADE" |
| 35 | + ), |
| 36 | + sa.PrimaryKeyConstraint("id"), |
| 37 | + schema="integration", |
| 38 | + ) |
| 39 | + op.create_index( |
| 40 | + op.f("ix_integration_sharepoint_property_sync_created_by"), |
| 41 | + "sharepoint_property_sync", |
| 42 | + ["created_by"], |
| 43 | + unique=False, |
| 44 | + schema="integration", |
| 45 | + ) |
| 46 | + op.create_index( |
| 47 | + op.f("ix_integration_sharepoint_property_sync_integration_id"), |
| 48 | + "sharepoint_property_sync", |
| 49 | + ["integration_id"], |
| 50 | + unique=False, |
| 51 | + schema="integration", |
| 52 | + ) |
| 53 | + op.drop_index( |
| 54 | + "ix_sharepoint_property_sync_created_by", table_name="sharepoint_property_sync" |
| 55 | + ) |
| 56 | + op.drop_index( |
| 57 | + "ix_sharepoint_property_sync_integration_id", |
| 58 | + table_name="sharepoint_property_sync", |
| 59 | + ) |
| 60 | + op.drop_table("sharepoint_property_sync") |
| 61 | + # ### end Alembic commands ### |
| 62 | + |
| 63 | + |
| 64 | +def downgrade(): |
| 65 | + # ### commands auto generated by Alembic - please adjust! ### |
| 66 | + op.create_table( |
| 67 | + "sharepoint_property_sync", |
| 68 | + sa.Column("id", postgresql.UUID(), autoincrement=False, nullable=False), |
| 69 | + sa.Column("created_by", postgresql.UUID(), autoincrement=False, nullable=True), |
| 70 | + sa.Column( |
| 71 | + "created_at", postgresql.TIMESTAMP(), autoincrement=False, nullable=True |
| 72 | + ), |
| 73 | + sa.Column( |
| 74 | + "updated_at", postgresql.TIMESTAMP(), autoincrement=False, nullable=True |
| 75 | + ), |
| 76 | + sa.Column( |
| 77 | + "integration_id", postgresql.UUID(), autoincrement=False, nullable=True |
| 78 | + ), |
| 79 | + sa.Column( |
| 80 | + "config", |
| 81 | + postgresql.JSON(astext_type=sa.Text()), |
| 82 | + autoincrement=False, |
| 83 | + nullable=True, |
| 84 | + ), |
| 85 | + sa.Column( |
| 86 | + "logs", postgresql.ARRAY(sa.VARCHAR()), autoincrement=False, nullable=True |
| 87 | + ), |
| 88 | + sa.Column("state", sa.VARCHAR(), autoincrement=False, nullable=True), |
| 89 | + sa.ForeignKeyConstraint( |
| 90 | + ["created_by"], |
| 91 | + ["user.id"], |
| 92 | + name="sharepoint_property_sync_created_by_fkey", |
| 93 | + ondelete="SET NULL", |
| 94 | + ), |
| 95 | + sa.ForeignKeyConstraint( |
| 96 | + ["integration_id"], |
| 97 | + ["cognition.integration.id"], |
| 98 | + name="sharepoint_property_sync_integration_id_fkey", |
| 99 | + ondelete="CASCADE", |
| 100 | + ), |
| 101 | + sa.PrimaryKeyConstraint("id", name="sharepoint_property_sync_pkey"), |
| 102 | + ) |
| 103 | + op.create_index( |
| 104 | + "ix_sharepoint_property_sync_integration_id", |
| 105 | + "sharepoint_property_sync", |
| 106 | + ["integration_id"], |
| 107 | + unique=False, |
| 108 | + ) |
| 109 | + op.create_index( |
| 110 | + "ix_sharepoint_property_sync_created_by", |
| 111 | + "sharepoint_property_sync", |
| 112 | + ["created_by"], |
| 113 | + unique=False, |
| 114 | + ) |
| 115 | + op.drop_index( |
| 116 | + op.f("ix_integration_sharepoint_property_sync_integration_id"), |
| 117 | + table_name="sharepoint_property_sync", |
| 118 | + schema="integration", |
| 119 | + ) |
| 120 | + op.drop_index( |
| 121 | + op.f("ix_integration_sharepoint_property_sync_created_by"), |
| 122 | + table_name="sharepoint_property_sync", |
| 123 | + schema="integration", |
| 124 | + ) |
| 125 | + op.drop_table("sharepoint_property_sync", schema="integration") |
| 126 | + # ### end Alembic commands ### |
0 commit comments