порт лабы 4
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "d9e53b20f7c1"
|
||||
down_revision = "c8f42a19e6b0"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.alter_column(
|
||||
"attachments",
|
||||
"uploader_id",
|
||||
new_column_name="owner_id",
|
||||
)
|
||||
|
||||
op.add_column(
|
||||
"attachments",
|
||||
sa.Column(
|
||||
"sha256",
|
||||
sa.String(length=64),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
|
||||
op.add_column(
|
||||
"attachments",
|
||||
sa.Column(
|
||||
"variants",
|
||||
sa.JSON(),
|
||||
nullable=False,
|
||||
server_default=sa.text("'[]'::json"),
|
||||
),
|
||||
)
|
||||
|
||||
op.add_column(
|
||||
"attachments",
|
||||
sa.Column(
|
||||
"error_code",
|
||||
sa.String(length=100),
|
||||
nullable=True,
|
||||
),
|
||||
)
|
||||
|
||||
op.add_column(
|
||||
"attachments",
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("CURRENT_TIMESTAMP"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
|
||||
op.create_check_constraint(
|
||||
"ck_attachments_sha256",
|
||||
"attachments",
|
||||
"sha256 ~ '^[a-f0-9]{64}$'",
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_constraint(
|
||||
"ck_attachments_sha256",
|
||||
"attachments",
|
||||
type_="check",
|
||||
)
|
||||
|
||||
op.drop_column("attachments", "updated_at")
|
||||
op.drop_column("attachments", "error_code")
|
||||
op.drop_column("attachments", "variants")
|
||||
op.drop_column("attachments", "sha256")
|
||||
|
||||
op.alter_column(
|
||||
"attachments",
|
||||
"owner_id",
|
||||
new_column_name="uploader_id",
|
||||
)
|
||||
Reference in New Issue
Block a user