feat: add governed DSAR workflow
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from importlib.util import module_from_spec, spec_from_file_location
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
_path = (
|
||||
Path(__file__).resolve().parents[1]
|
||||
/ "versions"
|
||||
/ "b47e6f809a13_data_subject_requests.py"
|
||||
)
|
||||
_spec = spec_from_file_location("govoplan_data_subject_requests_migration", _path)
|
||||
if _spec is None or _spec.loader is None:
|
||||
raise RuntimeError(f"Unable to load migration implementation from {_path}")
|
||||
_module = module_from_spec(_spec)
|
||||
_spec.loader.exec_module(_module)
|
||||
|
||||
revision = _module.revision
|
||||
down_revision = _module.down_revision
|
||||
branch_labels = _module.branch_labels
|
||||
depends_on = _module.depends_on
|
||||
upgrade = _module.upgrade
|
||||
downgrade = _module.downgrade
|
||||
@@ -0,0 +1,77 @@
|
||||
"""add governed data-subject request workflow
|
||||
|
||||
Revision ID: b47e6f809a13
|
||||
Revises: a36d8e4f9b12
|
||||
Create Date: 2026-08-07 00:00:00.000000
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "b47e6f809a13"
|
||||
down_revision = "a36d8e4f9b12"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
inspector = sa.inspect(op.get_bind())
|
||||
if "core_data_subject_requests" in inspector.get_table_names():
|
||||
return
|
||||
op.create_table(
|
||||
"core_data_subject_requests",
|
||||
sa.Column("id", sa.String(length=36), nullable=False),
|
||||
sa.Column("tenant_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("reference", sa.String(length=120), nullable=False),
|
||||
sa.Column("request_kind", sa.String(length=30), nullable=False),
|
||||
sa.Column("status", sa.String(length=30), nullable=False),
|
||||
sa.Column("subject", sa.JSON(), nullable=False),
|
||||
sa.Column("purpose", sa.String(length=1000), nullable=False),
|
||||
sa.Column("legal_basis", sa.String(length=1000), nullable=True),
|
||||
sa.Column("due_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("requested_by_account_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("search_result", sa.JSON(), nullable=False),
|
||||
sa.Column("erasure_plan", sa.JSON(), nullable=False),
|
||||
sa.Column("execution_result", sa.JSON(), nullable=False),
|
||||
sa.Column("coverage", sa.JSON(), nullable=False),
|
||||
sa.Column("evidence_sha256", sa.String(length=64), nullable=True),
|
||||
sa.Column("resource_revision", sa.Integer(), nullable=False),
|
||||
sa.Column("completed_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("notes", sa.Text(), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_core_data_subject_requests")),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_core_data_subject_requests_tenant_id"),
|
||||
"core_data_subject_requests",
|
||||
["tenant_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_core_data_subject_requests_status"),
|
||||
"core_data_subject_requests",
|
||||
["status"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_core_data_subject_requests_due_at"),
|
||||
"core_data_subject_requests",
|
||||
["due_at"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
"ix_core_data_subject_requests_tenant_status",
|
||||
"core_data_subject_requests",
|
||||
["tenant_id", "status"],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
inspector = sa.inspect(op.get_bind())
|
||||
if "core_data_subject_requests" in inspector.get_table_names():
|
||||
op.drop_table("core_data_subject_requests")
|
||||
Reference in New Issue
Block a user