feat: add governed ownership workflows and admin tree navigation
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""development-track wrapper for generic ownership transfers."""
|
||||
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"
|
||||
/ "d03a7b9c1e5f_core_ownership_transfers.py"
|
||||
)
|
||||
_spec = spec_from_file_location("govoplan_core_ownership_transfer_migration", _path)
|
||||
if _spec is None or _spec.loader is None:
|
||||
raise RuntimeError(f"Unable to load ownership migration from {_path}")
|
||||
_migration = module_from_spec(_spec)
|
||||
_spec.loader.exec_module(_migration)
|
||||
|
||||
revision = _migration.revision
|
||||
down_revision = _migration.down_revision
|
||||
branch_labels = _migration.branch_labels
|
||||
depends_on = _migration.depends_on
|
||||
upgrade = _migration.upgrade
|
||||
downgrade = _migration.downgrade
|
||||
@@ -12,6 +12,7 @@ except ModuleNotFoundError as exc:
|
||||
raise
|
||||
from govoplan_core.admin import models as core_admin_models # noqa: F401 - populate core admin metadata
|
||||
from govoplan_core.core import change_sequence as core_change_sequence_models # noqa: F401 - populate core metadata
|
||||
from govoplan_core.core import ownership as core_ownership_models # noqa: F401 - populate core metadata
|
||||
from govoplan_core.security import credential_envelopes as core_credential_models # noqa: F401 - populate core metadata
|
||||
from govoplan_core.core.migrations import migration_metadata_plan
|
||||
from govoplan_core.db.base import Base
|
||||
|
||||
129
alembic/versions/d03a7b9c1e5f_core_ownership_transfers.py
Normal file
129
alembic/versions/d03a7b9c1e5f_core_ownership_transfers.py
Normal file
@@ -0,0 +1,129 @@
|
||||
"""add generic resource ownership transfer state
|
||||
|
||||
Revision ID: d03a7b9c1e5f
|
||||
Revises: c91f0a72be34
|
||||
Create Date: 2026-07-30 00:00:00.000000
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "d03a7b9c1e5f"
|
||||
down_revision = "c91f0a72be34"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
inspector = sa.inspect(op.get_bind())
|
||||
if "core_ownership_transfers" in inspector.get_table_names():
|
||||
return
|
||||
op.create_table(
|
||||
"core_ownership_transfers",
|
||||
sa.Column("id", sa.String(length=36), nullable=False),
|
||||
sa.Column("tenant_id", sa.String(length=36), nullable=False),
|
||||
sa.Column("resource_module", sa.String(length=100), nullable=False),
|
||||
sa.Column("resource_type", sa.String(length=100), nullable=False),
|
||||
sa.Column("resource_id", sa.String(length=255), nullable=False),
|
||||
sa.Column("kind", sa.String(length=40), nullable=False),
|
||||
sa.Column("status", sa.String(length=50), nullable=False),
|
||||
sa.Column("current_owner_type", sa.String(length=40), nullable=False),
|
||||
sa.Column("current_owner_id", sa.String(length=255), nullable=False),
|
||||
sa.Column("target_owner_type", sa.String(length=40), nullable=False),
|
||||
sa.Column("target_owner_id", sa.String(length=255), nullable=False),
|
||||
sa.Column("initiated_by_type", sa.String(length=40), nullable=False),
|
||||
sa.Column("initiated_by_id", sa.String(length=255), nullable=False),
|
||||
sa.Column("owner_approved_by_type", sa.String(length=40), nullable=True),
|
||||
sa.Column("owner_approved_by_id", sa.String(length=255), nullable=True),
|
||||
sa.Column("target_accepted_by_type", sa.String(length=40), nullable=True),
|
||||
sa.Column("target_accepted_by_id", sa.String(length=255), nullable=True),
|
||||
sa.Column("reason", sa.Text(), nullable=True),
|
||||
sa.Column("assurance_profile", sa.String(length=80), nullable=True),
|
||||
sa.Column("required_approvals", sa.Integer(), nullable=False),
|
||||
sa.Column("approvals", sa.JSON(), nullable=False),
|
||||
sa.Column("decisions", sa.JSON(), nullable=False),
|
||||
sa.Column("idempotency_key", sa.String(length=200), nullable=False),
|
||||
sa.Column("canonical_request_hash", sa.String(length=64), nullable=False),
|
||||
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("execute_after", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("completed_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("declined_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("cancelled_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("expired_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("revision", sa.Integer(), nullable=False),
|
||||
sa.Column("metadata", sa.JSON(), nullable=False),
|
||||
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_ownership_transfers")),
|
||||
sa.UniqueConstraint(
|
||||
"tenant_id",
|
||||
"resource_module",
|
||||
"idempotency_key",
|
||||
name="uq_core_ownership_transfer_idempotency",
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_core_ownership_transfers_tenant_id"),
|
||||
"core_ownership_transfers",
|
||||
["tenant_id"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_core_ownership_transfers_kind"),
|
||||
"core_ownership_transfers",
|
||||
["kind"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_core_ownership_transfers_status"),
|
||||
"core_ownership_transfers",
|
||||
["status"],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
"ix_core_ownership_transfer_resource",
|
||||
"core_ownership_transfers",
|
||||
[
|
||||
"tenant_id",
|
||||
"resource_module",
|
||||
"resource_type",
|
||||
"resource_id",
|
||||
"status",
|
||||
],
|
||||
unique=False,
|
||||
)
|
||||
op.create_index(
|
||||
"ix_core_ownership_transfer_expiry",
|
||||
"core_ownership_transfers",
|
||||
["status", "expires_at"],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
inspector = sa.inspect(op.get_bind())
|
||||
if "core_ownership_transfers" not in inspector.get_table_names():
|
||||
return
|
||||
op.drop_index(
|
||||
"ix_core_ownership_transfer_expiry",
|
||||
table_name="core_ownership_transfers",
|
||||
)
|
||||
op.drop_index(
|
||||
"ix_core_ownership_transfer_resource",
|
||||
table_name="core_ownership_transfers",
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_core_ownership_transfers_status"),
|
||||
table_name="core_ownership_transfers",
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_core_ownership_transfers_kind"),
|
||||
table_name="core_ownership_transfers",
|
||||
)
|
||||
op.drop_index(
|
||||
op.f("ix_core_ownership_transfers_tenant_id"),
|
||||
table_name="core_ownership_transfers",
|
||||
)
|
||||
op.drop_table("core_ownership_transfers")
|
||||
Reference in New Issue
Block a user