1
0
Fork 0
mirror of https://github.com/EDeev/tablo.git synced 2026-10-07 20:49:31 +03:00
tablo/migrations/versions/aa6f28d23573_merge_progress_into_metric.py
2026-05-19 13:49:09 +03:00

40 lines
1.4 KiB
Python

"""merge progress into metric
Revision ID: aa6f28d23573
Revises: a9875eef468a
Create Date: 2026-05-03 11:13:14.874531
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'aa6f28d23573'
down_revision = 'a9875eef468a'
branch_labels = None
depends_on = None
def upgrade():
op.drop_table('metric_progress')
with op.batch_alter_table('metrics', schema=None) as batch_op:
batch_op.add_column(sa.Column('progress', sa.JSON(), nullable=False, server_default='{}'))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('metrics', schema=None) as batch_op:
batch_op.drop_column('progress')
op.create_table('metric_progress',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('metric_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False),
sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['metric_id'], ['metrics.id'], name='metric_progress_metric_id_fkey'),
sa.PrimaryKeyConstraint('id', name='metric_progress_pkey')
)
# ### end Alembic commands ###