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 migration script #34

Merged
merged 1 commit into from
Sep 24, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lnschema_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"""
# This is lnschema-module yvzi.
_schema_id = "yvzi"
_migration = "049d7dfc80a8"
_migration = "1f29517759b7"
__version__ = "0.7.2" # denote a pre-release for 0.1.0 with 0.1a1

from . import id, type # noqa
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""v0.7.3.

Revision ID: 1f29517759b7
Revises: 049d7dfc80a8
Create Date: 2022-09-24 10:32:37.801549

"""
import sqlalchemy as sa # noqa
import sqlmodel # noqa
from alembic import op

# revision identifiers, used by Alembic.
revision = "1f29517759b7"
down_revision = "049d7dfc80a8"
branch_labels = None
depends_on = None


def upgrade() -> None:
with op.batch_alter_table("dobject", schema=None) as batch_op:
batch_op.alter_column(
"created_at",
existing_type=sa.DATETIME(),
nullable=False,
existing_server_default=sa.text("(CURRENT_TIMESTAMP)"),
)

with op.batch_alter_table("jupynb", schema=None) as batch_op:
batch_op.alter_column(
"created_at",
existing_type=sa.DATETIME(),
nullable=False,
existing_server_default=sa.text("(CURRENT_TIMESTAMP)"),
)

with op.batch_alter_table("pipeline", schema=None) as batch_op:
batch_op.alter_column(
"created_at",
existing_type=sa.DATETIME(),
nullable=False,
existing_server_default=sa.text("(CURRENT_TIMESTAMP)"),
)

with op.batch_alter_table("pipeline_run", schema=None) as batch_op:
batch_op.alter_column(
"created_at",
existing_type=sa.DATETIME(),
nullable=False,
existing_server_default=sa.text("(CURRENT_TIMESTAMP)"),
)

with op.batch_alter_table("storage", schema=None) as batch_op:
batch_op.alter_column(
"created_at",
existing_type=sa.DATETIME(),
nullable=False,
existing_server_default=sa.text("(CURRENT_TIMESTAMP)"),
)

with op.batch_alter_table("user", schema=None) as batch_op:
batch_op.alter_column(
"created_at",
existing_type=sa.DATETIME(),
nullable=False,
existing_server_default=sa.text("(CURRENT_TIMESTAMP)"),
)
batch_op.drop_constraint("user", type_="unique")
batch_op.drop_index("ix_user_email")
batch_op.create_index(batch_op.f("ix_user_email"), ["email"], unique=True)
batch_op.drop_index("ix_user_handle")
batch_op.create_index(batch_op.f("ix_user_handle"), ["handle"], unique=True)

with op.batch_alter_table("version_yvzi", schema=None) as batch_op:
batch_op.alter_column(
"created_at",
existing_type=sa.DATETIME(),
nullable=False,
existing_server_default=sa.text("(CURRENT_TIMESTAMP)"),
)


def downgrade() -> None:
pass
Binary file modified tests/testdb.lndb
Binary file not shown.