Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add audit info migration #104

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions ixmp4/db/migrations/versions/c29289ced488_add_audit_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# type: ignore
"""add audit info

Revision ID: c29289ced488
Revises: 081bbda6bb7b
Create Date: 2024-07-31 11:13:39.889253

"""

import sqlalchemy as sa
from alembic import op

# Revision identifiers, used by Alembic.
revision = "c29289ced488"
down_revision = "081bbda6bb7b"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("optimization_column", schema=None) as batch_op:
batch_op.add_column(sa.Column("created_at", sa.DateTime(), nullable=True))
batch_op.add_column(
sa.Column("created_by", sa.String(length=255), nullable=True)
)

with op.batch_alter_table("region", schema=None) as batch_op:
batch_op.alter_column(
"name",
existing_type=sa.VARCHAR(length=1023),
type_=sa.String(length=255),
existing_nullable=False,
)

with op.batch_alter_table("run", schema=None) as batch_op:
batch_op.add_column(sa.Column("updated_at", sa.DateTime(), nullable=True))
batch_op.add_column(
sa.Column("updated_by", sa.String(length=255), nullable=True)
)
batch_op.add_column(sa.Column("created_at", sa.DateTime(), nullable=True))
batch_op.add_column(
sa.Column("created_by", sa.String(length=255), nullable=True)
)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("run", schema=None) as batch_op:
batch_op.drop_column("created_by")
batch_op.drop_column("created_at")
batch_op.drop_column("updated_by")
batch_op.drop_column("updated_at")

with op.batch_alter_table("region", schema=None) as batch_op:
batch_op.alter_column(
"name",
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=1023),
existing_nullable=False,
)

with op.batch_alter_table("optimization_column", schema=None) as batch_op:
batch_op.drop_column("created_by")
batch_op.drop_column("created_at")

# ### end Alembic commands ###
Loading