Coverage for datakiln/metadata/migrations/versions/v0001_baseline.py: 0%
11 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-16 23:23 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-16 23:23 +0000
1"""Tables and artifacts, keyed by schema and table
3The metadata of the databases built before there were migrations.
5Revision ID: 0001
6Revises:
7"""
8# pylint: disable=no-member, invalid-name, duplicate-code
9from alembic import op
10import sqlalchemy as sa
13revision = "0001"
14down_revision = None
16SCHEMA = "__metadata"
19def upgrade():
20 """Create the tables of the first version."""
21 op.create_table(
22 "table_",
23 sa.Column("schema_", sa.String(), nullable=False),
24 sa.Column("table_", sa.String(), nullable=False),
25 sa.Column("checksum_", sa.String(), nullable=False),
26 sa.PrimaryKeyConstraint("schema_", "table_"),
27 schema=SCHEMA,
28 )
29 op.create_table(
30 "artifact_",
31 sa.Column("path_", sa.String(), nullable=False),
32 sa.Column("schema_", sa.String(), nullable=False),
33 sa.Column("table_", sa.String(), nullable=False),
34 sa.Column("checksum_", sa.String(), nullable=False),
35 sa.PrimaryKeyConstraint("path_"),
36 sa.ForeignKeyConstraint(
37 ["table_", "schema_"],
38 [f"{SCHEMA}.table_.table_", f"{SCHEMA}.table_.schema_"],
39 ),
40 schema=SCHEMA,
41 )
44def downgrade():
45 """Drop the tables of the first version."""
46 op.drop_table("artifact_", schema=SCHEMA)
47 op.drop_table("table_", schema=SCHEMA)