Add migration for Migration
This commit is contained in:
parent
5b6bfbfb9c
commit
27afa101b1
@ -0,0 +1,36 @@
|
|||||||
|
"""create migrations table
|
||||||
|
Revision ID: a2b3c4d5e6f7
|
||||||
|
Revises:
|
||||||
|
Create Date: 2023-01-01 12:00:00.000000
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
# revision identifiers
|
||||||
|
revision = 'a2b3c4d5e6f7'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'migrations',
|
||||||
|
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
|
||||||
|
sa.Column('version', sa.String(), nullable=False),
|
||||||
|
sa.Column('description', sa.String(), nullable=True),
|
||||||
|
sa.Column('applied', sa.Boolean(), default=False),
|
||||||
|
sa.Column('script_path', sa.String(), nullable=False),
|
||||||
|
sa.Column('checksum', sa.String(), nullable=True),
|
||||||
|
sa.Column('execution_time', sa.DateTime(), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index('ix_migrations_version', 'migrations', ['version'])
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index('ix_migrations_version', 'migrations')
|
||||||
|
op.drop_table('migrations')
|
Loading…
x
Reference in New Issue
Block a user