71 lines
3.2 KiB
Python
71 lines
3.2 KiB
Python
|
"""empty message
|
||
|
|
||
|
Revision ID: 6344d90d20fa
|
||
|
Revises: 60c13a48d675
|
||
|
Create Date: 2024-02-02 08:33:49.669497
|
||
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = '6344d90d20fa'
|
||
|
down_revision = '60c13a48d675'
|
||
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.create_table('kkv_data_store',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('name', sa.String(length=255), nullable=False),
|
||
|
sa.Column('identifier', sa.String(length=255), nullable=False),
|
||
|
sa.Column('location', sa.String(length=255), nullable=False),
|
||
|
sa.Column('schema', sa.JSON(), nullable=False),
|
||
|
sa.Column('description', sa.String(length=255), nullable=True),
|
||
|
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=False),
|
||
|
sa.Column('created_at_in_seconds', sa.Integer(), nullable=False),
|
||
|
sa.PrimaryKeyConstraint('id'),
|
||
|
sa.UniqueConstraint('identifier', 'location', name='_kkv_identifier_location_unique')
|
||
|
)
|
||
|
with op.batch_alter_table('kkv_data_store', schema=None) as batch_op:
|
||
|
batch_op.create_index(batch_op.f('ix_kkv_data_store_identifier'), ['identifier'], unique=False)
|
||
|
batch_op.create_index(batch_op.f('ix_kkv_data_store_name'), ['name'], unique=False)
|
||
|
|
||
|
op.create_table('kkv_data_store_entry',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('kkv_data_store_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('top_level_key', sa.String(length=255), nullable=False),
|
||
|
sa.Column('secondary_key', sa.String(length=255), nullable=False),
|
||
|
sa.Column('value', sa.JSON(), nullable=False),
|
||
|
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=False),
|
||
|
sa.Column('created_at_in_seconds', sa.Integer(), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['kkv_data_store_id'], ['kkv_data_store.id'], ),
|
||
|
sa.PrimaryKeyConstraint('id'),
|
||
|
sa.UniqueConstraint('kkv_data_store_id', 'top_level_key', 'secondary_key', name='_instance_keys_unique')
|
||
|
)
|
||
|
with op.batch_alter_table('kkv_data_store_entry', schema=None) as batch_op:
|
||
|
batch_op.create_index(batch_op.f('ix_kkv_data_store_entry_kkv_data_store_id'), ['kkv_data_store_id'], unique=False)
|
||
|
batch_op.create_index(batch_op.f('ix_kkv_data_store_entry_secondary_key'), ['secondary_key'], unique=False)
|
||
|
batch_op.create_index(batch_op.f('ix_kkv_data_store_entry_top_level_key'), ['top_level_key'], unique=False)
|
||
|
|
||
|
# ### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
with op.batch_alter_table('kkv_data_store_entry', schema=None) as batch_op:
|
||
|
batch_op.drop_index(batch_op.f('ix_kkv_data_store_entry_top_level_key'))
|
||
|
batch_op.drop_index(batch_op.f('ix_kkv_data_store_entry_secondary_key'))
|
||
|
batch_op.drop_index(batch_op.f('ix_kkv_data_store_entry_kkv_data_store_id'))
|
||
|
|
||
|
op.drop_table('kkv_data_store_entry')
|
||
|
with op.batch_alter_table('kkv_data_store', schema=None) as batch_op:
|
||
|
batch_op.drop_index(batch_op.f('ix_kkv_data_store_name'))
|
||
|
batch_op.drop_index(batch_op.f('ix_kkv_data_store_identifier'))
|
||
|
|
||
|
op.drop_table('kkv_data_store')
|
||
|
# ### end Alembic commands ###
|