Files
docupulse/migrations/versions/c94c2b2b9f2e_add_version_tracking_fields_to_instances.py
2025-06-23 09:30:04 +02:00

69 lines
3.3 KiB
Python

"""add version tracking fields to instances
Revision ID: c94c2b2b9f2e
Revises: a1fd98e6630d
Create Date: 2025-06-23 09:15:13.092801
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'c94c2b2b9f2e'
down_revision = 'a1fd98e6630d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('email_template')
op.drop_table('notification')
with op.batch_alter_table('instances', schema=None) as batch_op:
batch_op.add_column(sa.Column('deployed_version', sa.String(length=50), nullable=True))
batch_op.add_column(sa.Column('deployed_branch', sa.String(length=100), nullable=True))
batch_op.add_column(sa.Column('latest_version', sa.String(length=50), nullable=True))
batch_op.add_column(sa.Column('version_checked_at', sa.DateTime(), nullable=True))
with op.batch_alter_table('room_file', schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f('fk_room_file_deleted_by_user'), type_='foreignkey')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('room_file', schema=None) as batch_op:
batch_op.create_foreign_key(batch_op.f('fk_room_file_deleted_by_user'), 'user', ['deleted_by'], ['id'])
with op.batch_alter_table('instances', schema=None) as batch_op:
batch_op.drop_column('version_checked_at')
batch_op.drop_column('latest_version')
batch_op.drop_column('deployed_branch')
batch_op.drop_column('deployed_version')
op.create_table('notification',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('title', sa.VARCHAR(length=200), autoincrement=False, nullable=False),
sa.Column('message', sa.TEXT(), autoincrement=False, nullable=False),
sa.Column('type', sa.VARCHAR(length=50), autoincrement=False, nullable=False),
sa.Column('read', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('notification_user_id_fkey')),
sa.PrimaryKeyConstraint('id', name=op.f('notification_pkey'))
)
op.create_table('email_template',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
sa.Column('subject', sa.VARCHAR(length=200), autoincrement=False, nullable=False),
sa.Column('body', sa.TEXT(), autoincrement=False, nullable=False),
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('email_template_pkey')),
sa.UniqueConstraint('name', name=op.f('email_template_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
)
# ### end Alembic commands ###