{
  "$schema": "mantara.schema.v1",
  "system_name": "ASN Workflow",
  "schema_name": "asn_workflow",
  "description": "A logistics application for managing advanced shipment notices and related processes.",
  "menus": [
    {
      "menu_id": 1,
      "menu_name": "Core Operations",
      "sequence_number": 1,
      "description": "Handles the core logistics operations.",
      "submenus": [
        {
          "submenu_id": 101,
          "submenu_name": "Advanced Shipment Notice Master",
          "sequence_number": 1,
          "description": "Manage advanced shipment notices.",
          "tables": [
            {
              "table_name": "advanced_shipment_notice",
              "comment": "Stores advanced shipment notices sent by suppliers announcing inbound goods.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 101 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "asn_id",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "ASN identifier"
                },
                {
                  "name": "supplier_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "FK to supplier"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL",
                  "comment": "FK to cfg_advanced_shipment_notice_status"
                },
                {
                  "name": "po_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Purchase order number"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_advanced_shipment_notice_status(cfg_advanced_shipment_notice_status_id)"
                },
                {
                  "column": "supplier_id",
                  "references": "asn_workflow.supplier(id)",
                  "on_delete": "RESTRICT",
                  "on_update": "RESTRICT"
                },
                {
                  "column": "po_number",
                  "references": "asn_workflow.order(po_number)",
                  "on_delete": "RESTRICT",
                  "on_update": "RESTRICT"
                }
              ]
            },
            {
              "table_name": "asn_line_item",
              "comment": "Stores line items within an ASN.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 102 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "po_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Purchase order number"
                },
                {
                  "name": "upc_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Universal Product Code"
                },
                {
                  "name": "sku",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Stock Keeping Unit"
                },
                {
                  "name": "quantity",
                  "type": "INTEGER",
                  "constraints": "NOT NULL CHECK (quantity > 0)",
                  "comment": "Quantity of items"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "po_number",
                  "references": "asn_workflow.order(po_number)",
                  "on_delete": "RESTRICT",
                  "on_update": "RESTRICT"
                }
              ]
            },
            {
              "table_name": "receiving_confirmation_report",
              "comment": "Stores documents generated after ASN closure.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 103 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "FK to cfg_receiving_confirmation_report_status"
                },
                {
                  "name": "rcr_id",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "RCR identifier"
                },
                {
                  "name": "sku_details",
                  "type": "JSONB",
                  "constraints": "NOT NULL",
                  "comment": "Details of SKUs"
                },
                {
                  "name": "vendor_details",
                  "type": "JSONB",
                  "constraints": "NOT NULL",
                  "comment": "Details of vendor"
                },
                {
                  "name": "asn_id",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "FK to advanced_shipment_notice"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_receiving_confirmation_report_status(cfg_receiving_confirmation_report_status_id)"
                },
                {
                  "column": "asn_id",
                  "references": "asn_workflow.advanced_shipment_notice(asn_id)",
                  "on_delete": "RESTRICT",
                  "on_update": "RESTRICT"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 102,
          "submenu_name": "ASN Line Item Master",
          "sequence_number": 2,
          "description": "Manage ASN line items."
        },
        {
          "submenu_id": 103,
          "submenu_name": "Receiving Confirmation Report Master",
          "sequence_number": 3,
          "description": "Manage receiving confirmation reports."
        }
      ]
    },
    {
      "menu_id": 2,
      "menu_name": "Master Data & Catalog",
      "sequence_number": 2,
      "description": "Manage master data and catalogs.",
      "submenus": [
        {
          "submenu_id": 201,
          "submenu_name": "Supplier Master",
          "sequence_number": 1,
          "description": "Manage supplier data.",
          "tables": [
            {
              "table_name": "supplier",
              "comment": "Stores entities representing suppliers providing goods.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 201 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "FK to cfg_supplier_status"
                },
                {
                  "name": "supplier_id",
                  "type": "UUID",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Supplier identifier"
                },
                {
                  "name": "supplier_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the supplier"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_supplier_status(cfg_supplier_status_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 202,
          "submenu_name": "Order Master",
          "sequence_number": 2,
          "description": "Manage order data.",
          "tables": [
            {
              "table_name": "order",
              "comment": "Stores purchase orders used in ASN creation.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 202 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "FK to cfg_order_status"
                },
                {
                  "name": "po_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Purchase order number"
                },
                {
                  "name": "vendor_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "FK to supplier"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_order_status(cfg_order_status_id)"
                },
                {
                  "column": "vendor_id",
                  "references": "asn_workflow.supplier(id)",
                  "on_delete": "RESTRICT",
                  "on_update": "RESTRICT"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 3,
      "menu_name": "Reports & History",
      "sequence_number": 3,
      "description": "Access reports and historical data.",
      "submenus": [
        {
          "submenu_id": 301,
          "submenu_name": "Door Master Master",
          "sequence_number": 1,
          "description": "Manage door assignments.",
          "tables": [
            {
              "table_name": "door_master",
              "comment": "Stores master data for door assignments.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 301 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "FK to cfg_door_master_status"
                },
                {
                  "name": "door_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Door number"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_door_master_status(cfg_door_master_status_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 302,
          "submenu_name": "ASN History",
          "sequence_number": 2,
          "description": "View history of advanced shipment notices.",
          "tables": [
            {
              "table_name": "advanced_shipment_notice_history",
              "comment": "Stores history of advanced shipment notices.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 302 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "asn_id",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "ASN identifier"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL",
                  "comment": "FK to cfg_advanced_shipment_notice_status"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_advanced_shipment_notice_status(cfg_advanced_shipment_notice_status_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 303,
          "submenu_name": "ASN Line Item History",
          "sequence_number": 3,
          "description": "View history of ASN line items.",
          "tables": [
            {
              "table_name": "asn_line_item_history",
              "comment": "Stores history of ASN line items.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 303 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "po_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Purchase order number"
                },
                {
                  "name": "quantity",
                  "type": "INTEGER",
                  "constraints": "NOT NULL CHECK (quantity >= 0)",
                  "comment": "Quantity of items"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 304,
          "submenu_name": "Door History",
          "sequence_number": 4,
          "description": "View history of door assignments.",
          "tables": [
            {
              "table_name": "door_master_history",
              "comment": "Stores history of door assignments.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 304 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "door_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Door number"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 305,
          "submenu_name": "RCR History",
          "sequence_number": 5,
          "description": "View history of receiving confirmation reports.",
          "tables": [
            {
              "table_name": "receiving_confirmation_report_history",
              "comment": "Stores history of receiving confirmation reports.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 305 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "rcr_id",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "RCR identifier"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 306,
          "submenu_name": "Supplier History",
          "sequence_number": 6,
          "description": "View history of suppliers.",
          "tables": [
            {
              "table_name": "supplier_history",
              "comment": "Stores history of suppliers.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 306 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "supplier_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "Supplier identifier"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 307,
          "submenu_name": "Order History",
          "sequence_number": 7,
          "description": "View history of orders.",
          "tables": [
            {
              "table_name": "order_history",
              "comment": "Stores history of orders.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 307 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "po_number",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Purchase order number"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 4,
      "menu_name": "User Management",
      "sequence_number": 4,
      "description": "Manage users and roles.",
      "submenus": [
        {
          "submenu_id": 401,
          "submenu_name": "User Directory",
          "sequence_number": 1,
          "description": "Manage user accounts.",
          "tables": [
            {
              "table_name": "users",
              "comment": "Stores user account information.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 401 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "FK to cfg_users_status"
                },
                {
                  "name": "username",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Username for login"
                },
                {
                  "name": "password_hash",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Stores bcrypt hash, never plain text"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_users_status(cfg_users_status_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 402,
          "submenu_name": "Roles & Permissions",
          "sequence_number": 2,
          "description": "Manage roles and permissions.",
          "tables": [
            {
              "table_name": "roles",
              "comment": "Stores role information.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 402 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "FK to cfg_roles_status"
                },
                {
                  "name": "role_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Name of the role"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_roles_status(cfg_roles_status_id)"
                }
              ]
            },
            {
              "table_name": "permissions",
              "comment": "Stores permission information.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 402 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "status_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "FK to cfg_permissions_status"
                },
                {
                  "name": "permission_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Name of the permission"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "status_id",
                  "references": "asn_workflow.cfg_permissions_status(cfg_permissions_status_id)"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 5,
      "menu_name": "Notifications & Audit",
      "sequence_number": 5,
      "description": "Manage notifications and audit logs.",
      "submenus": [
        {
          "submenu_id": 501,
          "submenu_name": "Notifications",
          "sequence_number": 1,
          "description": "Manage system notifications.",
          "tables": [
            {
              "table_name": "notifications",
              "comment": "Stores system notifications.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 501 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "message",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Notification message"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 502,
          "submenu_name": "Audit Log",
          "sequence_number": 2,
          "description": "View system audit logs.",
          "tables": [
            {
              "table_name": "audit_log",
              "comment": "Stores system audit logs.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 502 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "action",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Action performed"
                },
                {
                  "name": "user_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "FK to users"
                },
                {
                  "name": "version",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 1",
                  "comment": "Optimistic-concurrency version counter"
                },
                {
                  "name": "notes",
                  "type": "TEXT",
                  "comment": "Free-form operator notes"
                },
                {
                  "name": "metadata",
                  "type": "JSONB",
                  "comment": "Variable-shape extension payload"
                },
                {
                  "name": "deleted_at",
                  "type": "TIMESTAMP",
                  "comment": "Soft-delete marker (NULL = not deleted)"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "user_id",
                  "references": "asn_workflow.users(id)"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 6,
      "menu_name": "Configuration",
      "sequence_number": 6,
      "description": "Manage system configurations and settings.",
      "submenus": [
        {
          "submenu_id": 601,
          "submenu_name": "ASN Settings",
          "sequence_number": 1,
          "description": "Configure ASN settings.",
          "tables": [
            {
              "table_name": "advanced_shipment_notice_settings",
              "comment": "Stores configuration settings for ASNs.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 601 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "setting_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the setting"
                },
                {
                  "name": "setting_value",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Value of the setting"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 602,
          "submenu_name": "ASN Line Item Settings",
          "sequence_number": 2,
          "description": "Configure ASN line item settings.",
          "tables": [
            {
              "table_name": "asn_line_item_settings",
              "comment": "Stores configuration settings for ASN line items.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 602 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "setting_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the setting"
                },
                {
                  "name": "setting_value",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Value of the setting"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 603,
          "submenu_name": "Door Settings",
          "sequence_number": 3,
          "description": "Configure door settings.",
          "tables": [
            {
              "table_name": "door_master_settings",
              "comment": "Stores configuration settings for doors.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 603 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "setting_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the setting"
                },
                {
                  "name": "setting_value",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Value of the setting"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 604,
          "submenu_name": "RCR Settings",
          "sequence_number": 4,
          "description": "Configure RCR settings.",
          "tables": [
            {
              "table_name": "receiving_confirmation_report_settings",
              "comment": "Stores configuration settings for RCRs.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 604 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "setting_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the setting"
                },
                {
                  "name": "setting_value",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Value of the setting"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 605,
          "submenu_name": "Supplier Settings",
          "sequence_number": 5,
          "description": "Configure supplier settings.",
          "tables": [
            {
              "table_name": "supplier_settings",
              "comment": "Stores configuration settings for suppliers.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 605 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "setting_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the setting"
                },
                {
                  "name": "setting_value",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Value of the setting"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 606,
          "submenu_name": "Order Settings",
          "sequence_number": 6,
          "description": "Configure order settings.",
          "tables": [
            {
              "table_name": "order_settings",
              "comment": "Stores configuration settings for orders.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 606 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "setting_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the setting"
                },
                {
                  "name": "setting_value",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Value of the setting"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 607,
          "submenu_name": "System Configuration",
          "sequence_number": 7,
          "description": "Manage system-wide settings.",
          "tables": [
            {
              "table_name": "system_settings",
              "comment": "Stores system-wide configuration settings.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 607 NOT NULL REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "config_name",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL",
                  "comment": "Name of the configuration"
                },
                {
                  "name": "config_value",
                  "type": "TEXT",
                  "constraints": "NOT NULL",
                  "comment": "Value of the configuration"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMPTZ",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 608,
          "submenu_name": "Cfg Advanced Shipment Notice Status",
          "sequence_number": 8,
          "description": "Status of the advanced shipment notice.",
          "tables": [
            {
              "table_name": "cfg_advanced_shipment_notice_status",
              "comment": "Status of the advanced shipment notice.",
              "columns": [
                {
                  "name": "cfg_advanced_shipment_notice_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 608 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 609,
          "submenu_name": "Receiving Confirmation Report Status",
          "sequence_number": 9,
          "description": "Configurable status values for receiving_confirmation_report",
          "tables": [
            {
              "table_name": "cfg_receiving_confirmation_report_status",
              "comment": "Status lookup for receiving_confirmation_report. Generic placeholder seeds — operator may customise via admin UI.",
              "columns": [
                {
                  "name": "cfg_receiving_confirmation_report_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 609 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 610,
          "submenu_name": "Supplier Status",
          "sequence_number": 10,
          "description": "Configurable status values for supplier",
          "tables": [
            {
              "table_name": "cfg_supplier_status",
              "comment": "Status lookup for supplier. Generic placeholder seeds — operator may customise via admin UI.",
              "columns": [
                {
                  "name": "cfg_supplier_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 610 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 611,
          "submenu_name": "Order Status",
          "sequence_number": 11,
          "description": "Configurable status values for order",
          "tables": [
            {
              "table_name": "cfg_order_status",
              "comment": "Status lookup for order. Generic placeholder seeds — operator may customise via admin UI.",
              "columns": [
                {
                  "name": "cfg_order_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 611 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 612,
          "submenu_name": "Door Master Status",
          "sequence_number": 12,
          "description": "Configurable status values for door_master",
          "tables": [
            {
              "table_name": "cfg_door_master_status",
              "comment": "Status lookup for door_master. Generic placeholder seeds — operator may customise via admin UI.",
              "columns": [
                {
                  "name": "cfg_door_master_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 612 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 613,
          "submenu_name": "Users Status",
          "sequence_number": 13,
          "description": "Configurable status values for users",
          "tables": [
            {
              "table_name": "cfg_users_status",
              "comment": "Status lookup for users. Generic placeholder seeds — operator may customise via admin UI.",
              "columns": [
                {
                  "name": "cfg_users_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 613 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 614,
          "submenu_name": "Roles Status",
          "sequence_number": 14,
          "description": "Configurable status values for roles",
          "tables": [
            {
              "table_name": "cfg_roles_status",
              "comment": "Status lookup for roles. Generic placeholder seeds — operator may customise via admin UI.",
              "columns": [
                {
                  "name": "cfg_roles_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 614 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 615,
          "submenu_name": "Permissions Status",
          "sequence_number": 15,
          "description": "Configurable status values for permissions",
          "tables": [
            {
              "table_name": "cfg_permissions_status",
              "comment": "Status lookup for permissions. Generic placeholder seeds — operator may customise via admin UI.",
              "columns": [
                {
                  "name": "cfg_permissions_status_id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "code",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Status code"
                },
                {
                  "name": "label",
                  "type": "VARCHAR(100)",
                  "constraints": "NOT NULL",
                  "comment": "Status label"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Description of the status"
                },
                {
                  "name": "is_active",
                  "type": "BOOLEAN",
                  "constraints": "NOT NULL DEFAULT TRUE",
                  "comment": "Indicates if the status is active"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 615 REFERENCES asn_workflow.submenu(submenu_id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 616,
          "submenu_name": "Users History",
          "sequence_number": 16,
          "description": "Audit history for users",
          "tables": [
            {
              "table_name": "users_history",
              "comment": "Append-only audit trail for users.",
              "columns": [
                {
                  "name": "id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 616 REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "users_id",
                  "type": "INT",
                  "constraints": "NOT NULL REFERENCES asn_workflow.users(id)",
                  "comment": "FK to users"
                },
                {
                  "name": "change_type",
                  "type": "VARCHAR(30)",
                  "constraints": "NOT NULL CHECK (change_type IN ('CREATE','UPDATE','DELETE'))",
                  "comment": "Type of change"
                },
                {
                  "name": "change_details",
                  "type": "JSONB",
                  "constraints": "NOT NULL",
                  "comment": "Full snapshot of changed fields"
                },
                {
                  "name": "changed_by",
                  "type": "INT",
                  "comment": "Actor user id (FK added later if users table exists)"
                },
                {
                  "name": "change_date",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "ip_address",
                  "type": "INET",
                  "comment": "Source IP of the change"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "users_id",
                  "references": "asn_workflow.users(id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 617,
          "submenu_name": "Roles History",
          "sequence_number": 17,
          "description": "Audit history for roles",
          "tables": [
            {
              "table_name": "roles_history",
              "comment": "Append-only audit trail for roles.",
              "columns": [
                {
                  "name": "id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 617 REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "roles_id",
                  "type": "INT",
                  "constraints": "NOT NULL REFERENCES asn_workflow.roles(id)",
                  "comment": "FK to roles"
                },
                {
                  "name": "change_type",
                  "type": "VARCHAR(30)",
                  "constraints": "NOT NULL CHECK (change_type IN ('CREATE','UPDATE','DELETE'))",
                  "comment": "Type of change"
                },
                {
                  "name": "change_details",
                  "type": "JSONB",
                  "constraints": "NOT NULL",
                  "comment": "Full snapshot of changed fields"
                },
                {
                  "name": "changed_by",
                  "type": "INT",
                  "comment": "Actor user id (FK added later if users table exists)"
                },
                {
                  "name": "change_date",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "ip_address",
                  "type": "INET",
                  "comment": "Source IP of the change"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "roles_id",
                  "references": "asn_workflow.roles(id)"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 618,
          "submenu_name": "Permissions History",
          "sequence_number": 18,
          "description": "Audit history for permissions",
          "tables": [
            {
              "table_name": "permissions_history",
              "comment": "Append-only audit trail for permissions.",
              "columns": [
                {
                  "name": "id",
                  "type": "SERIAL",
                  "constraints": "PRIMARY KEY"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "NOT NULL DEFAULT 618 REFERENCES asn_workflow.submenu(submenu_id)"
                },
                {
                  "name": "permissions_id",
                  "type": "INT",
                  "constraints": "NOT NULL REFERENCES asn_workflow.permissions(id)",
                  "comment": "FK to permissions"
                },
                {
                  "name": "change_type",
                  "type": "VARCHAR(30)",
                  "constraints": "NOT NULL CHECK (change_type IN ('CREATE','UPDATE','DELETE'))",
                  "comment": "Type of change"
                },
                {
                  "name": "change_details",
                  "type": "JSONB",
                  "constraints": "NOT NULL",
                  "comment": "Full snapshot of changed fields"
                },
                {
                  "name": "changed_by",
                  "type": "INT",
                  "comment": "Actor user id (FK added later if users table exists)"
                },
                {
                  "name": "change_date",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "ip_address",
                  "type": "INET",
                  "comment": "Source IP of the change"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "permissions_id",
                  "references": "asn_workflow.permissions(id)"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "assumptions": [
    "UUID is used as the primary key for all tables.",
    "The system will use VARCHAR(255) for string fields unless otherwise specified.",
    "All timestamps are stored in TIMESTAMPTZ format.",
    "The system will use JSONB for storing JSON data.",
    "The system will use VARCHAR(30) for status fields referencing cfg_* tables."
  ],
  "open_questions": [
    "Clarification needed on the workflow transitions for advancedshipmentnotice_lifecycle.",
    "Clarification needed on the exact roles and permissions for each user action."
  ]
}
