"""Add data_lineage table

Revision ID: 012
Revises: 011
Create Date: 2026-04-23 23:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision: str = "012"
down_revision: Union[str, None] = "011"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "data_lineage",
        sa.Column("id", sa.Integer(), primary_key=True, index=True),
        sa.Column("source_table", sa.String(200), nullable=False),
        sa.Column("source_column", sa.String(200), nullable=True),
        sa.Column("target_table", sa.String(200), nullable=False),
        sa.Column("target_column", sa.String(200), nullable=True),
        sa.Column("relation_type", sa.String(20), default="direct"),
        sa.Column("script_content", sa.Text(), nullable=True),
        sa.Column("created_at", sa.DateTime(), default=sa.func.now()),
    )


def downgrade() -> None:
    op.drop_table("data_lineage")
