{
  "enums": [
    {
      "name": "river_job_state",
      "values": [
        "available",
        "cancelled",
        "completed",
        "discarded",
        "pending",
        "retryable",
        "running",
        "scheduled"
      ]
    }
  ],
  "views": [],
  "tables": [
    {
      "rls": true,
      "name": "activities",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "module_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "kind",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "body",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "video_source",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "body_format",
          "type": "text",
          "default": "'plain'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "package_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "activities_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX activities_pkey ON public.activities USING btree (organisation_id, id)"
        },
        {
          "name": "activities_position_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "module_id",
            "position"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX activities_position_once ON public.activities USING btree (organisation_id, module_id, \"position\")"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "activities_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "activities_body_format_check",
          "target": null,
          "columns": [
            "body_format"
          ],
          "definition": "CHECK ((body_format = ANY (ARRAY['plain'::text, 'html'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_body_format_not_null",
          "target": null,
          "columns": [
            "body_format"
          ],
          "definition": "NOT NULL body_format",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_body_not_null",
          "target": null,
          "columns": [
            "body"
          ],
          "definition": "NOT NULL body",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activities_kind",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "CHECK ((kind = ANY (ARRAY['text'::text, 'video'::text, 'pdf'::text, 'quiz'::text, 'scorm'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_kind_not_null",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "NOT NULL kind",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "activities_module_fk",
          "target": "modules",
          "columns": [
            "organisation_id",
            "module_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, module_id) REFERENCES modules(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "activities_module_id_not_null",
          "target": null,
          "columns": [
            "module_id"
          ],
          "definition": "NOT NULL module_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "activities_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activities_position_nonnegative",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "CHECK ((\"position\" >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "activities_position_once",
          "target": null,
          "columns": [
            "organisation_id",
            "module_id",
            "position"
          ],
          "definition": "UNIQUE (organisation_id, module_id, \"position\")",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activities_revision_positive",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activities_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activities_title_present",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((title = btrim(title)) AND (title <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "activity_package_fk",
          "target": "learning_packages",
          "columns": [
            "organisation_id",
            "package_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, package_id) REFERENCES learning_packages(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00009_drafts.sql",
        "migrations/00014_quiz_attempts.sql",
        "migrations/00035_native_workspace.sql",
        "migrations/00045_experience.sql",
        "migrations/00046_course_builder.sql",
        "migrations/00049_learning_packages.sql"
      ]
    },
    {
      "rls": true,
      "name": "activity_progress",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "server_revision",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "activity_progress_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX activity_progress_pkey ON public.activity_progress USING btree (organisation_id, enrolment_id, activity_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "activity_progress_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "activity_progress_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "activity_progress_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "activity_progress_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_progress_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "activity_progress_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, enrolment_id, activity_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_progress_revision_positive",
          "target": null,
          "columns": [
            "server_revision"
          ],
          "definition": "CHECK ((server_revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_progress_server_revision_not_null",
          "target": null,
          "columns": [
            "server_revision"
          ],
          "definition": "NOT NULL server_revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_progress_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['not_started'::text, 'completed'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_progress_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00013_learning_progress.sql"
      ]
    },
    {
      "rls": true,
      "name": "activity_questions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "prompt",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "options",
          "type": "text[]",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "correct_index",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "activity_questions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX activity_questions_pkey ON public.activity_questions USING btree (organisation_id, id)"
        },
        {
          "name": "activity_questions_position_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "activity_id",
            "position"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX activity_questions_position_once ON public.activity_questions USING btree (organisation_id, activity_id, \"position\")"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "activity_questions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "activity_questions_activity_fk",
          "target": "activities",
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, activity_id) REFERENCES activities(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "activity_questions_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_questions_correct",
          "target": null,
          "columns": [
            "correct_index"
          ],
          "definition": "CHECK ((correct_index >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_questions_correct_index_not_null",
          "target": null,
          "columns": [
            "correct_index"
          ],
          "definition": "NOT NULL correct_index",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_questions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_questions_options",
          "target": null,
          "columns": [
            "options"
          ],
          "definition": "CHECK ((cardinality(options) >= 2))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_questions_options_not_null",
          "target": null,
          "columns": [
            "options"
          ],
          "definition": "NOT NULL options",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_questions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "activity_questions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_questions_position_nonnegative",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "CHECK ((\"position\" >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_questions_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "activity_questions_position_once",
          "target": null,
          "columns": [
            "organisation_id",
            "activity_id",
            "position"
          ],
          "definition": "UNIQUE (organisation_id, activity_id, \"position\")",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_questions_prompt_not_null",
          "target": null,
          "columns": [
            "prompt"
          ],
          "definition": "NOT NULL prompt",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_questions_prompt_present",
          "target": null,
          "columns": [
            "prompt"
          ],
          "definition": "CHECK (((prompt = btrim(prompt)) AND (prompt <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00014_quiz_attempts.sql"
      ]
    },
    {
      "rls": true,
      "name": "activity_quiz_policies",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "max_attempts",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "pass_percent",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "feedback",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "activity_quiz_policies_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX activity_quiz_policies_pkey ON public.activity_quiz_policies USING btree (organisation_id, activity_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "activity_quiz_policies_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "activity_quiz_policies_activity_fk",
          "target": "activities",
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, activity_id) REFERENCES activities(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "activity_quiz_policies_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_quiz_policies_attempts",
          "target": null,
          "columns": [
            "max_attempts"
          ],
          "definition": "CHECK ((max_attempts > 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_quiz_policies_feedback",
          "target": null,
          "columns": [
            "feedback"
          ],
          "definition": "CHECK ((feedback = ANY (ARRAY['never'::text, 'after_submit'::text, 'after_pass'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_quiz_policies_feedback_not_null",
          "target": null,
          "columns": [
            "feedback"
          ],
          "definition": "NOT NULL feedback",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_quiz_policies_max_attempts_not_null",
          "target": null,
          "columns": [
            "max_attempts"
          ],
          "definition": "NOT NULL max_attempts",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_quiz_policies_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "activity_quiz_policies_pass",
          "target": null,
          "columns": [
            "pass_percent"
          ],
          "definition": "CHECK (((pass_percent >= 0) AND (pass_percent <= 100)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "activity_quiz_policies_pass_percent_not_null",
          "target": null,
          "columns": [
            "pass_percent"
          ],
          "definition": "NOT NULL pass_percent",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "activity_quiz_policies_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, activity_id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00014_quiz_attempts.sql"
      ]
    },
    {
      "rls": true,
      "name": "ai_company_policy",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enabled",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "allow_company_keys",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "providers",
          "type": "jsonb",
          "default": "'[\"openrouter\"]'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "daily_limit",
          "type": "integer",
          "default": "20",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "ai_company_policy_pkey",
          "unique": true,
          "columns": [
            "organisation_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX ai_company_policy_pkey ON public.ai_company_policy USING btree (organisation_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "ai_company_policy_allow_company_keys_not_null",
          "target": null,
          "columns": [
            "allow_company_keys"
          ],
          "definition": "NOT NULL allow_company_keys",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_company_policy_daily_limit_check",
          "target": null,
          "columns": [
            "daily_limit"
          ],
          "definition": "CHECK (((daily_limit >= 1) AND (daily_limit <= 1000)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_company_policy_daily_limit_not_null",
          "target": null,
          "columns": [
            "daily_limit"
          ],
          "definition": "NOT NULL daily_limit",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_company_policy_enabled_not_null",
          "target": null,
          "columns": [
            "enabled"
          ],
          "definition": "NOT NULL enabled",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "ai_company_policy_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "ai_company_policy_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "ai_company_policy_pkey",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "PRIMARY KEY (organisation_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_company_policy_providers_check",
          "target": null,
          "columns": [
            "providers"
          ],
          "definition": "CHECK (((jsonb_typeof(providers) = 'array'::text) AND ((jsonb_array_length(providers) >= 1) AND (jsonb_array_length(providers) <= 4))))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_company_policy_providers_not_null",
          "target": null,
          "columns": [
            "providers"
          ],
          "definition": "NOT NULL providers",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_company_policy_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00052_ai_provider_management.sql"
      ]
    },
    {
      "rls": true,
      "name": "ai_company_routing",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course",
          "type": "text",
          "default": "'deployment'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "answer",
          "type": "text",
          "default": "'deployment'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "daily_limit",
          "type": "integer",
          "default": "20",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "ai_company_routing_pkey",
          "unique": true,
          "columns": [
            "organisation_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX ai_company_routing_pkey ON public.ai_company_routing USING btree (organisation_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "ai_company_routing_answer_not_null",
          "target": null,
          "columns": [
            "answer"
          ],
          "definition": "NOT NULL answer",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_company_routing_course_not_null",
          "target": null,
          "columns": [
            "course"
          ],
          "definition": "NOT NULL course",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_company_routing_daily_limit_check",
          "target": null,
          "columns": [
            "daily_limit"
          ],
          "definition": "CHECK (((daily_limit >= 1) AND (daily_limit <= 1000)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_company_routing_daily_limit_not_null",
          "target": null,
          "columns": [
            "daily_limit"
          ],
          "definition": "NOT NULL daily_limit",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "ai_company_routing_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "ai_company_routing_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "ai_company_routing_pkey",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "PRIMARY KEY (organisation_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_company_routing_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00052_ai_provider_management.sql"
      ]
    },
    {
      "rls": true,
      "name": "ai_connections",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "provider",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "model",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "credential_ciphertext",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "privacy_reviewed",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "active",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "tested_revision",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "tested_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "ai_connections_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX ai_connections_pkey ON public.ai_connections USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "ai_connections_active_not_null",
          "target": null,
          "columns": [
            "active"
          ],
          "definition": "NOT NULL active",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_connections_check",
          "target": null,
          "columns": [
            "active",
            "tested_revision",
            "revision",
            "privacy_reviewed",
            "credential_ciphertext"
          ],
          "definition": "CHECK (((NOT active) OR ((tested_revision = revision) AND privacy_reviewed AND (credential_ciphertext <> ''::text))))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_credential_ciphertext_not_null",
          "target": null,
          "columns": [
            "credential_ciphertext"
          ],
          "definition": "NOT NULL credential_ciphertext",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_model_not_null",
          "target": null,
          "columns": [
            "model"
          ],
          "definition": "NOT NULL model",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "ai_connections_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "ai_connections_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "ai_connections_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_privacy_reviewed_not_null",
          "target": null,
          "columns": [
            "privacy_reviewed"
          ],
          "definition": "NOT NULL privacy_reviewed",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_connections_provider_check",
          "target": null,
          "columns": [
            "provider"
          ],
          "definition": "CHECK ((provider = ANY (ARRAY['openrouter'::text, 'openai'::text, 'anthropic'::text, 'deepseek'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_provider_not_null",
          "target": null,
          "columns": [
            "provider"
          ],
          "definition": "NOT NULL provider",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_connections_tested_revision_not_null",
          "target": null,
          "columns": [
            "tested_revision"
          ],
          "definition": "NOT NULL tested_revision",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00052_ai_provider_management.sql"
      ]
    },
    {
      "rls": true,
      "name": "ai_draft_requests",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "model",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "kind",
          "type": "text",
          "default": "'course'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sources",
          "type": "jsonb",
          "default": "'[]'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "provider",
          "type": "text",
          "default": "'openrouter'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "connection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "configuration",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "input_tokens",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "output_tokens",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "ai_draft_daily",
          "unique": false,
          "columns": [
            "organisation_id",
            "created_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX ai_draft_daily ON public.ai_draft_requests USING btree (organisation_id, created_at)"
        },
        {
          "name": "ai_draft_requests_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX ai_draft_requests_pkey ON public.ai_draft_requests USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "ai_draft_connection_fk",
          "target": "ai_connections",
          "columns": [
            "organisation_id",
            "connection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, connection_id) REFERENCES ai_connections(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_configuration_not_null",
          "target": null,
          "columns": [
            "configuration"
          ],
          "definition": "NOT NULL configuration",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_draft_requests_input_tokens_check",
          "target": null,
          "columns": [
            "input_tokens"
          ],
          "definition": "CHECK ((input_tokens >= 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_draft_requests_kind_check",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "CHECK ((kind = ANY (ARRAY['course'::text, 'answer'::text, 'test'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_kind_not_null",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "NOT NULL kind",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_model_not_null",
          "target": null,
          "columns": [
            "model"
          ],
          "definition": "NOT NULL model",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "ai_draft_requests_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "ai_draft_requests_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "c",
          "name": "ai_draft_requests_output_tokens_check",
          "target": null,
          "columns": [
            "output_tokens"
          ],
          "definition": "CHECK ((output_tokens >= 0))",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "ai_draft_requests_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_provider_not_null",
          "target": null,
          "columns": [
            "provider"
          ],
          "definition": "NOT NULL provider",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_draft_requests_sources_check",
          "target": null,
          "columns": [
            "sources"
          ],
          "definition": "CHECK (((jsonb_typeof(sources) = 'array'::text) AND (jsonb_array_length(sources) <= 3)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_sources_not_null",
          "target": null,
          "columns": [
            "sources"
          ],
          "definition": "NOT NULL sources",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "ai_draft_requests_state_check",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['started'::text, 'succeeded'::text, 'failed'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "ai_draft_requests_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00050_ai_draft_requests.sql",
        "migrations/00051_ai_resource_assistance.sql",
        "migrations/00052_ai_provider_management.sql"
      ]
    },
    {
      "rls": true,
      "name": "api_keys",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "key_prefix",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "secret_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "rotated_from_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "api_keys_hash_once",
          "unique": true,
          "columns": [
            "secret_hash"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX api_keys_hash_once ON public.api_keys USING btree (secret_hash)"
        },
        {
          "name": "api_keys_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX api_keys_pkey ON public.api_keys USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "api_keys_by_hash",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "(secret_hash = decode(NULLIF(current_setting('app.api_key_hash'::text, true), ''::text), 'hex'::text))",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "api_keys_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "api_keys_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "api_keys_hash_once",
          "target": null,
          "columns": [
            "secret_hash"
          ],
          "definition": "UNIQUE (secret_hash)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "api_keys_hash_present",
          "target": null,
          "columns": [
            "secret_hash"
          ],
          "definition": "CHECK ((octet_length(secret_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "api_keys_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "api_keys_key_prefix_not_null",
          "target": null,
          "columns": [
            "key_prefix"
          ],
          "definition": "NOT NULL key_prefix",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "api_keys_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "api_keys_name_present",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "CHECK (((name = btrim(name)) AND (name <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "api_keys_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "api_keys_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "api_keys_prefix_present",
          "target": null,
          "columns": [
            "key_prefix"
          ],
          "definition": "CHECK (((key_prefix = btrim(key_prefix)) AND (char_length(key_prefix) >= 8)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "api_keys_rotated_fk",
          "target": "api_keys",
          "columns": [
            "organisation_id",
            "rotated_from_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, rotated_from_id) REFERENCES api_keys(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "api_keys_secret_hash_not_null",
          "target": null,
          "columns": [
            "secret_hash"
          ],
          "definition": "NOT NULL secret_hash",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00033_api_keys_webhooks.sql"
      ]
    },
    {
      "rls": true,
      "name": "attempt_answers",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "question_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "selected_index",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "correct",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "attempt_answers_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "attempt_id",
            "question_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX attempt_answers_pkey ON public.attempt_answers USING btree (organisation_id, attempt_id, question_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "attempt_answers_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "attempt_answers_attempt_fk",
          "target": "attempts",
          "columns": [
            "organisation_id",
            "attempt_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, attempt_id) REFERENCES attempts(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "attempt_answers_attempt_id_not_null",
          "target": null,
          "columns": [
            "attempt_id"
          ],
          "definition": "NOT NULL attempt_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempt_answers_correct_not_null",
          "target": null,
          "columns": [
            "correct"
          ],
          "definition": "NOT NULL correct",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempt_answers_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "attempt_answers_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "attempt_id",
            "question_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, attempt_id, question_id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "attempt_answers_question_fk",
          "target": "course_version_questions",
          "columns": [
            "organisation_id",
            "question_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, question_id) REFERENCES course_version_questions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "attempt_answers_question_id_not_null",
          "target": null,
          "columns": [
            "question_id"
          ],
          "definition": "NOT NULL question_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "attempt_answers_selected",
          "target": null,
          "columns": [
            "selected_index"
          ],
          "definition": "CHECK ((selected_index >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempt_answers_selected_index_not_null",
          "target": null,
          "columns": [
            "selected_index"
          ],
          "definition": "NOT NULL selected_index",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00014_quiz_attempts.sql"
      ]
    },
    {
      "rls": true,
      "name": "attempts",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_number",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "score_percent",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "passed",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "started_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "submitted_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "graded_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "attempts_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id",
            "attempt_number"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX attempts_once ON public.attempts USING btree (organisation_id, enrolment_id, activity_id, attempt_number)"
        },
        {
          "name": "attempts_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX attempts_pkey ON public.attempts USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "attempts_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "attempts_activity_fk",
          "target": "course_version_activities",
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, activity_id) REFERENCES course_version_activities(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "attempts_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempts_attempt_number_not_null",
          "target": null,
          "columns": [
            "attempt_number"
          ],
          "definition": "NOT NULL attempt_number",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "attempts_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "attempts_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempts_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "attempts_number_positive",
          "target": null,
          "columns": [
            "attempt_number"
          ],
          "definition": "CHECK ((attempt_number > 0))",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "attempts_once",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id",
            "attempt_number"
          ],
          "definition": "UNIQUE (organisation_id, enrolment_id, activity_id, attempt_number)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempts_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "attempts_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "attempts_score",
          "target": null,
          "columns": [
            "score_percent"
          ],
          "definition": "CHECK (((score_percent IS NULL) OR ((score_percent >= 0) AND (score_percent <= 100))))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempts_started_at_not_null",
          "target": null,
          "columns": [
            "started_at"
          ],
          "definition": "NOT NULL started_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "attempts_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['started'::text, 'submitted'::text, 'graded'::text, 'abandoned'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "attempts_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "attempts_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "attempts_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00014_quiz_attempts.sql"
      ]
    },
    {
      "rls": true,
      "name": "auth_transactions",
      "columns": [
        {
          "name": "state_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "issuer",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "nonce",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "verifier",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "broker_alias",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "broker_revision",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "auth_transactions_pkey",
          "unique": true,
          "columns": [
            "state_hash"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX auth_transactions_pkey ON public.auth_transactions USING btree (state_hash)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "auth_transactions_by_hash",
          "check": "(state_hash = decode(NULLIF(current_setting('app.login_state_hash'::text, true), ''::text), 'hex'::text))",
          "roles": [
            "public"
          ],
          "using": "(state_hash = decode(NULLIF(current_setting('app.login_state_hash'::text, true), ''::text), 'hex'::text))",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "auth_transactions_broker_alias_not_null",
          "target": null,
          "columns": [
            "broker_alias"
          ],
          "definition": "NOT NULL broker_alias",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "auth_transactions_broker_revision_not_null",
          "target": null,
          "columns": [
            "broker_revision"
          ],
          "definition": "NOT NULL broker_revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "auth_transactions_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "auth_transactions_issuer_not_null",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "NOT NULL issuer",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "auth_transactions_issuer_present",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "CHECK (((issuer = btrim(issuer)) AND (issuer <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "auth_transactions_nonce_not_null",
          "target": null,
          "columns": [
            "nonce"
          ],
          "definition": "NOT NULL nonce",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "auth_transactions_nonce_present",
          "target": null,
          "columns": [
            "nonce"
          ],
          "definition": "CHECK ((nonce <> ''::text))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "auth_transactions_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "auth_transactions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "auth_transactions_pkey",
          "target": null,
          "columns": [
            "state_hash"
          ],
          "definition": "PRIMARY KEY (state_hash)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "auth_transactions_state_hash_not_null",
          "target": null,
          "columns": [
            "state_hash"
          ],
          "definition": "NOT NULL state_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "auth_transactions_verifier_not_null",
          "target": null,
          "columns": [
            "verifier"
          ],
          "definition": "NOT NULL verifier",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "auth_transactions_verifier_present",
          "target": null,
          "columns": [
            "verifier"
          ],
          "definition": "CHECK ((verifier <> ''::text))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00005_browser_sessions.sql",
        "migrations/00041_organisation_administration.sql"
      ]
    },
    {
      "rls": true,
      "name": "binding_decisions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "invitation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "actor_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "decision",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "binding_decisions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX binding_decisions_pkey ON public.binding_decisions USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "binding_decisions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "binding_decisions_actor_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "actor_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, actor_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "binding_decisions_actor_id_not_null",
          "target": null,
          "columns": [
            "actor_id"
          ],
          "definition": "NOT NULL actor_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "binding_decisions_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "binding_decisions_decision",
          "target": null,
          "columns": [
            "decision"
          ],
          "definition": "CHECK ((decision = ANY (ARRAY['approved'::text, 'rejected'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "binding_decisions_decision_not_null",
          "target": null,
          "columns": [
            "decision"
          ],
          "definition": "NOT NULL decision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "binding_decisions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "binding_decisions_invitation_fk",
          "target": "invitations",
          "columns": [
            "organisation_id",
            "invitation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, invitation_id) REFERENCES invitations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "binding_decisions_invitation_id_not_null",
          "target": null,
          "columns": [
            "invitation_id"
          ],
          "definition": "NOT NULL invitation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "binding_decisions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "binding_decisions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00006_invitations.sql"
      ]
    },
    {
      "rls": true,
      "name": "browser_sessions",
      "columns": [
        {
          "name": "session_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "authz_version",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "auth_time",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "csrf_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "last_seen_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "absolute_expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "assurance",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "oidc_issuer",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "oidc_subject_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "oidc_sid_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "browser_oidc_sid",
          "unique": false,
          "columns": [
            "oidc_issuer",
            "oidc_sid_hash"
          ],
          "primary": false,
          "predicate": "(oidc_sid_hash IS NOT NULL)",
          "definition": "CREATE INDEX browser_oidc_sid ON public.browser_sessions USING btree (oidc_issuer, oidc_sid_hash) WHERE (oidc_sid_hash IS NOT NULL)"
        },
        {
          "name": "browser_oidc_subject",
          "unique": false,
          "columns": [
            "oidc_issuer",
            "oidc_subject_hash"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX browser_oidc_subject ON public.browser_sessions USING btree (oidc_issuer, oidc_subject_hash)"
        },
        {
          "name": "browser_sessions_pkey",
          "unique": true,
          "columns": [
            "session_hash"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX browser_sessions_pkey ON public.browser_sessions USING btree (session_hash)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "browser_sessions_by_actor",
          "check": "((organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid) AND (user_id = (NULLIF(current_setting('app.actor_id'::text, true), ''::text))::uuid))",
          "roles": [
            "public"
          ],
          "using": "((organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid) AND (user_id = (NULLIF(current_setting('app.actor_id'::text, true), ''::text))::uuid))",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "browser_sessions_by_hash",
          "check": "(session_hash = decode(NULLIF(current_setting('app.session_hash'::text, true), ''::text), 'hex'::text))",
          "roles": [
            "public"
          ],
          "using": "(session_hash = decode(NULLIF(current_setting('app.session_hash'::text, true), ''::text), 'hex'::text))",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "browser_sessions_for_logout",
          "check": "false",
          "roles": [
            "public"
          ],
          "using": "((oidc_issuer = NULLIF(current_setting('app.logout_issuer'::text, true), ''::text)) AND ((NULLIF(current_setting('app.logout_sid'::text, true), ''::text) IS NOT NULL) OR (NULLIF(current_setting('app.logout_subject'::text, true), ''::text) IS NOT NULL)) AND ((NULLIF(current_setting('app.logout_sid'::text, true), ''::text) IS NULL) OR (oidc_sid_hash = decode(current_setting('app.logout_sid'::text, true), 'hex'::text))) AND ((NULLIF(current_setting('app.logout_subject'::text, true), ''::text) IS NULL) OR (oidc_subject_hash = decode(current_setting('app.logout_subject'::text, true), 'hex'::text))))",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "browser_oidc_sid_hash",
          "target": null,
          "columns": [
            "oidc_sid_hash"
          ],
          "definition": "CHECK (((oidc_sid_hash IS NULL) OR (octet_length(oidc_sid_hash) = 32)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "browser_oidc_subject_hash",
          "target": null,
          "columns": [
            "oidc_subject_hash"
          ],
          "definition": "CHECK (((oidc_subject_hash IS NULL) OR (octet_length(oidc_subject_hash) = 32)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "browser_sessions_absolute",
          "target": null,
          "columns": [
            "absolute_expires_at",
            "created_at"
          ],
          "definition": "CHECK ((absolute_expires_at > created_at))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_absolute_expires_at_not_null",
          "target": null,
          "columns": [
            "absolute_expires_at"
          ],
          "definition": "NOT NULL absolute_expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_assurance_not_null",
          "target": null,
          "columns": [
            "assurance"
          ],
          "definition": "NOT NULL assurance",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_auth_time_not_null",
          "target": null,
          "columns": [
            "auth_time"
          ],
          "definition": "NOT NULL auth_time",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_authz_version_not_null",
          "target": null,
          "columns": [
            "authz_version"
          ],
          "definition": "NOT NULL authz_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_csrf_hash_not_null",
          "target": null,
          "columns": [
            "csrf_hash"
          ],
          "definition": "NOT NULL csrf_hash",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "browser_sessions_csrf_present",
          "target": null,
          "columns": [
            "csrf_hash"
          ],
          "definition": "CHECK ((octet_length(csrf_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "browser_sessions_hash_present",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "CHECK ((octet_length(session_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_last_seen_at_not_null",
          "target": null,
          "columns": [
            "last_seen_at"
          ],
          "definition": "NOT NULL last_seen_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_oidc_issuer_not_null",
          "target": null,
          "columns": [
            "oidc_issuer"
          ],
          "definition": "NOT NULL oidc_issuer",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "browser_sessions_pkey",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "PRIMARY KEY (session_hash)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "browser_sessions_session_hash_not_null",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "NOT NULL session_hash",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "browser_sessions_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "browser_sessions_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00005_browser_sessions.sql",
        "migrations/00008_profiles.sql",
        "migrations/00040_oidc_session_revocation.sql",
        "migrations/00055_support_views.sql"
      ]
    },
    {
      "rls": true,
      "name": "certificate_versions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "certificate_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version_number",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "pdf_object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "html_object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "template_version",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "rendered_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "certificate_versions_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "certificate_id",
            "version_number"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX certificate_versions_once ON public.certificate_versions USING btree (organisation_id, certificate_id, version_number)"
        },
        {
          "name": "certificate_versions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX certificate_versions_pkey ON public.certificate_versions USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "certificate_versions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "certificate_versions_certificate_fk",
          "target": "certificates",
          "columns": [
            "organisation_id",
            "certificate_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, certificate_id) REFERENCES certificates(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "certificate_versions_certificate_id_not_null",
          "target": null,
          "columns": [
            "certificate_id"
          ],
          "definition": "NOT NULL certificate_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificate_versions_html_object_id_not_null",
          "target": null,
          "columns": [
            "html_object_id"
          ],
          "definition": "NOT NULL html_object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificate_versions_html_present",
          "target": null,
          "columns": [
            "html_object_id"
          ],
          "definition": "CHECK (((html_object_id = btrim(html_object_id)) AND (html_object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificate_versions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificate_versions_number",
          "target": null,
          "columns": [
            "version_number"
          ],
          "definition": "CHECK ((version_number > 0))",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "certificate_versions_once",
          "target": null,
          "columns": [
            "organisation_id",
            "certificate_id",
            "version_number"
          ],
          "definition": "UNIQUE (organisation_id, certificate_id, version_number)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificate_versions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificate_versions_pdf_object_id_not_null",
          "target": null,
          "columns": [
            "pdf_object_id"
          ],
          "definition": "NOT NULL pdf_object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificate_versions_pdf_present",
          "target": null,
          "columns": [
            "pdf_object_id"
          ],
          "definition": "CHECK (((pdf_object_id = btrim(pdf_object_id)) AND (pdf_object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "certificate_versions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificate_versions_rendered_at_not_null",
          "target": null,
          "columns": [
            "rendered_at"
          ],
          "definition": "NOT NULL rendered_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificate_versions_template_present",
          "target": null,
          "columns": [
            "template_version"
          ],
          "definition": "CHECK (((template_version = btrim(template_version)) AND (template_version <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificate_versions_template_version_not_null",
          "target": null,
          "columns": [
            "template_version"
          ],
          "definition": "NOT NULL template_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificate_versions_version_number_not_null",
          "target": null,
          "columns": [
            "version_number"
          ],
          "definition": "NOT NULL version_number",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00018_certificates.sql"
      ]
    },
    {
      "rls": true,
      "name": "certificates",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "completion_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "learner_name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "valid_from",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "valid_until",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_by",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "revoke_reason",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "render_generation",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "render_started_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "certificates_completion_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "completion_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX certificates_completion_once ON public.certificates USING btree (organisation_id, completion_id)"
        },
        {
          "name": "certificates_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX certificates_pkey ON public.certificates USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "certificates_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "certificates_completion_fk",
          "target": "completions",
          "columns": [
            "organisation_id",
            "completion_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, completion_id) REFERENCES completions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "certificates_completion_id_not_null",
          "target": null,
          "columns": [
            "completion_id"
          ],
          "definition": "NOT NULL completion_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "certificates_completion_once",
          "target": null,
          "columns": [
            "organisation_id",
            "completion_id"
          ],
          "definition": "UNIQUE (organisation_id, completion_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_course_title_not_null",
          "target": null,
          "columns": [
            "course_title"
          ],
          "definition": "NOT NULL course_title",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "certificates_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "certificates_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_learner_name_not_null",
          "target": null,
          "columns": [
            "learner_name"
          ],
          "definition": "NOT NULL learner_name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificates_learner_present",
          "target": null,
          "columns": [
            "learner_name"
          ],
          "definition": "CHECK (((learner_name = btrim(learner_name)) AND (learner_name <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "certificates_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_render_generation_not_null",
          "target": null,
          "columns": [
            "render_generation"
          ],
          "definition": "NOT NULL render_generation",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificates_revoke_complete",
          "target": null,
          "columns": [
            "revoked_at",
            "revoked_by",
            "revoke_reason"
          ],
          "definition": "CHECK ((((revoked_at IS NULL) AND (revoked_by IS NULL) AND (revoke_reason IS NULL)) OR ((revoked_at IS NOT NULL) AND (revoked_by IS NOT NULL) AND (revoke_reason = btrim(revoke_reason)) AND (revoke_reason <> ''::text))))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "certificates_revoked_by_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "revoked_by"
          ],
          "definition": "FOREIGN KEY (organisation_id, revoked_by) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "c",
          "name": "certificates_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['queued'::text, 'rendering'::text, 'ready'::text, 'failed'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificates_title_present",
          "target": null,
          "columns": [
            "course_title"
          ],
          "definition": "CHECK (((course_title = btrim(course_title)) AND (course_title <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "certificates_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "certificates_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "certificates_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "certificates_validity_order",
          "target": null,
          "columns": [
            "valid_until",
            "valid_from"
          ],
          "definition": "CHECK (((valid_until IS NULL) OR (valid_from IS NULL) OR (valid_until >= valid_from)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00018_certificates.sql",
        "migrations/00019_certificate_revocation.sql",
        "migrations/00020_refresher_schedule.sql",
        "migrations/00038_certificate_render_leases.sql"
      ]
    },
    {
      "rls": true,
      "name": "collection_courses",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "collection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "collection_courses_organisation_id_collection_id_position_key",
          "unique": true,
          "columns": [
            "organisation_id",
            "collection_id",
            "position"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX collection_courses_organisation_id_collection_id_position_key ON public.collection_courses USING btree (organisation_id, collection_id, \"position\")"
        },
        {
          "name": "collection_courses_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "collection_id",
            "course_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX collection_courses_pkey ON public.collection_courses USING btree (organisation_id, collection_id, course_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "collection_courses_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "collection_courses_collection_id_not_null",
          "target": null,
          "columns": [
            "collection_id"
          ],
          "definition": "NOT NULL collection_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "collection_courses_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "collection_courses_organisation_id_collection_id_fkey",
          "target": "course_collections",
          "columns": [
            "organisation_id",
            "collection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, collection_id) REFERENCES course_collections(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "u",
          "name": "collection_courses_organisation_id_collection_id_position_key",
          "target": null,
          "columns": [
            "organisation_id",
            "collection_id",
            "position"
          ],
          "definition": "UNIQUE (organisation_id, collection_id, \"position\")",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "collection_courses_organisation_id_course_id_fkey",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "collection_courses_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "collection_courses_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "collection_id",
            "course_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, collection_id, course_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "collection_courses_position_check",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "CHECK ((\"position\" >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "collection_courses_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "collection_follows",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "collection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "collection_follows_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "collection_id",
            "user_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX collection_follows_pkey ON public.collection_follows USING btree (organisation_id, collection_id, user_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "collection_follows_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "collection_follows_collection_id_not_null",
          "target": null,
          "columns": [
            "collection_id"
          ],
          "definition": "NOT NULL collection_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "collection_follows_organisation_id_collection_id_fkey",
          "target": "course_collections",
          "columns": [
            "organisation_id",
            "collection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, collection_id) REFERENCES course_collections(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "collection_follows_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "collection_follows_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "collection_follows_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "collection_id",
            "user_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, collection_id, user_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "collection_follows_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "collection_recommendations",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "collection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "recommended_by",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "collection_recommendations_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "collection_id",
            "user_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX collection_recommendations_pkey ON public.collection_recommendations USING btree (organisation_id, collection_id, user_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "collection_recommendations_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "collection_recommendations_collection_id_not_null",
          "target": null,
          "columns": [
            "collection_id"
          ],
          "definition": "NOT NULL collection_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "collection_recommendations_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "collection_recommendations_organisation_id_collection_id_fkey",
          "target": "course_collections",
          "columns": [
            "organisation_id",
            "collection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, collection_id) REFERENCES course_collections(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "collection_recommendations_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "collection_recommendations_organisation_id_recommended_by_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "recommended_by"
          ],
          "definition": "FOREIGN KEY (organisation_id, recommended_by) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "collection_recommendations_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "collection_recommendations_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "collection_id",
            "user_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, collection_id, user_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "collection_recommendations_recommended_by_not_null",
          "target": null,
          "columns": [
            "recommended_by"
          ],
          "definition": "NOT NULL recommended_by",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "collection_recommendations_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": true,
      "name": "company_domain_claims",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "hostname",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "token",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "verified_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "company_domain_claim_owner",
          "unique": true,
          "columns": [
            "hostname"
          ],
          "primary": false,
          "predicate": "(verified_at IS NOT NULL)",
          "definition": "CREATE UNIQUE INDEX company_domain_claim_owner ON public.company_domain_claims USING btree (hostname) WHERE (verified_at IS NOT NULL)"
        },
        {
          "name": "company_domain_claims_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "hostname"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX company_domain_claims_pkey ON public.company_domain_claims USING btree (organisation_id, hostname)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "company_domain_claims_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "company_domain_claims_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "company_domain_claims_hostname_check",
          "target": null,
          "columns": [
            "hostname"
          ],
          "definition": "CHECK ((((length(hostname) >= 4) AND (length(hostname) <= 253)) AND (hostname = lower(hostname))))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "company_domain_claims_hostname_not_null",
          "target": null,
          "columns": [
            "hostname"
          ],
          "definition": "NOT NULL hostname",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "company_domain_claims_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "company_domain_claims_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "company_domain_claims_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "hostname"
          ],
          "definition": "PRIMARY KEY (organisation_id, hostname)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "company_domain_claims_token_not_null",
          "target": null,
          "columns": [
            "token"
          ],
          "definition": "NOT NULL token",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00048_company_addresses.sql"
      ]
    },
    {
      "rls": true,
      "name": "completions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "completed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "completions_enrolment_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX completions_enrolment_once ON public.completions USING btree (organisation_id, enrolment_id)"
        },
        {
          "name": "completions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX completions_pkey ON public.completions USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "completions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "completions_completed_at_not_null",
          "target": null,
          "columns": [
            "completed_at"
          ],
          "definition": "NOT NULL completed_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "completions_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "completions_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "completions_enrolment_once",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "UNIQUE (organisation_id, enrolment_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "completions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "completions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "completions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00015_completions.sql",
        "migrations/00018_certificates.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_bookmarks",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_bookmarks_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id",
            "course_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_bookmarks_pkey ON public.course_bookmarks USING btree (organisation_id, user_id, course_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_bookmarks_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "course_bookmarks_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_bookmarks_organisation_id_course_id_fkey",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_bookmarks_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_bookmarks_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "course_bookmarks_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id",
            "course_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, user_id, course_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_bookmarks_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00043_course_bookmarks.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_collections",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "description",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "colour",
          "type": "text",
          "default": "'violet'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "audience_unit",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "published",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "archived",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_collections_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_collections_pkey ON public.course_collections USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_collections_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "course_collections_archived_not_null",
          "target": null,
          "columns": [
            "archived"
          ],
          "definition": "NOT NULL archived",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_collections_colour_not_null",
          "target": null,
          "columns": [
            "colour"
          ],
          "definition": "NOT NULL colour",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_collections_description_not_null",
          "target": null,
          "columns": [
            "description"
          ],
          "definition": "NOT NULL description",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_collections_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_collections_organisation_id_audience_unit_fkey",
          "target": "units",
          "columns": [
            "organisation_id",
            "audience_unit"
          ],
          "definition": "FOREIGN KEY (organisation_id, audience_unit) REFERENCES units(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "course_collections_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_collections_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_collections_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_collections_published_not_null",
          "target": null,
          "columns": [
            "published"
          ],
          "definition": "NOT NULL published",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_collections_revision_check",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_collections_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_collections_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql",
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_draft_assets",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "quarantine_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_draft_assets_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_id",
            "quarantine_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_draft_assets_pkey ON public.course_draft_assets USING btree (organisation_id, course_id, quarantine_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_draft_assets_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "course_draft_assets_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_draft_assets_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_draft_assets_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_draft_assets_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "course_id",
            "quarantine_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, course_id, quarantine_id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_draft_assets_quarantine_fk",
          "target": "quarantine_uploads",
          "columns": [
            "organisation_id",
            "quarantine_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, quarantine_id) REFERENCES quarantine_uploads(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_draft_assets_quarantine_id_not_null",
          "target": null,
          "columns": [
            "quarantine_id"
          ],
          "definition": "NOT NULL quarantine_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00012_quarantine.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_draft_renditions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "media_asset_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_draft_renditions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_id",
            "media_asset_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_draft_renditions_pkey ON public.course_draft_renditions USING btree (organisation_id, course_id, media_asset_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_draft_renditions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "course_draft_renditions_asset_fk",
          "target": "media_assets",
          "columns": [
            "organisation_id",
            "media_asset_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, media_asset_id) REFERENCES media_assets(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "course_draft_renditions_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_draft_renditions_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_draft_renditions_media_asset_id_not_null",
          "target": null,
          "columns": [
            "media_asset_id"
          ],
          "definition": "NOT NULL media_asset_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_draft_renditions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_draft_renditions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "course_id",
            "media_asset_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, course_id, media_asset_id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00017_media_renditions.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_version_activities",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "module_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "kind",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "body",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "video_source",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "body_format",
          "type": "text",
          "default": "'plain'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "package_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_version_activities_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_activities_pkey ON public.course_version_activities USING btree (organisation_id, id)"
        },
        {
          "name": "course_version_activities_position_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "module_id",
            "position"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_activities_position_once ON public.course_version_activities USING btree (organisation_id, module_id, \"position\")"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_version_activities_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "course_version_activities_body_format_check",
          "target": null,
          "columns": [
            "body_format"
          ],
          "definition": "CHECK ((body_format = ANY (ARRAY['plain'::text, 'html'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_activities_body_format_not_null",
          "target": null,
          "columns": [
            "body_format"
          ],
          "definition": "NOT NULL body_format",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_activities_body_not_null",
          "target": null,
          "columns": [
            "body"
          ],
          "definition": "NOT NULL body",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_activities_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_activities_kind",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "CHECK ((kind = ANY (ARRAY['text'::text, 'video'::text, 'pdf'::text, 'quiz'::text, 'scorm'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_activities_kind_not_null",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "NOT NULL kind",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_version_activities_module_fk",
          "target": "course_version_modules",
          "columns": [
            "organisation_id",
            "module_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, module_id) REFERENCES course_version_modules(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_version_activities_module_id_not_null",
          "target": null,
          "columns": [
            "module_id"
          ],
          "definition": "NOT NULL module_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_activities_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_version_activities_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_activities_position_nonnegative",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "CHECK ((\"position\" >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_activities_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "course_version_activities_position_once",
          "target": null,
          "columns": [
            "organisation_id",
            "module_id",
            "position"
          ],
          "definition": "UNIQUE (organisation_id, module_id, \"position\")",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_activities_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_activities_title_present",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((title = btrim(title)) AND (title <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "version_activity_package_fk",
          "target": "learning_packages",
          "columns": [
            "organisation_id",
            "package_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, package_id) REFERENCES learning_packages(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00010_course_versions.sql",
        "migrations/00014_quiz_attempts.sql",
        "migrations/00035_native_workspace.sql",
        "migrations/00045_experience.sql",
        "migrations/00046_course_builder.sql",
        "migrations/00049_learning_packages.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_version_assets",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "quarantine_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_version_assets_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_version_id",
            "quarantine_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_assets_pkey ON public.course_version_assets USING btree (organisation_id, course_version_id, quarantine_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_version_assets_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "course_version_assets_byte_length",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_assets_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_assets_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_assets_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_assets_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_version_assets_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "course_version_id",
            "quarantine_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, course_version_id, quarantine_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_assets_quarantine_id_not_null",
          "target": null,
          "columns": [
            "quarantine_id"
          ],
          "definition": "NOT NULL quarantine_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_assets_sha256",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "CHECK ((octet_length(sha256) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_assets_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_version_assets_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00012_quarantine.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_version_modules",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "summary",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_version_modules_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_modules_pkey ON public.course_version_modules USING btree (organisation_id, id)"
        },
        {
          "name": "course_version_modules_position_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_version_id",
            "position"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_modules_position_once ON public.course_version_modules USING btree (organisation_id, course_version_id, \"position\")"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_version_modules_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "course_version_modules_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_modules_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_modules_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_version_modules_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_modules_position_nonnegative",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "CHECK ((\"position\" >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_modules_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "course_version_modules_position_once",
          "target": null,
          "columns": [
            "organisation_id",
            "course_version_id",
            "position"
          ],
          "definition": "UNIQUE (organisation_id, course_version_id, \"position\")",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_modules_summary_not_null",
          "target": null,
          "columns": [
            "summary"
          ],
          "definition": "NOT NULL summary",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_modules_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_modules_title_present",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((title = btrim(title)) AND (title <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_version_modules_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00010_course_versions.sql",
        "migrations/00046_course_builder.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_version_questions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "prompt",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "options",
          "type": "text[]",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "correct_index",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_version_questions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_questions_pkey ON public.course_version_questions USING btree (organisation_id, id)"
        },
        {
          "name": "course_version_questions_position_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "activity_id",
            "position"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_questions_position_once ON public.course_version_questions USING btree (organisation_id, activity_id, \"position\")"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_version_questions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "course_version_questions_activity_fk",
          "target": "course_version_activities",
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, activity_id) REFERENCES course_version_activities(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_version_questions_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_questions_correct",
          "target": null,
          "columns": [
            "correct_index"
          ],
          "definition": "CHECK ((correct_index >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_questions_correct_index_not_null",
          "target": null,
          "columns": [
            "correct_index"
          ],
          "definition": "NOT NULL correct_index",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_questions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_questions_options",
          "target": null,
          "columns": [
            "options"
          ],
          "definition": "CHECK ((cardinality(options) >= 2))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_questions_options_not_null",
          "target": null,
          "columns": [
            "options"
          ],
          "definition": "NOT NULL options",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_questions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_version_questions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_questions_position_nonnegative",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "CHECK ((\"position\" >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_questions_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "course_version_questions_position_once",
          "target": null,
          "columns": [
            "organisation_id",
            "activity_id",
            "position"
          ],
          "definition": "UNIQUE (organisation_id, activity_id, \"position\")",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_questions_prompt_not_null",
          "target": null,
          "columns": [
            "prompt"
          ],
          "definition": "NOT NULL prompt",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_questions_prompt_present",
          "target": null,
          "columns": [
            "prompt"
          ],
          "definition": "CHECK (((prompt = btrim(prompt)) AND (prompt <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00014_quiz_attempts.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_version_quiz_policies",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "max_attempts",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "pass_percent",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "feedback",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_version_quiz_policies_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_quiz_policies_pkey ON public.course_version_quiz_policies USING btree (organisation_id, activity_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_version_quiz_policies_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "course_version_quiz_policies_activity_fk",
          "target": "course_version_activities",
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, activity_id) REFERENCES course_version_activities(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_version_quiz_policies_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_quiz_policies_attempts",
          "target": null,
          "columns": [
            "max_attempts"
          ],
          "definition": "CHECK ((max_attempts > 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_quiz_policies_feedback",
          "target": null,
          "columns": [
            "feedback"
          ],
          "definition": "CHECK ((feedback = ANY (ARRAY['never'::text, 'after_submit'::text, 'after_pass'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_quiz_policies_feedback_not_null",
          "target": null,
          "columns": [
            "feedback"
          ],
          "definition": "NOT NULL feedback",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_quiz_policies_max_attempts_not_null",
          "target": null,
          "columns": [
            "max_attempts"
          ],
          "definition": "NOT NULL max_attempts",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_quiz_policies_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_quiz_policies_pass",
          "target": null,
          "columns": [
            "pass_percent"
          ],
          "definition": "CHECK (((pass_percent >= 0) AND (pass_percent <= 100)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_quiz_policies_pass_percent_not_null",
          "target": null,
          "columns": [
            "pass_percent"
          ],
          "definition": "NOT NULL pass_percent",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_version_quiz_policies_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, activity_id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00014_quiz_attempts.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_version_renditions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "media_asset_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "master_object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_version_renditions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_version_id",
            "media_asset_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_renditions_pkey ON public.course_version_renditions USING btree (organisation_id, course_version_id, media_asset_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_version_renditions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "course_version_renditions_attempt_id_not_null",
          "target": null,
          "columns": [
            "attempt_id"
          ],
          "definition": "NOT NULL attempt_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_renditions_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_renditions_master_object_id_not_null",
          "target": null,
          "columns": [
            "master_object_id"
          ],
          "definition": "NOT NULL master_object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_renditions_master_present",
          "target": null,
          "columns": [
            "master_object_id"
          ],
          "definition": "CHECK (((master_object_id = btrim(master_object_id)) AND (master_object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_renditions_media_asset_id_not_null",
          "target": null,
          "columns": [
            "media_asset_id"
          ],
          "definition": "NOT NULL media_asset_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_renditions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_version_renditions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "course_version_id",
            "media_asset_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, course_version_id, media_asset_id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_version_renditions_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00017_media_renditions.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_version_scorm",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "package_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "item_title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "launch_href",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_version_scorm_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_version_scorm_pkey ON public.course_version_scorm USING btree (organisation_id, course_version_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_version_scorm_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "course_version_scorm_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_scorm_item_title_not_null",
          "target": null,
          "columns": [
            "item_title"
          ],
          "definition": "NOT NULL item_title",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_scorm_launch_href_not_null",
          "target": null,
          "columns": [
            "launch_href"
          ],
          "definition": "NOT NULL launch_href",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_scorm_launch_present",
          "target": null,
          "columns": [
            "launch_href"
          ],
          "definition": "CHECK (((launch_href = btrim(launch_href)) AND (launch_href <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_scorm_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_scorm_object_present",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "CHECK (((object_id = btrim(object_id)) AND (object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_scorm_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_version_scorm_package_fk",
          "target": "scorm_packages",
          "columns": [
            "organisation_id",
            "package_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, package_id) REFERENCES scorm_packages(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_version_scorm_package_id_not_null",
          "target": null,
          "columns": [
            "package_id"
          ],
          "definition": "NOT NULL package_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_version_scorm_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, course_version_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_version_scorm_sha256",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "CHECK ((octet_length(sha256) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_scorm_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_version_scorm_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "course_version_scorm_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00027_scorm_packages.sql"
      ]
    },
    {
      "rls": true,
      "name": "course_versions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version_number",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "source_revision",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "published_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "metadata",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "course_versions_number_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_id",
            "version_number"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_versions_number_once ON public.course_versions USING btree (organisation_id, course_id, version_number)"
        },
        {
          "name": "course_versions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX course_versions_pkey ON public.course_versions USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "course_versions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "course_versions_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "course_versions_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_versions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_versions_metadata_not_null",
          "target": null,
          "columns": [
            "metadata"
          ],
          "definition": "NOT NULL metadata",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "course_versions_number_once",
          "target": null,
          "columns": [
            "organisation_id",
            "course_id",
            "version_number"
          ],
          "definition": "UNIQUE (organisation_id, course_id, version_number)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_versions_number_positive",
          "target": null,
          "columns": [
            "version_number"
          ],
          "definition": "CHECK ((version_number > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_versions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "course_versions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_versions_published_at_not_null",
          "target": null,
          "columns": [
            "published_at"
          ],
          "definition": "NOT NULL published_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_versions_source_positive",
          "target": null,
          "columns": [
            "source_revision"
          ],
          "definition": "CHECK ((source_revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_versions_source_revision_not_null",
          "target": null,
          "columns": [
            "source_revision"
          ],
          "definition": "NOT NULL source_revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_versions_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "course_versions_title_present",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((title = btrim(title)) AND (title <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "course_versions_version_number_not_null",
          "target": null,
          "columns": [
            "version_number"
          ],
          "definition": "NOT NULL version_number",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00010_course_versions.sql",
        "migrations/00011_enrolments.sql",
        "migrations/00012_quarantine.sql",
        "migrations/00017_media_renditions.sql",
        "migrations/00027_scorm_packages.sql",
        "migrations/00028_scorm_launch_registrations.sql",
        "migrations/00030_dispatch_destinations.sql",
        "migrations/00031_dispatch_registrations.sql",
        "migrations/00035_native_workspace.sql",
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "courses",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "metadata",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "courses_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX courses_pkey ON public.courses USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "courses_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "courses_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "courses_metadata_not_null",
          "target": null,
          "columns": [
            "metadata"
          ],
          "definition": "NOT NULL metadata",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "courses_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "courses_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "courses_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "courses_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "courses_revision_positive",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "courses_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "courses_title_present",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((title = btrim(title)) AND (title <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00009_drafts.sql",
        "migrations/00010_course_versions.sql",
        "migrations/00011_enrolments.sql",
        "migrations/00012_quarantine.sql",
        "migrations/00017_media_renditions.sql",
        "migrations/00020_refresher_schedule.sql",
        "migrations/00027_scorm_packages.sql",
        "migrations/00030_dispatch_destinations.sql",
        "migrations/00035_native_workspace.sql",
        "migrations/00043_course_bookmarks.sql",
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "dispatch_deployments",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "destination_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "dispatch_deployments_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_deployments_pkey ON public.dispatch_deployments USING btree (organisation_id, id)"
        },
        {
          "name": "dispatch_deployments_revision_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "destination_id",
            "course_id",
            "revision"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_deployments_revision_once ON public.dispatch_deployments USING btree (organisation_id, destination_id, course_id, revision)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "dispatch_deployments_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "dispatch_deployments_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "dispatch_deployments_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_deployments_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_deployments_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_deployments_destination_fk",
          "target": "dispatch_destinations",
          "columns": [
            "organisation_id",
            "destination_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, destination_id) REFERENCES dispatch_destinations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "dispatch_deployments_destination_id_not_null",
          "target": null,
          "columns": [
            "destination_id"
          ],
          "definition": "NOT NULL destination_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_deployments_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_deployments_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "dispatch_deployments_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_deployments_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "dispatch_deployments_revision_once",
          "target": null,
          "columns": [
            "organisation_id",
            "destination_id",
            "course_id",
            "revision"
          ],
          "definition": "UNIQUE (organisation_id, destination_id, course_id, revision)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_deployments_revision_positive",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_deployments_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00030_dispatch_destinations.sql",
        "migrations/00031_dispatch_registrations.sql"
      ]
    },
    {
      "rls": true,
      "name": "dispatch_destinations",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "approved_origins",
          "type": "text[]",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "credential_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "credential_version",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enabled",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "dispatch_destinations_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_destinations_pkey ON public.dispatch_destinations USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "dispatch_destinations_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "dispatch_destinations_approved_origins_not_null",
          "target": null,
          "columns": [
            "approved_origins"
          ],
          "definition": "NOT NULL approved_origins",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_destinations_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_destinations_credential",
          "target": null,
          "columns": [
            "credential_hash"
          ],
          "definition": "CHECK ((octet_length(credential_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_destinations_credential_hash_not_null",
          "target": null,
          "columns": [
            "credential_hash"
          ],
          "definition": "NOT NULL credential_hash",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_destinations_credential_version",
          "target": null,
          "columns": [
            "credential_version"
          ],
          "definition": "CHECK ((credential_version > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_destinations_credential_version_not_null",
          "target": null,
          "columns": [
            "credential_version"
          ],
          "definition": "NOT NULL credential_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_destinations_enabled_not_null",
          "target": null,
          "columns": [
            "enabled"
          ],
          "definition": "NOT NULL enabled",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_destinations_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_destinations_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_destinations_name_present",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "CHECK (((name = btrim(name)) AND (name <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_destinations_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_destinations_origins",
          "target": null,
          "columns": [
            "approved_origins"
          ],
          "definition": "CHECK ((cardinality(approved_origins) > 0))",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "dispatch_destinations_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00030_dispatch_destinations.sql",
        "migrations/00031_dispatch_registrations.sql"
      ]
    },
    {
      "rls": true,
      "name": "dispatch_external_learners",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "destination_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "external_learner_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "dispatch_external_learners_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "destination_id",
            "external_learner_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_external_learners_pkey ON public.dispatch_external_learners USING btree (organisation_id, destination_id, external_learner_id)"
        },
        {
          "name": "dispatch_external_user_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_external_user_once ON public.dispatch_external_learners USING btree (organisation_id, user_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "dispatch_external_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "dispatch_external_destination_fk",
          "target": "dispatch_destinations",
          "columns": [
            "organisation_id",
            "destination_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, destination_id) REFERENCES dispatch_destinations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "c",
          "name": "dispatch_external_learner_present",
          "target": null,
          "columns": [
            "external_learner_id"
          ],
          "definition": "CHECK (((external_learner_id = btrim(external_learner_id)) AND (external_learner_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_external_learners_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_external_learners_destination_id_not_null",
          "target": null,
          "columns": [
            "destination_id"
          ],
          "definition": "NOT NULL destination_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_external_learners_external_learner_id_not_null",
          "target": null,
          "columns": [
            "external_learner_id"
          ],
          "definition": "NOT NULL external_learner_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_external_learners_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "dispatch_external_learners_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "destination_id",
            "external_learner_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, destination_id, external_learner_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_external_learners_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_external_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "u",
          "name": "dispatch_external_user_once",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "UNIQUE (organisation_id, user_id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00031_dispatch_registrations.sql"
      ]
    },
    {
      "rls": true,
      "name": "dispatch_grants",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "capability_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "destination_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "deployment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "external_learner_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "external_attempt_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "redeemed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "dispatch_grants_hash_once",
          "unique": true,
          "columns": [
            "capability_hash"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_grants_hash_once ON public.dispatch_grants USING btree (capability_hash)"
        },
        {
          "name": "dispatch_grants_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_grants_pkey ON public.dispatch_grants USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "dispatch_grants_by_hash",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "(capability_hash = decode(NULLIF(current_setting('app.dispatch_grant_hash'::text, true), ''::text), 'hex'::text))",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "dispatch_grants_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "dispatch_grants_attempt_present",
          "target": null,
          "columns": [
            "external_attempt_id"
          ],
          "definition": "CHECK (((external_attempt_id = btrim(external_attempt_id)) AND (external_attempt_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_grants_capability_hash_not_null",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "NOT NULL capability_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_grants_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_grants_deployment_fk",
          "target": "dispatch_deployments",
          "columns": [
            "organisation_id",
            "deployment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, deployment_id) REFERENCES dispatch_deployments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "dispatch_grants_deployment_id_not_null",
          "target": null,
          "columns": [
            "deployment_id"
          ],
          "definition": "NOT NULL deployment_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_grants_destination_fk",
          "target": "dispatch_destinations",
          "columns": [
            "organisation_id",
            "destination_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, destination_id) REFERENCES dispatch_destinations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "dispatch_grants_destination_id_not_null",
          "target": null,
          "columns": [
            "destination_id"
          ],
          "definition": "NOT NULL destination_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_grants_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_grants_external_attempt_id_not_null",
          "target": null,
          "columns": [
            "external_attempt_id"
          ],
          "definition": "NOT NULL external_attempt_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_grants_external_learner_id_not_null",
          "target": null,
          "columns": [
            "external_learner_id"
          ],
          "definition": "NOT NULL external_learner_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "dispatch_grants_hash_once",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "UNIQUE (capability_hash)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_grants_hash_present",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "CHECK ((octet_length(capability_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_grants_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_grants_learner_present",
          "target": null,
          "columns": [
            "external_learner_id"
          ],
          "definition": "CHECK (((external_learner_id = btrim(external_learner_id)) AND (external_learner_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_grants_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "dispatch_grants_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00031_dispatch_registrations.sql"
      ]
    },
    {
      "rls": true,
      "name": "dispatch_launcher_packages",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "deployment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "dispatch_launcher_packages_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_launcher_packages_pkey ON public.dispatch_launcher_packages USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "dispatch_launcher_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "dispatch_launcher_bytes",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length > 0))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_launcher_deployment_fk",
          "target": "dispatch_deployments",
          "columns": [
            "organisation_id",
            "deployment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, deployment_id) REFERENCES dispatch_deployments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "dispatch_launcher_packages_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_launcher_packages_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_launcher_packages_deployment_id_not_null",
          "target": null,
          "columns": [
            "deployment_id"
          ],
          "definition": "NOT NULL deployment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_launcher_packages_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_launcher_packages_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "dispatch_launcher_packages_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_launcher_packages_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_launcher_sha256",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "CHECK ((octet_length(sha256) = 32))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00030_dispatch_destinations.sql"
      ]
    },
    {
      "rls": true,
      "name": "dispatch_registrations",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "destination_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "deployment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "external_learner_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "external_attempt_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "deployment_revision",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "dispatch_reg_tuple_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "destination_id",
            "external_learner_id",
            "deployment_id",
            "external_attempt_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_reg_tuple_once ON public.dispatch_registrations USING btree (organisation_id, destination_id, external_learner_id, deployment_id, external_attempt_id)"
        },
        {
          "name": "dispatch_registrations_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_registrations_pkey ON public.dispatch_registrations USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "dispatch_reg_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "dispatch_reg_deployment_fk",
          "target": "dispatch_deployments",
          "columns": [
            "organisation_id",
            "deployment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, deployment_id) REFERENCES dispatch_deployments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "dispatch_reg_destination_fk",
          "target": "dispatch_destinations",
          "columns": [
            "organisation_id",
            "destination_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, destination_id) REFERENCES dispatch_destinations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "dispatch_reg_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "u",
          "name": "dispatch_reg_tuple_once",
          "target": null,
          "columns": [
            "organisation_id",
            "destination_id",
            "external_learner_id",
            "deployment_id",
            "external_attempt_id"
          ],
          "definition": "UNIQUE (organisation_id, destination_id, external_learner_id, deployment_id, external_attempt_id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_reg_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "dispatch_reg_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_deployment_id_not_null",
          "target": null,
          "columns": [
            "deployment_id"
          ],
          "definition": "NOT NULL deployment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_deployment_revision_not_null",
          "target": null,
          "columns": [
            "deployment_revision"
          ],
          "definition": "NOT NULL deployment_revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_destination_id_not_null",
          "target": null,
          "columns": [
            "destination_id"
          ],
          "definition": "NOT NULL destination_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_external_attempt_id_not_null",
          "target": null,
          "columns": [
            "external_attempt_id"
          ],
          "definition": "NOT NULL external_attempt_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_external_learner_id_not_null",
          "target": null,
          "columns": [
            "external_learner_id"
          ],
          "definition": "NOT NULL external_learner_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "dispatch_registrations_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_registrations_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00031_dispatch_registrations.sql",
        "migrations/00032_dispatch_results.sql"
      ]
    },
    {
      "rls": true,
      "name": "dispatch_results",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "registration_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "lesson_status",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "acknowledged_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "dispatch_results_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "registration_id",
            "revision"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX dispatch_results_pkey ON public.dispatch_results USING btree (organisation_id, registration_id, revision)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "dispatch_results_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "dispatch_results_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_results_lesson_status_not_null",
          "target": null,
          "columns": [
            "lesson_status"
          ],
          "definition": "NOT NULL lesson_status",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_results_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "dispatch_results_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "registration_id",
            "revision"
          ],
          "definition": "PRIMARY KEY (organisation_id, registration_id, revision)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "dispatch_results_registration_fk",
          "target": "dispatch_registrations",
          "columns": [
            "organisation_id",
            "registration_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, registration_id) REFERENCES dispatch_registrations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "dispatch_results_registration_id_not_null",
          "target": null,
          "columns": [
            "registration_id"
          ],
          "definition": "NOT NULL registration_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "dispatch_results_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_results_revision_positive",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "dispatch_results_status",
          "target": null,
          "columns": [
            "lesson_status"
          ],
          "definition": "CHECK ((lesson_status = ANY (ARRAY['passed'::text, 'completed'::text, 'failed'::text, 'incomplete'::text, 'browsed'::text, 'not attempted'::text])))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00032_dispatch_results.sql"
      ]
    },
    {
      "rls": true,
      "name": "domains",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "hostname",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "verified",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "domains_one_verified_hostname",
          "unique": true,
          "columns": [
            "hostname"
          ],
          "primary": false,
          "predicate": "verified",
          "definition": "CREATE UNIQUE INDEX domains_one_verified_hostname ON public.domains USING btree (hostname) WHERE verified"
        },
        {
          "name": "domains_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "hostname"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX domains_pkey ON public.domains USING btree (organisation_id, hostname)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "domains_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "domains_verified_lookup",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "verified",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "domains_hostname_not_null",
          "target": null,
          "columns": [
            "hostname"
          ],
          "definition": "NOT NULL hostname",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "domains_normalised",
          "target": null,
          "columns": [
            "hostname"
          ],
          "definition": "CHECK (((hostname = lower(hostname)) AND (hostname = btrim(hostname)) AND (\"right\"(hostname, 1) <> '.'::text) AND (hostname !~ '[[:space:]]'::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "domains_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "domains_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "domains_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "hostname"
          ],
          "definition": "PRIMARY KEY (organisation_id, hostname)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "domains_verified_not_null",
          "target": null,
          "columns": [
            "verified"
          ],
          "definition": "NOT NULL verified",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00003_organisations.sql"
      ]
    },
    {
      "rls": true,
      "name": "enrolment_summaries",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "learner_name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "due_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "access_expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "completed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "refreshed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "enrolment_summaries_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX enrolment_summaries_pkey ON public.enrolment_summaries USING btree (organisation_id, enrolment_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "enrolment_summaries_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "enrolment_summaries_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolment_summaries_course_title_not_null",
          "target": null,
          "columns": [
            "course_title"
          ],
          "definition": "NOT NULL course_title",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "enrolment_summaries_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "enrolment_summaries_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolment_summaries_learner_name_not_null",
          "target": null,
          "columns": [
            "learner_name"
          ],
          "definition": "NOT NULL learner_name",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolment_summaries_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "enrolment_summaries_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, enrolment_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolment_summaries_refreshed_at_not_null",
          "target": null,
          "columns": [
            "refreshed_at"
          ],
          "definition": "NOT NULL refreshed_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "enrolment_summaries_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['assigned'::text, 'in_progress'::text, 'completed'::text, 'expired'::text, 'cancelled'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolment_summaries_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "enrolment_summaries_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "enrolment_summaries_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00021_report_exports.sql"
      ]
    },
    {
      "rls": true,
      "name": "enrolments",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "cycle_number",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "due_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "access_expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "enrolments_cycle_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id",
            "course_id",
            "cycle_number"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX enrolments_cycle_once ON public.enrolments USING btree (organisation_id, user_id, course_id, cycle_number)"
        },
        {
          "name": "enrolments_one_active",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id",
            "course_id"
          ],
          "primary": false,
          "predicate": "(state = ANY (ARRAY['assigned'::text, 'in_progress'::text]))",
          "definition": "CREATE UNIQUE INDEX enrolments_one_active ON public.enrolments USING btree (organisation_id, user_id, course_id) WHERE (state = ANY (ARRAY['assigned'::text, 'in_progress'::text]))"
        },
        {
          "name": "enrolments_people_summary",
          "unique": false,
          "columns": [
            "organisation_id",
            "user_id",
            "state"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX enrolments_people_summary ON public.enrolments USING btree (organisation_id, user_id, state) INCLUDE (due_at)"
        },
        {
          "name": "enrolments_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX enrolments_pkey ON public.enrolments USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "enrolments_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "enrolments_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "enrolments_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolments_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolments_cycle_number_not_null",
          "target": null,
          "columns": [
            "cycle_number"
          ],
          "definition": "NOT NULL cycle_number",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "enrolments_cycle_once",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id",
            "course_id",
            "cycle_number"
          ],
          "definition": "UNIQUE (organisation_id, user_id, course_id, cycle_number)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "enrolments_cycle_positive",
          "target": null,
          "columns": [
            "cycle_number"
          ],
          "definition": "CHECK ((cycle_number > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolments_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolments_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "enrolments_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "enrolments_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['assigned'::text, 'in_progress'::text, 'completed'::text, 'expired'::text, 'cancelled'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "enrolments_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "enrolments_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "enrolments_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "enrolments_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00011_enrolments.sql",
        "migrations/00013_learning_progress.sql",
        "migrations/00014_quiz_attempts.sql",
        "migrations/00015_completions.sql",
        "migrations/00016_media_leases.sql",
        "migrations/00018_certificates.sql",
        "migrations/00021_report_exports.sql",
        "migrations/00028_scorm_launch_registrations.sql",
        "migrations/00029_scorm_cmi_state.sql",
        "migrations/00031_dispatch_registrations.sql",
        "migrations/00034_extensions.sql",
        "migrations/00045_experience.sql",
        "migrations/00049_learning_packages.sql",
        "migrations/00053_collections_pathways.sql",
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": true,
      "name": "experience_deliveries",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "event_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "provider",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": "'queued'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "reason",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "experience_deliveries_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "event_id",
            "provider"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX experience_deliveries_pkey ON public.experience_deliveries USING btree (organisation_id, event_id, provider)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "experience_deliveries_event_id_not_null",
          "target": null,
          "columns": [
            "event_id"
          ],
          "definition": "NOT NULL event_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "experience_deliveries_organisation_id_event_id_fkey",
          "target": "experience_events",
          "columns": [
            "organisation_id",
            "event_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, event_id) REFERENCES experience_events(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "experience_deliveries_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "experience_deliveries_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "event_id",
            "provider"
          ],
          "definition": "PRIMARY KEY (organisation_id, event_id, provider)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_deliveries_provider_not_null",
          "target": null,
          "columns": [
            "provider"
          ],
          "definition": "NOT NULL provider",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_deliveries_reason_not_null",
          "target": null,
          "columns": [
            "reason"
          ],
          "definition": "NOT NULL reason",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "experience_deliveries_state_check",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['queued'::text, 'accepted'::text, 'skipped'::text, 'failed'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_deliveries_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_deliveries_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00045_experience.sql"
      ]
    },
    {
      "rls": true,
      "name": "experience_events",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "actor",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "event_name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "page",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "payload",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "browser_context",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "payload_hash",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "analytics",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "marketing",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "experience_events_actor_time",
          "unique": false,
          "columns": [
            "organisation_id",
            "actor",
            "created_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX experience_events_actor_time ON public.experience_events USING btree (organisation_id, actor, created_at)"
        },
        {
          "name": "experience_events_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX experience_events_pkey ON public.experience_events USING btree (organisation_id, id)"
        },
        {
          "name": "experience_events_recent",
          "unique": false,
          "columns": [
            "organisation_id",
            "created_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX experience_events_recent ON public.experience_events USING btree (organisation_id, created_at DESC)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "experience_events_actor_not_null",
          "target": null,
          "columns": [
            "actor"
          ],
          "definition": "NOT NULL actor",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_analytics_not_null",
          "target": null,
          "columns": [
            "analytics"
          ],
          "definition": "NOT NULL analytics",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_browser_context_not_null",
          "target": null,
          "columns": [
            "browser_context"
          ],
          "definition": "NOT NULL browser_context",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_event_name_not_null",
          "target": null,
          "columns": [
            "event_name"
          ],
          "definition": "NOT NULL event_name",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_marketing_not_null",
          "target": null,
          "columns": [
            "marketing"
          ],
          "definition": "NOT NULL marketing",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_page_not_null",
          "target": null,
          "columns": [
            "page"
          ],
          "definition": "NOT NULL page",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_payload_hash_not_null",
          "target": null,
          "columns": [
            "payload_hash"
          ],
          "definition": "NOT NULL payload_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_events_payload_not_null",
          "target": null,
          "columns": [
            "payload"
          ],
          "definition": "NOT NULL payload",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "experience_events_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00045_experience.sql"
      ]
    },
    {
      "rls": true,
      "name": "experience_preferences",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "actor",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "analytics",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "marketing",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "experience_preferences_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "actor"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX experience_preferences_pkey ON public.experience_preferences USING btree (organisation_id, actor)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "experience_preferences_actor_not_null",
          "target": null,
          "columns": [
            "actor"
          ],
          "definition": "NOT NULL actor",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_preferences_analytics_not_null",
          "target": null,
          "columns": [
            "analytics"
          ],
          "definition": "NOT NULL analytics",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_preferences_marketing_not_null",
          "target": null,
          "columns": [
            "marketing"
          ],
          "definition": "NOT NULL marketing",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_preferences_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "experience_preferences_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "actor"
          ],
          "definition": "PRIMARY KEY (organisation_id, actor)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_preferences_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00045_experience.sql"
      ]
    },
    {
      "rls": true,
      "name": "experience_settings",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "destinations",
          "type": "jsonb",
          "default": "'[]'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "experience_settings_pkey",
          "unique": true,
          "columns": [
            "organisation_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX experience_settings_pkey ON public.experience_settings USING btree (organisation_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "experience_settings_destinations_not_null",
          "target": null,
          "columns": [
            "destinations"
          ],
          "definition": "NOT NULL destinations",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "experience_settings_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "experience_settings_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "experience_settings_pkey",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "PRIMARY KEY (organisation_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "experience_settings_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00045_experience.sql"
      ]
    },
    {
      "rls": true,
      "name": "extension_activity_records",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "extension_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "extension_version",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "payload",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "completed",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "extension_activity_records_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX extension_activity_records_pkey ON public.extension_activity_records USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "extension_activity_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "extension_activity_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "c",
          "name": "extension_activity_id_present",
          "target": null,
          "columns": [
            "extension_id"
          ],
          "definition": "CHECK (((extension_id = btrim(extension_id)) AND (extension_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_completed_not_null",
          "target": null,
          "columns": [
            "completed"
          ],
          "definition": "NOT NULL completed",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_extension_id_not_null",
          "target": null,
          "columns": [
            "extension_id"
          ],
          "definition": "NOT NULL extension_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_extension_version_not_null",
          "target": null,
          "columns": [
            "extension_version"
          ],
          "definition": "NOT NULL extension_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_activity_records_payload_not_null",
          "target": null,
          "columns": [
            "payload"
          ],
          "definition": "NOT NULL payload",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "extension_activity_records_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "extension_activity_version_present",
          "target": null,
          "columns": [
            "extension_version"
          ],
          "definition": "CHECK (((extension_version = btrim(extension_version)) AND (extension_version <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00034_extensions.sql"
      ]
    },
    {
      "rls": true,
      "name": "extension_report_records",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "extension_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "extension_version",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "parameters",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "result",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "extension_report_records_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX extension_report_records_pkey ON public.extension_report_records USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "extension_report_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "extension_report_id_present",
          "target": null,
          "columns": [
            "extension_id"
          ],
          "definition": "CHECK (((extension_id = btrim(extension_id)) AND (extension_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_report_records_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_report_records_extension_id_not_null",
          "target": null,
          "columns": [
            "extension_id"
          ],
          "definition": "NOT NULL extension_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_report_records_extension_version_not_null",
          "target": null,
          "columns": [
            "extension_version"
          ],
          "definition": "NOT NULL extension_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_report_records_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_report_records_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_report_records_parameters_not_null",
          "target": null,
          "columns": [
            "parameters"
          ],
          "definition": "NOT NULL parameters",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "extension_report_records_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "extension_report_records_result_not_null",
          "target": null,
          "columns": [
            "result"
          ],
          "definition": "NOT NULL result",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "extension_report_version_present",
          "target": null,
          "columns": [
            "extension_version"
          ],
          "definition": "CHECK (((extension_version = btrim(extension_version)) AND (extension_version <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00034_extensions.sql"
      ]
    },
    {
      "rls": false,
      "name": "goose_db_version",
      "columns": [
        {
          "name": "id",
          "type": "integer",
          "default": null,
          "identity": "d",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version_id",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "is_applied",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "tstamp",
          "type": "timestamp without time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "goose_db_version_pkey",
          "unique": true,
          "columns": [
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX goose_db_version_pkey ON public.goose_db_version USING btree (id)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "goose_db_version_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "goose_db_version_is_applied_not_null",
          "target": null,
          "columns": [
            "is_applied"
          ],
          "definition": "NOT NULL is_applied",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "goose_db_version_pkey",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "PRIMARY KEY (id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "goose_db_version_tstamp_not_null",
          "target": null,
          "columns": [
            "tstamp"
          ],
          "definition": "NOT NULL tstamp",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "goose_db_version_version_id_not_null",
          "target": null,
          "columns": [
            "version_id"
          ],
          "definition": "NOT NULL version_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": []
    },
    {
      "rls": true,
      "name": "group_memberships",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "group_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "group_memberships_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "group_id",
            "user_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX group_memberships_pkey ON public.group_memberships USING btree (organisation_id, group_id, user_id)"
        },
        {
          "name": "groups_member_user",
          "unique": false,
          "columns": [
            "organisation_id",
            "user_id",
            "group_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX groups_member_user ON public.group_memberships USING btree (organisation_id, user_id, group_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "group_memberships_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "group_memberships_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "group_memberships_group_fk",
          "target": "groups",
          "columns": [
            "organisation_id",
            "group_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, group_id) REFERENCES groups(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "group_memberships_group_id_not_null",
          "target": null,
          "columns": [
            "group_id"
          ],
          "definition": "NOT NULL group_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "group_memberships_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "group_memberships_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "group_id",
            "user_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, group_id, user_id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "group_memberships_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "group_memberships_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00024_scim_groups.sql",
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": true,
      "name": "groups",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "scim_resource_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "description",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "archived",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "groups_name_order",
          "unique": false,
          "columns": [
            "organisation_id",
            null,
            "id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX groups_name_order ON public.groups USING btree (organisation_id, lower(name), id)"
        },
        {
          "name": "groups_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX groups_pkey ON public.groups USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "groups_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "groups_archived_not_null",
          "target": null,
          "columns": [
            "archived"
          ],
          "definition": "NOT NULL archived",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "groups_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "groups_description_not_null",
          "target": null,
          "columns": [
            "description"
          ],
          "definition": "NOT NULL description",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "groups_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "groups_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "groups_name_present",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "CHECK (((name = btrim(name)) AND (name <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "groups_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "groups_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "groups_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "groups_revision_check",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "groups_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "groups_scim_fk",
          "target": "scim_resources",
          "columns": [
            "organisation_id",
            "scim_resource_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, scim_resource_id) REFERENCES scim_resources(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00024_scim_groups.sql",
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": true,
      "name": "identity_links",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "issuer",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "subject",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "identity_links_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "issuer",
            "subject"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX identity_links_pkey ON public.identity_links USING btree (organisation_id, issuer, subject)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "identity_links_for_subject",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "((current_setting('app.identity_issuer'::text, true) <> ''::text) AND (issuer = current_setting('app.identity_issuer'::text, true)) AND (subject = current_setting('app.identity_subject'::text, true)))",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "identity_links_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "identity_links_issuer_not_null",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "NOT NULL issuer",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "identity_links_issuer_present",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "CHECK (((issuer = btrim(issuer)) AND (issuer <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "identity_links_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "identity_links_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "issuer",
            "subject"
          ],
          "definition": "PRIMARY KEY (organisation_id, issuer, subject)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "identity_links_subject_not_null",
          "target": null,
          "columns": [
            "subject"
          ],
          "definition": "NOT NULL subject",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "identity_links_subject_present",
          "target": null,
          "columns": [
            "subject"
          ],
          "definition": "CHECK (((subject = btrim(subject)) AND (subject <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "identity_links_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "identity_links_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00004_identity.sql",
        "migrations/00008_profiles.sql"
      ]
    },
    {
      "rls": true,
      "name": "invitations",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "token_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "connection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_authz_version",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "connection_version",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_by",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "consumed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "invitations_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX invitations_pkey ON public.invitations USING btree (organisation_id, id)"
        },
        {
          "name": "invitations_token_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "token_hash"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX invitations_token_once ON public.invitations USING btree (organisation_id, token_hash)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "invitations_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "invitations_connection_fk",
          "target": "oidc_connections",
          "columns": [
            "organisation_id",
            "connection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, connection_id) REFERENCES oidc_connections(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "invitations_connection_id_not_null",
          "target": null,
          "columns": [
            "connection_id"
          ],
          "definition": "NOT NULL connection_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "invitations_connection_version_not_null",
          "target": null,
          "columns": [
            "connection_version"
          ],
          "definition": "NOT NULL connection_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "invitations_created_by_not_null",
          "target": null,
          "columns": [
            "created_by"
          ],
          "definition": "NOT NULL created_by",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "invitations_creator_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "created_by"
          ],
          "definition": "FOREIGN KEY (organisation_id, created_by) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "invitations_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "invitations_hash_present",
          "target": null,
          "columns": [
            "token_hash"
          ],
          "definition": "CHECK ((octet_length(token_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "invitations_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "invitations_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "invitations_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "invitations_token_hash_not_null",
          "target": null,
          "columns": [
            "token_hash"
          ],
          "definition": "NOT NULL token_hash",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "invitations_token_once",
          "target": null,
          "columns": [
            "organisation_id",
            "token_hash"
          ],
          "definition": "UNIQUE (organisation_id, token_hash)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "invitations_user_authz_version_not_null",
          "target": null,
          "columns": [
            "user_authz_version"
          ],
          "definition": "NOT NULL user_authz_version",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "invitations_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "invitations_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00006_invitations.sql"
      ]
    },
    {
      "rls": true,
      "name": "learning_package_attempts",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "package_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt",
          "type": "integer",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "data",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "finished",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "learning_package_attempts_organisation_id_enrolment_id_acti_key",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id",
            "attempt"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_package_attempts_organisation_id_enrolment_id_acti_key ON public.learning_package_attempts USING btree (organisation_id, enrolment_id, activity_id, attempt)"
        },
        {
          "name": "learning_package_attempts_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_package_attempts_pkey ON public.learning_package_attempts USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "learning_package_attempts_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_attempt_not_null",
          "target": null,
          "columns": [
            "attempt"
          ],
          "definition": "NOT NULL attempt",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_data_not_null",
          "target": null,
          "columns": [
            "data"
          ],
          "definition": "NOT NULL data",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_finished_not_null",
          "target": null,
          "columns": [
            "finished"
          ],
          "definition": "NOT NULL finished",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_package_attempts_organisation_id_activity_id_fkey",
          "target": "course_version_activities",
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, activity_id) REFERENCES course_version_activities(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "u",
          "name": "learning_package_attempts_organisation_id_enrolment_id_acti_key",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id",
            "attempt"
          ],
          "definition": "UNIQUE (organisation_id, enrolment_id, activity_id, attempt)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_package_attempts_organisation_id_enrolment_id_fkey",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_package_attempts_organisation_id_package_id_fkey",
          "target": "learning_packages",
          "columns": [
            "organisation_id",
            "package_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, package_id) REFERENCES learning_packages(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "learning_package_attempts_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_package_id_not_null",
          "target": null,
          "columns": [
            "package_id"
          ],
          "definition": "NOT NULL package_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "learning_package_attempts_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_attempts_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00049_learning_packages.sql"
      ]
    },
    {
      "rls": true,
      "name": "learning_package_launches",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "token_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "package_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "preview",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "initial_data",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "session_centiseconds",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "last_sequence",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "last_hash",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "finished",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "session_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "learning_package_launches_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_package_launches_pkey ON public.learning_package_launches USING btree (organisation_id, id)"
        },
        {
          "name": "learning_package_launches_token_hash_key",
          "unique": true,
          "columns": [
            "token_hash"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_package_launches_token_hash_key ON public.learning_package_launches USING btree (token_hash)"
        },
        {
          "name": "learning_package_live",
          "unique": false,
          "columns": [
            "organisation_id",
            "attempt_id",
            "expires_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX learning_package_live ON public.learning_package_launches USING btree (organisation_id, attempt_id, expires_at)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "learning_package_launches_check",
          "target": null,
          "columns": [
            "preview",
            "attempt_id"
          ],
          "definition": "CHECK ((preview = (attempt_id IS NULL)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_finished_not_null",
          "target": null,
          "columns": [
            "finished"
          ],
          "definition": "NOT NULL finished",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_initial_data_not_null",
          "target": null,
          "columns": [
            "initial_data"
          ],
          "definition": "NOT NULL initial_data",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_last_hash_not_null",
          "target": null,
          "columns": [
            "last_hash"
          ],
          "definition": "NOT NULL last_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_last_sequence_not_null",
          "target": null,
          "columns": [
            "last_sequence"
          ],
          "definition": "NOT NULL last_sequence",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_package_launches_organisation_id_attempt_id_fkey",
          "target": "learning_package_attempts",
          "columns": [
            "organisation_id",
            "attempt_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, attempt_id) REFERENCES learning_package_attempts(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_package_launches_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_package_launches_organisation_id_package_id_fkey",
          "target": "learning_packages",
          "columns": [
            "organisation_id",
            "package_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, package_id) REFERENCES learning_packages(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "learning_package_launches_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_package_launches_package_id_not_null",
          "target": null,
          "columns": [
            "package_id"
          ],
          "definition": "NOT NULL package_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "learning_package_launches_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_preview_not_null",
          "target": null,
          "columns": [
            "preview"
          ],
          "definition": "NOT NULL preview",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_revoked_not_null",
          "target": null,
          "columns": [
            "revoked"
          ],
          "definition": "NOT NULL revoked",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_session_centiseconds_not_null",
          "target": null,
          "columns": [
            "session_centiseconds"
          ],
          "definition": "NOT NULL session_centiseconds",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_package_launches_session_hash_check",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "CHECK ((octet_length(session_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_session_hash_not_null",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "NOT NULL session_hash",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_package_launches_token_hash_check",
          "target": null,
          "columns": [
            "token_hash"
          ],
          "definition": "CHECK ((octet_length(token_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "learning_package_launches_token_hash_key",
          "target": null,
          "columns": [
            "token_hash"
          ],
          "definition": "UNIQUE (token_hash)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_token_hash_not_null",
          "target": null,
          "columns": [
            "token_hash"
          ],
          "definition": "NOT NULL token_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_package_launches_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00049_learning_packages.sql"
      ]
    },
    {
      "rls": true,
      "name": "learning_packages",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "family_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "filename",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "launch_href",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_by",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "request_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "learning_packages_organisation_id_family_id_version_key",
          "unique": true,
          "columns": [
            "organisation_id",
            "family_id",
            "version"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_packages_organisation_id_family_id_version_key ON public.learning_packages USING btree (organisation_id, family_id, version)"
        },
        {
          "name": "learning_packages_organisation_id_request_id_key",
          "unique": true,
          "columns": [
            "organisation_id",
            "request_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_packages_organisation_id_request_id_key ON public.learning_packages USING btree (organisation_id, request_id)"
        },
        {
          "name": "learning_packages_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_packages_pkey ON public.learning_packages USING btree (organisation_id, id)"
        },
        {
          "name": "learning_packages_recent",
          "unique": false,
          "columns": [
            "organisation_id",
            "created_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX learning_packages_recent ON public.learning_packages USING btree (organisation_id, created_at DESC)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "learning_packages_byte_length_check",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_created_by_not_null",
          "target": null,
          "columns": [
            "created_by"
          ],
          "definition": "NOT NULL created_by",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_family_id_not_null",
          "target": null,
          "columns": [
            "family_id"
          ],
          "definition": "NOT NULL family_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_filename_not_null",
          "target": null,
          "columns": [
            "filename"
          ],
          "definition": "NOT NULL filename",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_launch_href_not_null",
          "target": null,
          "columns": [
            "launch_href"
          ],
          "definition": "NOT NULL launch_href",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_packages_organisation_id_created_by_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "created_by"
          ],
          "definition": "FOREIGN KEY (organisation_id, created_by) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "u",
          "name": "learning_packages_organisation_id_family_id_version_key",
          "target": null,
          "columns": [
            "organisation_id",
            "family_id",
            "version"
          ],
          "definition": "UNIQUE (organisation_id, family_id, version)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_packages_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_packages_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "learning_packages_organisation_id_request_id_key",
          "target": null,
          "columns": [
            "organisation_id",
            "request_id"
          ],
          "definition": "UNIQUE (organisation_id, request_id)",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "learning_packages_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_request_id_not_null",
          "target": null,
          "columns": [
            "request_id"
          ],
          "definition": "NOT NULL request_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_packages_state_check",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['validated'::text, 'ready'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_packages_version_check",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "CHECK ((version > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_packages_version_not_null",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "NOT NULL version",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00049_learning_packages.sql"
      ]
    },
    {
      "rls": true,
      "name": "learning_pathways",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "draft",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "archived",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "learning_pathways_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_pathways_pkey ON public.learning_pathways USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "learning_pathways_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "learning_pathways_archived_not_null",
          "target": null,
          "columns": [
            "archived"
          ],
          "definition": "NOT NULL archived",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_pathways_draft_not_null",
          "target": null,
          "columns": [
            "draft"
          ],
          "definition": "NOT NULL draft",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_pathways_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_pathways_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_pathways_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "learning_pathways_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_pathways_revision_check",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_pathways_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "learning_resources",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "summary",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "category",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "kind",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "body",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "archived",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "learning_resources_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_resources_pkey ON public.learning_resources USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "learning_resources_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "learning_resources_archived_not_null",
          "target": null,
          "columns": [
            "archived"
          ],
          "definition": "NOT NULL archived",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_resources_body_check",
          "target": null,
          "columns": [
            "body"
          ],
          "definition": "CHECK (((length(body) >= 1) AND (length(body) <= 30000)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_body_not_null",
          "target": null,
          "columns": [
            "body"
          ],
          "definition": "NOT NULL body",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_resources_category_check",
          "target": null,
          "columns": [
            "category"
          ],
          "definition": "CHECK (((length(category) >= 1) AND (length(category) <= 60)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_category_not_null",
          "target": null,
          "columns": [
            "category"
          ],
          "definition": "NOT NULL category",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_resources_kind_check",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "CHECK ((kind = ANY (ARRAY['guide'::text, 'checklist'::text, 'template'::text, 'policy'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_kind_not_null",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "NOT NULL kind",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_resources_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_resources_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "learning_resources_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_resources_revision_check",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_resources_summary_check",
          "target": null,
          "columns": [
            "summary"
          ],
          "definition": "CHECK ((length(summary) <= 600))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_summary_not_null",
          "target": null,
          "columns": [
            "summary"
          ],
          "definition": "NOT NULL summary",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "learning_resources_title_check",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((length(title) >= 1) AND (length(title) <= 160)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_resources_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00042_resource_library.sql"
      ]
    },
    {
      "rls": true,
      "name": "learning_sessions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "closed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "learning_sessions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX learning_sessions_pkey ON public.learning_sessions USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "learning_sessions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "learning_sessions_closed",
          "target": null,
          "columns": [
            "closed_at",
            "created_at"
          ],
          "definition": "CHECK (((closed_at IS NULL) OR (closed_at >= created_at)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_sessions_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_sessions_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_sessions_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_sessions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "learning_sessions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "learning_sessions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "learning_sessions_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "learning_sessions_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00013_learning_progress.sql",
        "migrations/00016_media_leases.sql",
        "migrations/00029_scorm_cmi_state.sql"
      ]
    },
    {
      "rls": true,
      "name": "media_assets",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "quarantine_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "source_object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "lease_generation",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "winning_attempt_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "ready_master_object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "media_assets_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX media_assets_pkey ON public.media_assets USING btree (organisation_id, id)"
        },
        {
          "name": "media_assets_quarantine_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "quarantine_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX media_assets_quarantine_once ON public.media_assets USING btree (organisation_id, quarantine_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "media_assets_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "media_assets_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_assets_generation",
          "target": null,
          "columns": [
            "lease_generation"
          ],
          "definition": "CHECK ((lease_generation >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_assets_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_assets_lease_generation_not_null",
          "target": null,
          "columns": [
            "lease_generation"
          ],
          "definition": "NOT NULL lease_generation",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_assets_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "media_assets_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "media_assets_quarantine_fk",
          "target": "quarantine_uploads",
          "columns": [
            "organisation_id",
            "quarantine_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, quarantine_id) REFERENCES quarantine_uploads(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "media_assets_quarantine_id_not_null",
          "target": null,
          "columns": [
            "quarantine_id"
          ],
          "definition": "NOT NULL quarantine_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "media_assets_quarantine_once",
          "target": null,
          "columns": [
            "organisation_id",
            "quarantine_id"
          ],
          "definition": "UNIQUE (organisation_id, quarantine_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_assets_ready_master",
          "target": null,
          "columns": [
            "state",
            "winning_attempt_id",
            "ready_master_object_id"
          ],
          "definition": "CHECK ((((state = 'ready'::text) AND (winning_attempt_id IS NOT NULL) AND (ready_master_object_id IS NOT NULL)) OR ((state <> 'ready'::text) AND (winning_attempt_id IS NULL) AND (ready_master_object_id IS NULL))))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_assets_source_object_id_not_null",
          "target": null,
          "columns": [
            "source_object_id"
          ],
          "definition": "NOT NULL source_object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_assets_source_present",
          "target": null,
          "columns": [
            "source_object_id"
          ],
          "definition": "CHECK (((source_object_id = btrim(source_object_id)) AND (source_object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_assets_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['queued'::text, 'processing'::text, 'ready'::text, 'failed'::text, 'cancelled'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_assets_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_assets_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "media_assets_winning_attempt_fk",
          "target": "media_attempts",
          "columns": [
            "organisation_id",
            "winning_attempt_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, winning_attempt_id) REFERENCES media_attempts(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00017_media_renditions.sql"
      ]
    },
    {
      "rls": true,
      "name": "media_attempt_objects",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "role",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "media_attempt_objects_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "attempt_id",
            "object_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX media_attempt_objects_pkey ON public.media_attempt_objects USING btree (organisation_id, attempt_id, object_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "media_attempt_objects_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "media_attempt_objects_attempt_fk",
          "target": "media_attempts",
          "columns": [
            "organisation_id",
            "attempt_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, attempt_id) REFERENCES media_attempts(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "media_attempt_objects_attempt_id_not_null",
          "target": null,
          "columns": [
            "attempt_id"
          ],
          "definition": "NOT NULL attempt_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_attempt_objects_byte_length",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempt_objects_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempt_objects_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_attempt_objects_object_present",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "CHECK (((object_id = btrim(object_id)) AND (object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempt_objects_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "media_attempt_objects_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "attempt_id",
            "object_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, attempt_id, object_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_attempt_objects_role",
          "target": null,
          "columns": [
            "role"
          ],
          "definition": "CHECK ((role = ANY (ARRAY['master'::text, 'playlist'::text, 'init'::text, 'segment'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempt_objects_role_not_null",
          "target": null,
          "columns": [
            "role"
          ],
          "definition": "NOT NULL role",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_attempt_objects_sha256",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "CHECK ((octet_length(sha256) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempt_objects_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00017_media_renditions.sql"
      ]
    },
    {
      "rls": true,
      "name": "media_attempts",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "media_asset_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "generation",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "profile_version",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "diagnostic_code",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "finished_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "media_attempts_generation_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "media_asset_id",
            "generation"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX media_attempts_generation_once ON public.media_attempts USING btree (organisation_id, media_asset_id, generation)"
        },
        {
          "name": "media_attempts_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX media_attempts_pkey ON public.media_attempts USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "media_attempts_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "media_attempts_asset_fk",
          "target": "media_assets",
          "columns": [
            "organisation_id",
            "media_asset_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, media_asset_id) REFERENCES media_assets(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "media_attempts_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_attempts_generation",
          "target": null,
          "columns": [
            "generation"
          ],
          "definition": "CHECK ((generation > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempts_generation_not_null",
          "target": null,
          "columns": [
            "generation"
          ],
          "definition": "NOT NULL generation",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "media_attempts_generation_once",
          "target": null,
          "columns": [
            "organisation_id",
            "media_asset_id",
            "generation"
          ],
          "definition": "UNIQUE (organisation_id, media_asset_id, generation)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempts_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempts_media_asset_id_not_null",
          "target": null,
          "columns": [
            "media_asset_id"
          ],
          "definition": "NOT NULL media_asset_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempts_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "media_attempts_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_attempts_profile",
          "target": null,
          "columns": [
            "profile_version"
          ],
          "definition": "CHECK (((profile_version = btrim(profile_version)) AND (profile_version <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempts_profile_version_not_null",
          "target": null,
          "columns": [
            "profile_version"
          ],
          "definition": "NOT NULL profile_version",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_attempts_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['processing'::text, 'complete'::text, 'failed'::text, 'stale'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_attempts_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00017_media_renditions.sql"
      ]
    },
    {
      "rls": true,
      "name": "media_leases",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "capability_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "purpose",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "session_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "media_leases_hash_once",
          "unique": true,
          "columns": [
            "capability_hash"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX media_leases_hash_once ON public.media_leases USING btree (capability_hash)"
        },
        {
          "name": "media_leases_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX media_leases_pkey ON public.media_leases USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "media_leases_by_hash",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "(capability_hash = decode(NULLIF(current_setting('app.media_capability_hash'::text, true), ''::text), 'hex'::text))",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "media_leases_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "media_leases_capability_hash_not_null",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "NOT NULL capability_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_leases_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "media_leases_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "media_leases_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_leases_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "media_leases_hash_once",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "UNIQUE (capability_hash)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_leases_hash_present",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "CHECK ((octet_length(capability_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_leases_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_leases_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_leases_object_present",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "CHECK (((object_id = btrim(object_id)) AND (object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_leases_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "media_leases_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "media_leases_purpose",
          "target": null,
          "columns": [
            "purpose"
          ],
          "definition": "CHECK ((purpose = 'learning'::text))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "media_leases_purpose_not_null",
          "target": null,
          "columns": [
            "purpose"
          ],
          "definition": "NOT NULL purpose",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "media_leases_session_fk",
          "target": "learning_sessions",
          "columns": [
            "organisation_id",
            "session_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, session_id) REFERENCES learning_sessions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "media_leases_session_id_not_null",
          "target": null,
          "columns": [
            "session_id"
          ],
          "definition": "NOT NULL session_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "media_leases_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "media_leases_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00016_media_leases.sql"
      ]
    },
    {
      "rls": true,
      "name": "message_deliveries",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "message_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "channel",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "reason",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "read_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "message_deliveries_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "message_id",
            "user_id",
            "channel"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX message_deliveries_pkey ON public.message_deliveries USING btree (organisation_id, message_id, user_id, channel)"
        },
        {
          "name": "message_deliveries_recipient",
          "unique": false,
          "columns": [
            "organisation_id",
            "user_id",
            "message_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX message_deliveries_recipient ON public.message_deliveries USING btree (organisation_id, user_id, message_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "message_deliveries_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "message_deliveries_channel_check",
          "target": null,
          "columns": [
            "channel"
          ],
          "definition": "CHECK ((channel = ANY (ARRAY['in_app'::text, 'email'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_deliveries_channel_not_null",
          "target": null,
          "columns": [
            "channel"
          ],
          "definition": "NOT NULL channel",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_deliveries_message_id_not_null",
          "target": null,
          "columns": [
            "message_id"
          ],
          "definition": "NOT NULL message_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "message_deliveries_organisation_id_message_id_fkey",
          "target": "messages",
          "columns": [
            "organisation_id",
            "message_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, message_id) REFERENCES messages(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "message_deliveries_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "message_deliveries_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "message_deliveries_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "message_id",
            "user_id",
            "channel"
          ],
          "definition": "PRIMARY KEY (organisation_id, message_id, user_id, channel)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_deliveries_reason_not_null",
          "target": null,
          "columns": [
            "reason"
          ],
          "definition": "NOT NULL reason",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "message_deliveries_state_check",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['available'::text, 'queued'::text, 'accepted'::text, 'failed'::text, 'skipped'::text, 'uncertain'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_deliveries_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_deliveries_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_deliveries_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00044_messaging.sql"
      ]
    },
    {
      "rls": true,
      "name": "message_preferences",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "email",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "message_preferences_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX message_preferences_pkey ON public.message_preferences USING btree (organisation_id, user_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "message_preferences_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "message_preferences_email_not_null",
          "target": null,
          "columns": [
            "email"
          ],
          "definition": "NOT NULL email",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_preferences_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "message_preferences_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "message_preferences_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, user_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "message_preferences_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00044_messaging.sql"
      ]
    },
    {
      "rls": true,
      "name": "messages",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sender_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "subject",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "body",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": "'draft'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "recipients",
          "type": "uuid[]",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "channels",
          "type": "text[]",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sent_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "messages_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX messages_pkey ON public.messages USING btree (organisation_id, id)"
        },
        {
          "name": "messages_sender",
          "unique": false,
          "columns": [
            "organisation_id",
            "sender_id",
            "created_at",
            "id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX messages_sender ON public.messages USING btree (organisation_id, sender_id, created_at DESC, id DESC)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "messages_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "messages_body_check",
          "target": null,
          "columns": [
            "body"
          ],
          "definition": "CHECK (((length(body) >= 1) AND (length(body) <= 8000)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_body_not_null",
          "target": null,
          "columns": [
            "body"
          ],
          "definition": "NOT NULL body",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_channels_not_null",
          "target": null,
          "columns": [
            "channels"
          ],
          "definition": "NOT NULL channels",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "messages_organisation_id_sender_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "sender_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, sender_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "messages_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_recipients_not_null",
          "target": null,
          "columns": [
            "recipients"
          ],
          "definition": "NOT NULL recipients",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "messages_revision_check",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_sender_id_not_null",
          "target": null,
          "columns": [
            "sender_id"
          ],
          "definition": "NOT NULL sender_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "messages_state_check",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['draft'::text, 'sent'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "messages_subject_check",
          "target": null,
          "columns": [
            "subject"
          ],
          "definition": "CHECK (((length(subject) >= 1) AND (length(subject) <= 160)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_subject_not_null",
          "target": null,
          "columns": [
            "subject"
          ],
          "definition": "NOT NULL subject",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "messages_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00044_messaging.sql"
      ]
    },
    {
      "rls": true,
      "name": "modules",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "summary",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "modules_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX modules_pkey ON public.modules USING btree (organisation_id, id)"
        },
        {
          "name": "modules_position_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_id",
            "position"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX modules_position_once ON public.modules USING btree (organisation_id, course_id, \"position\")"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "modules_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "modules_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "modules_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "modules_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "modules_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "modules_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "modules_position_nonnegative",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "CHECK ((\"position\" >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "modules_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "modules_position_once",
          "target": null,
          "columns": [
            "organisation_id",
            "course_id",
            "position"
          ],
          "definition": "UNIQUE (organisation_id, course_id, \"position\")",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "modules_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "modules_revision_positive",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "CHECK ((revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "modules_summary_not_null",
          "target": null,
          "columns": [
            "summary"
          ],
          "definition": "NOT NULL summary",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "modules_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "modules_title_present",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((title = btrim(title)) AND (title <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00009_drafts.sql",
        "migrations/00046_course_builder.sql"
      ]
    },
    {
      "rls": true,
      "name": "oidc_connections",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "issuer",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enabled",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "required_assurance",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "oidc_connections_issuer_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "issuer"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX oidc_connections_issuer_once ON public.oidc_connections USING btree (organisation_id, issuer)"
        },
        {
          "name": "oidc_connections_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX oidc_connections_pkey ON public.oidc_connections USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "oidc_connections_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "oidc_connections_enabled_not_null",
          "target": null,
          "columns": [
            "enabled"
          ],
          "definition": "NOT NULL enabled",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_connections_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_connections_issuer_not_null",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "NOT NULL issuer",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "oidc_connections_issuer_once",
          "target": null,
          "columns": [
            "organisation_id",
            "issuer"
          ],
          "definition": "UNIQUE (organisation_id, issuer)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "oidc_connections_issuer_present",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "CHECK (((issuer = btrim(issuer)) AND (issuer <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "oidc_connections_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "oidc_connections_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "oidc_connections_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_connections_required_assurance_not_null",
          "target": null,
          "columns": [
            "required_assurance"
          ],
          "definition": "NOT NULL required_assurance",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_connections_version_not_null",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "NOT NULL version",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "oidc_connections_version_positive",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "CHECK ((version > 0))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00006_invitations.sql",
        "migrations/00008_profiles.sql"
      ]
    },
    {
      "rls": true,
      "name": "oidc_logout_receipts",
      "columns": [
        {
          "name": "issuer",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "jti_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "subject_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "sid_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "issued_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "oidc_logout_expiry",
          "unique": false,
          "columns": [
            "issuer",
            "expires_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX oidc_logout_expiry ON public.oidc_logout_receipts USING btree (issuer, expires_at)"
        },
        {
          "name": "oidc_logout_receipts_pkey",
          "unique": true,
          "columns": [
            "issuer",
            "jti_hash"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX oidc_logout_receipts_pkey ON public.oidc_logout_receipts USING btree (issuer, jti_hash)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "oidc_logout_issuer",
          "check": "(issuer = NULLIF(current_setting('app.logout_issuer'::text, true), ''::text))",
          "roles": [
            "public"
          ],
          "using": "(issuer = NULLIF(current_setting('app.logout_issuer'::text, true), ''::text))",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "oidc_logout_receipts_check",
          "target": null,
          "columns": [
            "subject_hash",
            "sid_hash"
          ],
          "definition": "CHECK (((subject_hash IS NOT NULL) OR (sid_hash IS NOT NULL)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_logout_receipts_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_logout_receipts_issued_at_not_null",
          "target": null,
          "columns": [
            "issued_at"
          ],
          "definition": "NOT NULL issued_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_logout_receipts_issuer_not_null",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "NOT NULL issuer",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "oidc_logout_receipts_jti_hash_check",
          "target": null,
          "columns": [
            "jti_hash"
          ],
          "definition": "CHECK ((octet_length(jti_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "oidc_logout_receipts_jti_hash_not_null",
          "target": null,
          "columns": [
            "jti_hash"
          ],
          "definition": "NOT NULL jti_hash",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "oidc_logout_receipts_pkey",
          "target": null,
          "columns": [
            "issuer",
            "jti_hash"
          ],
          "definition": "PRIMARY KEY (issuer, jti_hash)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "oidc_logout_receipts_sid_hash_check",
          "target": null,
          "columns": [
            "sid_hash"
          ],
          "definition": "CHECK (((sid_hash IS NULL) OR (octet_length(sid_hash) = 32)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "oidc_logout_receipts_subject_hash_check",
          "target": null,
          "columns": [
            "subject_hash"
          ],
          "definition": "CHECK (((subject_hash IS NULL) OR (octet_length(subject_hash) = 32)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00040_oidc_session_revocation.sql"
      ]
    },
    {
      "rls": true,
      "name": "organisation_access_commands",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "actor_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "payload_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "restriction",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "journal_recorded",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "organisation_access_commands_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisation_access_commands_pkey ON public.organisation_access_commands USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "organisation_access_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "organisation_access_commands_actor_id_not_null",
          "target": null,
          "columns": [
            "actor_id"
          ],
          "definition": "NOT NULL actor_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_access_commands_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_access_commands_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_access_commands_journal_recorded_not_null",
          "target": null,
          "columns": [
            "journal_recorded"
          ],
          "definition": "NOT NULL journal_recorded",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "organisation_access_commands_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "organisation_access_commands_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_access_commands_payload_hash_not_null",
          "target": null,
          "columns": [
            "payload_hash"
          ],
          "definition": "NOT NULL payload_hash",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "organisation_access_commands_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00041_organisation_administration.sql"
      ]
    },
    {
      "rls": true,
      "name": "organisation_audit",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "actor_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "action",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "resource_id",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "metadata",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "organisation_audit_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisation_audit_pkey ON public.organisation_audit USING btree (organisation_id, id)"
        },
        {
          "name": "organisation_audit_recent",
          "unique": false,
          "columns": [
            "organisation_id",
            "created_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX organisation_audit_recent ON public.organisation_audit USING btree (organisation_id, created_at DESC)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "organisation_audit_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "organisation_audit_action_not_null",
          "target": null,
          "columns": [
            "action"
          ],
          "definition": "NOT NULL action",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_audit_actor_id_not_null",
          "target": null,
          "columns": [
            "actor_id"
          ],
          "definition": "NOT NULL actor_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_audit_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_audit_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_audit_metadata_not_null",
          "target": null,
          "columns": [
            "metadata"
          ],
          "definition": "NOT NULL metadata",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "organisation_audit_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "organisation_audit_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "organisation_audit_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_audit_resource_id_not_null",
          "target": null,
          "columns": [
            "resource_id"
          ],
          "definition": "NOT NULL resource_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00041_organisation_administration.sql",
        "migrations/00055_support_views.sql"
      ]
    },
    {
      "rls": true,
      "name": "organisation_extensions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "extension_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "extension_version",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enabled",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "installed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "disabled_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "organisation_extensions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "extension_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisation_extensions_pkey ON public.organisation_extensions USING btree (organisation_id, extension_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "organisation_extensions_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "organisation_extensions_enabled_not_null",
          "target": null,
          "columns": [
            "enabled"
          ],
          "definition": "NOT NULL enabled",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_extensions_extension_id_not_null",
          "target": null,
          "columns": [
            "extension_id"
          ],
          "definition": "NOT NULL extension_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_extensions_extension_version_not_null",
          "target": null,
          "columns": [
            "extension_version"
          ],
          "definition": "NOT NULL extension_version",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisation_extensions_id_present",
          "target": null,
          "columns": [
            "extension_id"
          ],
          "definition": "CHECK (((extension_id = btrim(extension_id)) AND (extension_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_extensions_installed_at_not_null",
          "target": null,
          "columns": [
            "installed_at"
          ],
          "definition": "NOT NULL installed_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_extensions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "organisation_extensions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "extension_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, extension_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisation_extensions_version_present",
          "target": null,
          "columns": [
            "extension_version"
          ],
          "definition": "CHECK (((extension_version = btrim(extension_version)) AND (extension_version <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00034_extensions.sql"
      ]
    },
    {
      "rls": true,
      "name": "organisation_slugs",
      "columns": [
        {
          "name": "slug",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "organisation_slugs_pkey",
          "unique": true,
          "columns": [
            "slug"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisation_slugs_pkey ON public.organisation_slugs USING btree (slug)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "slug_public_lookup",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "true",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "slug_tenant_insert",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": null,
          "command": "INSERT",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "organisation_slugs_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "organisation_slugs_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "organisation_slugs_pkey",
          "target": null,
          "columns": [
            "slug"
          ],
          "definition": "PRIMARY KEY (slug)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisation_slugs_slug_check",
          "target": null,
          "columns": [
            "slug"
          ],
          "definition": "CHECK ((slug ~ '^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$'::text))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_slugs_slug_not_null",
          "target": null,
          "columns": [
            "slug"
          ],
          "definition": "NOT NULL slug",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00048_company_addresses.sql"
      ]
    },
    {
      "rls": true,
      "name": "organisation_sso",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revision",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "checked_revision",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "config_ciphertext",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "status",
          "type": "text",
          "default": "'draft'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "message",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "desired_enabled",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "published_revision",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "last_sign_in",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": "'Company sign-in'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "protocol",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "broker_alias",
          "type": "text",
          "default": "(('zublms-'::text || (organisation_id)::text) ||\nCASE\n    WHEN (id = organisation_id) THEN ''::text\n    ELSE ('-'::text || (id)::text)\nEND)",
          "identity": "",
          "nullable": true,
          "generated": "s",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "organisation_sso_active",
          "unique": false,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": false,
          "predicate": "((status = 'active'::text) AND desired_enabled AND (published_revision = revision))",
          "definition": "CREATE INDEX organisation_sso_active ON public.organisation_sso USING btree (organisation_id, id) WHERE ((status = 'active'::text) AND desired_enabled AND (published_revision = revision))"
        },
        {
          "name": "organisation_sso_alias",
          "unique": true,
          "columns": [
            "broker_alias"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisation_sso_alias ON public.organisation_sso USING btree (broker_alias)"
        },
        {
          "name": "organisation_sso_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisation_sso_pkey ON public.organisation_sso USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "organisation_sso_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "organisation_sso_checked_revision_not_null",
          "target": null,
          "columns": [
            "checked_revision"
          ],
          "definition": "NOT NULL checked_revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_config_ciphertext_not_null",
          "target": null,
          "columns": [
            "config_ciphertext"
          ],
          "definition": "NOT NULL config_ciphertext",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_desired_enabled_not_null",
          "target": null,
          "columns": [
            "desired_enabled"
          ],
          "definition": "NOT NULL desired_enabled",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_message_not_null",
          "target": null,
          "columns": [
            "message"
          ],
          "definition": "NOT NULL message",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "organisation_sso_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "organisation_sso_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "organisation_sso_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisation_sso_protocol_check",
          "target": null,
          "columns": [
            "protocol"
          ],
          "definition": "CHECK ((protocol = ANY (ARRAY[''::text, 'saml'::text, 'oidc'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_protocol_not_null",
          "target": null,
          "columns": [
            "protocol"
          ],
          "definition": "NOT NULL protocol",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_published_revision_not_null",
          "target": null,
          "columns": [
            "published_revision"
          ],
          "definition": "NOT NULL published_revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_revision_not_null",
          "target": null,
          "columns": [
            "revision"
          ],
          "definition": "NOT NULL revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisation_sso_status_check",
          "target": null,
          "columns": [
            "status"
          ],
          "definition": "CHECK ((status = ANY (ARRAY['draft'::text, 'checked'::text, 'pending'::text, 'active'::text, 'disabling'::text, 'disabled'::text, 'error'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_status_not_null",
          "target": null,
          "columns": [
            "status"
          ],
          "definition": "NOT NULL status",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00041_organisation_administration.sql",
        "migrations/00047_multi_company_sso.sql"
      ]
    },
    {
      "rls": true,
      "name": "organisation_sso_domains",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "connection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "domain",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "organisation_sso_domains_connection",
          "unique": false,
          "columns": [
            "organisation_id",
            "connection_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX organisation_sso_domains_connection ON public.organisation_sso_domains USING btree (organisation_id, connection_id)"
        },
        {
          "name": "organisation_sso_domains_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "domain"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisation_sso_domains_pkey ON public.organisation_sso_domains USING btree (organisation_id, domain)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "organisation_sso_domains_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "organisation_sso_domains_connection_id_not_null",
          "target": null,
          "columns": [
            "connection_id"
          ],
          "definition": "NOT NULL connection_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisation_sso_domains_domain_check",
          "target": null,
          "columns": [
            "domain"
          ],
          "definition": "CHECK (((domain = lower(domain)) AND ((length(domain) >= 3) AND (length(domain) <= 253))))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisation_sso_domains_domain_not_null",
          "target": null,
          "columns": [
            "domain"
          ],
          "definition": "NOT NULL domain",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "organisation_sso_domains_organisation_id_connection_id_fkey",
          "target": "organisation_sso",
          "columns": [
            "organisation_id",
            "connection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, connection_id) REFERENCES organisation_sso(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "organisation_sso_domains_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "organisation_sso_domains_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "domain"
          ],
          "definition": "PRIMARY KEY (organisation_id, domain)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00047_multi_company_sso.sql"
      ]
    },
    {
      "rls": true,
      "name": "organisations",
      "columns": [
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "timezone",
          "type": "text",
          "default": "'UTC'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "scope_epoch",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "settings_revision",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "logo_data",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "accent",
          "type": "text",
          "default": "'violet'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "support_email",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "support_url",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "workspace_slug",
          "type": "text",
          "default": "''::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "address_revision",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "allow_slug_changes",
          "type": "boolean",
          "default": "true",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "allow_custom_domains",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "organisations_pkey",
          "unique": true,
          "columns": [
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX organisations_pkey ON public.organisations USING btree (id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "organisations_for_subject",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "(id IN ( SELECT identity_links.organisation_id\n   FROM identity_links\n  WHERE ((current_setting('app.identity_issuer'::text, true) <> ''::text) AND (identity_links.issuer = current_setting('app.identity_issuer'::text, true)) AND (identity_links.subject = current_setting('app.identity_subject'::text, true)))))",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "organisations_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [
        "CREATE TRIGGER organisation_recovery_registry AFTER INSERT ON public.organisations FOR EACH ROW EXECUTE FUNCTION register_recovery_organisation()"
      ],
      "constraints": [
        {
          "kind": "n",
          "name": "organisations_accent_not_null",
          "target": null,
          "columns": [
            "accent"
          ],
          "definition": "NOT NULL accent",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_address_revision_not_null",
          "target": null,
          "columns": [
            "address_revision"
          ],
          "definition": "NOT NULL address_revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_allow_custom_domains_not_null",
          "target": null,
          "columns": [
            "allow_custom_domains"
          ],
          "definition": "NOT NULL allow_custom_domains",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_allow_slug_changes_not_null",
          "target": null,
          "columns": [
            "allow_slug_changes"
          ],
          "definition": "NOT NULL allow_slug_changes",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_logo_data_not_null",
          "target": null,
          "columns": [
            "logo_data"
          ],
          "definition": "NOT NULL logo_data",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "organisations_pkey",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "PRIMARY KEY (id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_scope_epoch_not_null",
          "target": null,
          "columns": [
            "scope_epoch"
          ],
          "definition": "NOT NULL scope_epoch",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisations_scope_epoch_positive",
          "target": null,
          "columns": [
            "scope_epoch"
          ],
          "definition": "CHECK ((scope_epoch > 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisations_self",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "CHECK ((organisation_id = id))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_settings_revision_not_null",
          "target": null,
          "columns": [
            "settings_revision"
          ],
          "definition": "NOT NULL settings_revision",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_support_email_not_null",
          "target": null,
          "columns": [
            "support_email"
          ],
          "definition": "NOT NULL support_email",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_support_url_not_null",
          "target": null,
          "columns": [
            "support_url"
          ],
          "definition": "NOT NULL support_url",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_timezone_not_null",
          "target": null,
          "columns": [
            "timezone"
          ],
          "definition": "NOT NULL timezone",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "organisations_timezone_present",
          "target": null,
          "columns": [
            "timezone"
          ],
          "definition": "CHECK (((timezone = btrim(timezone)) AND (timezone <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "organisations_workspace_slug_not_null",
          "target": null,
          "columns": [
            "workspace_slug"
          ],
          "definition": "NOT NULL workspace_slug",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00003_organisations.sql",
        "migrations/00004_identity.sql",
        "migrations/00005_browser_sessions.sql",
        "migrations/00006_invitations.sql",
        "migrations/00007_step_up.sql",
        "migrations/00008_profiles.sql",
        "migrations/00009_drafts.sql",
        "migrations/00012_quarantine.sql",
        "migrations/00020_refresher_schedule.sql",
        "migrations/00022_report_download_authority.sql",
        "migrations/00023_scim_users.sql",
        "migrations/00024_scim_groups.sql",
        "migrations/00035_native_workspace.sql",
        "migrations/00037_recovery_admission.sql",
        "migrations/00039_report_requests.sql",
        "migrations/00041_organisation_administration.sql",
        "migrations/00042_resource_library.sql",
        "migrations/00045_experience.sql",
        "migrations/00048_company_addresses.sql",
        "migrations/00049_learning_packages.sql",
        "migrations/00050_ai_draft_requests.sql",
        "migrations/00052_ai_provider_management.sql",
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "outbox_events",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "event_type",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "aggregate_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "outbox_events_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX outbox_events_pkey ON public.outbox_events USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "outbox_events_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "outbox_events_aggregate_id_not_null",
          "target": null,
          "columns": [
            "aggregate_id"
          ],
          "definition": "NOT NULL aggregate_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "outbox_events_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "outbox_events_event_type_not_null",
          "target": null,
          "columns": [
            "event_type"
          ],
          "definition": "NOT NULL event_type",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "outbox_events_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "outbox_events_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "outbox_events_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "outbox_events_type_present",
          "target": null,
          "columns": [
            "event_type"
          ],
          "definition": "CHECK (((event_type = btrim(event_type)) AND (event_type <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00015_completions.sql"
      ]
    },
    {
      "rls": true,
      "name": "pathway_assignments",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "pathway_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "assigned_by",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "assigned_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "due_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "started_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "cancelled_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "pathway_assignments_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pathway_assignments_pkey ON public.pathway_assignments USING btree (organisation_id, id)"
        },
        {
          "name": "pathway_assignments_user",
          "unique": false,
          "columns": [
            "organisation_id",
            "user_id",
            "assigned_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX pathway_assignments_user ON public.pathway_assignments USING btree (organisation_id, user_id, assigned_at)"
        },
        {
          "name": "pathway_one_live_assignment",
          "unique": true,
          "columns": [
            "organisation_id",
            "pathway_id",
            "user_id"
          ],
          "primary": false,
          "predicate": "(cancelled_at IS NULL)",
          "definition": "CREATE UNIQUE INDEX pathway_one_live_assignment ON public.pathway_assignments USING btree (organisation_id, pathway_id, user_id) WHERE (cancelled_at IS NULL)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "pathway_assignments_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "pathway_assignments_assigned_at_not_null",
          "target": null,
          "columns": [
            "assigned_at"
          ],
          "definition": "NOT NULL assigned_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_assignments_assigned_by_not_null",
          "target": null,
          "columns": [
            "assigned_by"
          ],
          "definition": "NOT NULL assigned_by",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_assignments_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pathway_assignments_organisation_id_assigned_by_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "assigned_by"
          ],
          "definition": "FOREIGN KEY (organisation_id, assigned_by) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "pathway_assignments_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pathway_assignments_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "pathway_assignments_organisation_id_version_id_pathway_id_fkey",
          "target": "pathway_versions",
          "columns": [
            "organisation_id",
            "version_id",
            "pathway_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, version_id, pathway_id) REFERENCES pathway_versions(organisation_id, id, pathway_id)",
          "targetColumns": [
            "organisation_id",
            "id",
            "pathway_id"
          ]
        },
        {
          "kind": "n",
          "name": "pathway_assignments_pathway_id_not_null",
          "target": null,
          "columns": [
            "pathway_id"
          ],
          "definition": "NOT NULL pathway_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "pathway_assignments_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_assignments_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_assignments_version_id_not_null",
          "target": null,
          "columns": [
            "version_id"
          ],
          "definition": "NOT NULL version_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "pathway_course_links",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "assignment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "credited",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "pathway_course_links_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "assignment_id",
            "course_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pathway_course_links_pkey ON public.pathway_course_links USING btree (organisation_id, assignment_id, course_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "pathway_course_links_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "pathway_course_links_assignment_id_not_null",
          "target": null,
          "columns": [
            "assignment_id"
          ],
          "definition": "NOT NULL assignment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_course_links_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_course_links_credited_not_null",
          "target": null,
          "columns": [
            "credited"
          ],
          "definition": "NOT NULL credited",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_course_links_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pathway_course_links_organisation_id_assignment_id_fkey",
          "target": "pathway_assignments",
          "columns": [
            "organisation_id",
            "assignment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, assignment_id) REFERENCES pathway_assignments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "pathway_course_links_organisation_id_course_id_fkey",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "pathway_course_links_organisation_id_enrolment_id_fkey",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "pathway_course_links_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "pathway_course_links_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "assignment_id",
            "course_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, assignment_id, course_id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "pathway_version_courses",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "pathway_version_courses_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "version_id",
            "course_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pathway_version_courses_pkey ON public.pathway_version_courses USING btree (organisation_id, version_id, course_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "pathway_version_courses_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "pathway_version_courses_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_version_courses_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pathway_version_courses_organisation_id_course_id_fkey",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "pathway_version_courses_organisation_id_course_version_id_fkey",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "pathway_version_courses_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pathway_version_courses_organisation_id_version_id_fkey",
          "target": "pathway_versions",
          "columns": [
            "organisation_id",
            "version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, version_id) REFERENCES pathway_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "pathway_version_courses_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "version_id",
            "course_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, version_id, course_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_version_courses_version_id_not_null",
          "target": null,
          "columns": [
            "version_id"
          ],
          "definition": "NOT NULL version_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "pathway_versions",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "pathway_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version_number",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "source_revision",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "definition",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "published_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "pathway_versions_organisation_id_id_pathway_id_key",
          "unique": true,
          "columns": [
            "organisation_id",
            "id",
            "pathway_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pathway_versions_organisation_id_id_pathway_id_key ON public.pathway_versions USING btree (organisation_id, id, pathway_id)"
        },
        {
          "name": "pathway_versions_organisation_id_pathway_id_source_revision_key",
          "unique": true,
          "columns": [
            "organisation_id",
            "pathway_id",
            "source_revision"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pathway_versions_organisation_id_pathway_id_source_revision_key ON public.pathway_versions USING btree (organisation_id, pathway_id, source_revision)"
        },
        {
          "name": "pathway_versions_organisation_id_pathway_id_version_number_key",
          "unique": true,
          "columns": [
            "organisation_id",
            "pathway_id",
            "version_number"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pathway_versions_organisation_id_pathway_id_version_number_key ON public.pathway_versions USING btree (organisation_id, pathway_id, version_number)"
        },
        {
          "name": "pathway_versions_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pathway_versions_pkey ON public.pathway_versions USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "pathway_versions_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "pathway_versions_definition_not_null",
          "target": null,
          "columns": [
            "definition"
          ],
          "definition": "NOT NULL definition",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_versions_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "pathway_versions_organisation_id_id_pathway_id_key",
          "target": null,
          "columns": [
            "organisation_id",
            "id",
            "pathway_id"
          ],
          "definition": "UNIQUE (organisation_id, id, pathway_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_versions_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pathway_versions_organisation_id_pathway_id_fkey",
          "target": "learning_pathways",
          "columns": [
            "organisation_id",
            "pathway_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, pathway_id) REFERENCES learning_pathways(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "u",
          "name": "pathway_versions_organisation_id_pathway_id_source_revision_key",
          "target": null,
          "columns": [
            "organisation_id",
            "pathway_id",
            "source_revision"
          ],
          "definition": "UNIQUE (organisation_id, pathway_id, source_revision)",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "pathway_versions_organisation_id_pathway_id_version_number_key",
          "target": null,
          "columns": [
            "organisation_id",
            "pathway_id",
            "version_number"
          ],
          "definition": "UNIQUE (organisation_id, pathway_id, version_number)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_versions_pathway_id_not_null",
          "target": null,
          "columns": [
            "pathway_id"
          ],
          "definition": "NOT NULL pathway_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "pathway_versions_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_versions_published_at_not_null",
          "target": null,
          "columns": [
            "published_at"
          ],
          "definition": "NOT NULL published_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_versions_source_revision_not_null",
          "target": null,
          "columns": [
            "source_revision"
          ],
          "definition": "NOT NULL source_revision",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "pathway_versions_version_number_check",
          "target": null,
          "columns": [
            "version_number"
          ],
          "definition": "CHECK ((version_number > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pathway_versions_version_number_not_null",
          "target": null,
          "columns": [
            "version_number"
          ],
          "definition": "NOT NULL version_number",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "pending_bindings",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "invitation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "connection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "issuer",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "subject",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_authz_version",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "connection_version",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "status",
          "type": "text",
          "default": "'pending'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "pending_bindings_invitation_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "invitation_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pending_bindings_invitation_once ON public.pending_bindings USING btree (organisation_id, invitation_id)"
        },
        {
          "name": "pending_bindings_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX pending_bindings_pkey ON public.pending_bindings USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "pending_bindings_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "pending_bindings_connection_fk",
          "target": "oidc_connections",
          "columns": [
            "organisation_id",
            "connection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, connection_id) REFERENCES oidc_connections(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "pending_bindings_connection_id_not_null",
          "target": null,
          "columns": [
            "connection_id"
          ],
          "definition": "NOT NULL connection_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pending_bindings_connection_version_not_null",
          "target": null,
          "columns": [
            "connection_version"
          ],
          "definition": "NOT NULL connection_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pending_bindings_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pending_bindings_invitation_fk",
          "target": "invitations",
          "columns": [
            "organisation_id",
            "invitation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, invitation_id) REFERENCES invitations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "pending_bindings_invitation_id_not_null",
          "target": null,
          "columns": [
            "invitation_id"
          ],
          "definition": "NOT NULL invitation_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "pending_bindings_invitation_once",
          "target": null,
          "columns": [
            "organisation_id",
            "invitation_id"
          ],
          "definition": "UNIQUE (organisation_id, invitation_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pending_bindings_issuer_not_null",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "NOT NULL issuer",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pending_bindings_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "pending_bindings_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "pending_bindings_status",
          "target": null,
          "columns": [
            "status"
          ],
          "definition": "CHECK ((status = ANY (ARRAY['pending'::text, 'approved'::text, 'rejected'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pending_bindings_status_not_null",
          "target": null,
          "columns": [
            "status"
          ],
          "definition": "NOT NULL status",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pending_bindings_subject_not_null",
          "target": null,
          "columns": [
            "subject"
          ],
          "definition": "NOT NULL subject",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "pending_bindings_user_authz_version_not_null",
          "target": null,
          "columns": [
            "user_authz_version"
          ],
          "definition": "NOT NULL user_authz_version",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "pending_bindings_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "pending_bindings_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00006_invitations.sql"
      ]
    },
    {
      "rls": true,
      "name": "people_bulk_results",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "run_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "result",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "people_bulk_results_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "run_id",
            "user_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX people_bulk_results_pkey ON public.people_bulk_results USING btree (organisation_id, run_id, user_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "people_bulk_results_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "people_bulk_results_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "people_bulk_results_organisation_id_run_id_fkey",
          "target": "people_bulk_runs",
          "columns": [
            "organisation_id",
            "run_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, run_id) REFERENCES people_bulk_runs(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "people_bulk_results_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "run_id",
            "user_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, run_id, user_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "people_bulk_results_result_not_null",
          "target": null,
          "columns": [
            "result"
          ],
          "definition": "NOT NULL result",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "people_bulk_results_run_id_not_null",
          "target": null,
          "columns": [
            "run_id"
          ],
          "definition": "NOT NULL run_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "people_bulk_results_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": true,
      "name": "people_bulk_runs",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "actor_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "payload_hash",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "people_bulk_runs_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX people_bulk_runs_pkey ON public.people_bulk_runs USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "people_bulk_runs_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "people_bulk_runs_actor_id_not_null",
          "target": null,
          "columns": [
            "actor_id"
          ],
          "definition": "NOT NULL actor_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "people_bulk_runs_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "people_bulk_runs_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "people_bulk_runs_organisation_id_actor_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "actor_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, actor_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "people_bulk_runs_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "people_bulk_runs_payload_hash_not_null",
          "target": null,
          "columns": [
            "payload_hash"
          ],
          "definition": "NOT NULL payload_hash",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "people_bulk_runs_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": false,
      "name": "platform_object_location",
      "columns": [
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "purpose",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "backend",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "storage_key",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "generation",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "tombstoned_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "platform_object_location_pkey",
          "unique": true,
          "columns": [
            "object_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX platform_object_location_pkey ON public.platform_object_location USING btree (object_id)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "platform_object_location_backend_check",
          "target": null,
          "columns": [
            "backend"
          ],
          "definition": "CHECK ((backend = ANY (ARRAY['filesystem'::text, 's3'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_backend_not_null",
          "target": null,
          "columns": [
            "backend"
          ],
          "definition": "NOT NULL backend",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "platform_object_location_byte_length_check",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "platform_object_location_generation_check",
          "target": null,
          "columns": [
            "generation"
          ],
          "definition": "CHECK ((generation >= 1))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_generation_not_null",
          "target": null,
          "columns": [
            "generation"
          ],
          "definition": "NOT NULL generation",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "platform_object_location_pkey",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "PRIMARY KEY (object_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_purpose_not_null",
          "target": null,
          "columns": [
            "purpose"
          ],
          "definition": "NOT NULL purpose",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_storage_key_not_null",
          "target": null,
          "columns": [
            "storage_key"
          ],
          "definition": "NOT NULL storage_key",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_object_location_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00002_platform_object_location.sql"
      ]
    },
    {
      "rls": false,
      "name": "platform_organisation_registry",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "platform_organisation_registry_pkey",
          "unique": true,
          "columns": [
            "organisation_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX platform_organisation_registry_pkey ON public.platform_organisation_registry USING btree (organisation_id)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "platform_organisation_registry_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "platform_organisation_registry_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "platform_organisation_registry_pkey",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "PRIMARY KEY (organisation_id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00037_recovery_admission.sql"
      ]
    },
    {
      "rls": true,
      "name": "platform_tenant_smoke",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "label",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "platform_tenant_smoke_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "label"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX platform_tenant_smoke_pkey ON public.platform_tenant_smoke USING btree (organisation_id, label)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "platform_tenant_smoke_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "platform_tenant_smoke_label_not_null",
          "target": null,
          "columns": [
            "label"
          ],
          "definition": "NOT NULL label",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "platform_tenant_smoke_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "platform_tenant_smoke_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "label"
          ],
          "definition": "PRIMARY KEY (organisation_id, label)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00001_synthetic_tenant_guard.sql"
      ]
    },
    {
      "rls": true,
      "name": "profiles",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name_envelope",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "email_envelope",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "phone_envelope",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "address_envelope",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attributes_envelope",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "email_index",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "profiles_email_index_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "email_index"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX profiles_email_index_once ON public.profiles USING btree (organisation_id, email_index)"
        },
        {
          "name": "profiles_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX profiles_pkey ON public.profiles USING btree (organisation_id, user_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "profiles_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "profiles_address_envelope_not_null",
          "target": null,
          "columns": [
            "address_envelope"
          ],
          "definition": "NOT NULL address_envelope",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "profiles_attributes_envelope_not_null",
          "target": null,
          "columns": [
            "attributes_envelope"
          ],
          "definition": "NOT NULL attributes_envelope",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "profiles_email_envelope_not_null",
          "target": null,
          "columns": [
            "email_envelope"
          ],
          "definition": "NOT NULL email_envelope",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "profiles_email_index_not_null",
          "target": null,
          "columns": [
            "email_index"
          ],
          "definition": "NOT NULL email_index",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "profiles_email_index_once",
          "target": null,
          "columns": [
            "organisation_id",
            "email_index"
          ],
          "definition": "UNIQUE (organisation_id, email_index)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "profiles_name_envelope_not_null",
          "target": null,
          "columns": [
            "name_envelope"
          ],
          "definition": "NOT NULL name_envelope",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "profiles_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "profiles_phone_envelope_not_null",
          "target": null,
          "columns": [
            "phone_envelope"
          ],
          "definition": "NOT NULL phone_envelope",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "profiles_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, user_id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "profiles_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "profiles_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00008_profiles.sql"
      ]
    },
    {
      "rls": true,
      "name": "progress_commands",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "session_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "command_key",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "kind",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "server_revision",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "accepted_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "progress_commands_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "session_id",
            "command_key"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX progress_commands_once ON public.progress_commands USING btree (organisation_id, enrolment_id, session_id, command_key)"
        },
        {
          "name": "progress_commands_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX progress_commands_pkey ON public.progress_commands USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "progress_commands_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "progress_commands_accepted_at_not_null",
          "target": null,
          "columns": [
            "accepted_at"
          ],
          "definition": "NOT NULL accepted_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "progress_commands_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "progress_commands_command_key_not_null",
          "target": null,
          "columns": [
            "command_key"
          ],
          "definition": "NOT NULL command_key",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "progress_commands_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "progress_commands_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "progress_commands_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "progress_commands_key_present",
          "target": null,
          "columns": [
            "command_key"
          ],
          "definition": "CHECK (((command_key = btrim(command_key)) AND (command_key <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "progress_commands_kind",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "CHECK ((kind = 'acknowledge'::text))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "progress_commands_kind_not_null",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "NOT NULL kind",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "progress_commands_once",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "session_id",
            "command_key"
          ],
          "definition": "UNIQUE (organisation_id, enrolment_id, session_id, command_key)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "progress_commands_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "progress_commands_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "progress_commands_revision_positive",
          "target": null,
          "columns": [
            "server_revision"
          ],
          "definition": "CHECK ((server_revision > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "progress_commands_server_revision_not_null",
          "target": null,
          "columns": [
            "server_revision"
          ],
          "definition": "NOT NULL server_revision",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "progress_commands_session_fk",
          "target": "learning_sessions",
          "columns": [
            "organisation_id",
            "session_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, session_id) REFERENCES learning_sessions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "progress_commands_session_id_not_null",
          "target": null,
          "columns": [
            "session_id"
          ],
          "definition": "NOT NULL session_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00013_learning_progress.sql"
      ]
    },
    {
      "rls": true,
      "name": "quarantine_uploads",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "scan_state",
          "type": "text",
          "default": "'pending'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "quarantine_uploads_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX quarantine_uploads_pkey ON public.quarantine_uploads USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "quarantine_uploads_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "quarantine_uploads_byte_length",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "quarantine_uploads_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "quarantine_uploads_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "quarantine_uploads_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "quarantine_uploads_object_present",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "CHECK (((object_id = btrim(object_id)) AND (object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "quarantine_uploads_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "quarantine_uploads_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "quarantine_uploads_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "quarantine_uploads_scan_state",
          "target": null,
          "columns": [
            "scan_state"
          ],
          "definition": "CHECK ((scan_state = ANY (ARRAY['pending'::text, 'clean'::text, 'failed'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "quarantine_uploads_scan_state_not_null",
          "target": null,
          "columns": [
            "scan_state"
          ],
          "definition": "NOT NULL scan_state",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "quarantine_uploads_sha256",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "CHECK ((octet_length(sha256) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "quarantine_uploads_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00012_quarantine.sql",
        "migrations/00017_media_renditions.sql"
      ]
    },
    {
      "rls": true,
      "name": "recovery_checkpoints",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sequence",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "head_hash",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "verified_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "recovery_checkpoints_pkey",
          "unique": true,
          "columns": [
            "organisation_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX recovery_checkpoints_pkey ON public.recovery_checkpoints USING btree (organisation_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "recovery_checkpoint_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "recovery_checkpoints_head_hash_not_null",
          "target": null,
          "columns": [
            "head_hash"
          ],
          "definition": "NOT NULL head_hash",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "recovery_checkpoints_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "recovery_checkpoints_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "recovery_checkpoints_pkey",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "PRIMARY KEY (organisation_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "recovery_checkpoints_sequence_check",
          "target": null,
          "columns": [
            "sequence"
          ],
          "definition": "CHECK ((sequence >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "recovery_checkpoints_sequence_not_null",
          "target": null,
          "columns": [
            "sequence"
          ],
          "definition": "NOT NULL sequence",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "recovery_checkpoints_verified_at_not_null",
          "target": null,
          "columns": [
            "verified_at"
          ],
          "definition": "NOT NULL verified_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00037_recovery_admission.sql"
      ]
    },
    {
      "rls": true,
      "name": "refresher_occurrences",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "rule_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "certificate_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "scheduled_instant",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "refresher_occurrences_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "rule_id",
            "user_id",
            "scheduled_instant"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX refresher_occurrences_once ON public.refresher_occurrences USING btree (organisation_id, rule_id, user_id, scheduled_instant)"
        },
        {
          "name": "refresher_occurrences_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX refresher_occurrences_pkey ON public.refresher_occurrences USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "refresher_occurrences_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "refresher_occurrences_certificate_fk",
          "target": "certificates",
          "columns": [
            "organisation_id",
            "certificate_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, certificate_id) REFERENCES certificates(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_certificate_id_not_null",
          "target": null,
          "columns": [
            "certificate_id"
          ],
          "definition": "NOT NULL certificate_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "refresher_occurrences_once",
          "target": null,
          "columns": [
            "organisation_id",
            "rule_id",
            "user_id",
            "scheduled_instant"
          ],
          "definition": "UNIQUE (organisation_id, rule_id, user_id, scheduled_instant)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "refresher_occurrences_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "refresher_occurrences_rule_fk",
          "target": "refresher_rules",
          "columns": [
            "organisation_id",
            "rule_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, rule_id) REFERENCES refresher_rules(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_rule_id_not_null",
          "target": null,
          "columns": [
            "rule_id"
          ],
          "definition": "NOT NULL rule_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_scheduled_instant_not_null",
          "target": null,
          "columns": [
            "scheduled_instant"
          ],
          "definition": "NOT NULL scheduled_instant",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "refresher_occurrences_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['scheduled'::text, 'skipped'::text, 'enqueued'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "refresher_occurrences_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "refresher_occurrences_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00020_refresher_schedule.sql"
      ]
    },
    {
      "rls": true,
      "name": "refresher_rules",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "refresher_rules_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX refresher_rules_pkey ON public.refresher_rules USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "refresher_rules_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "refresher_rules_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "refresher_rules_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_rules_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_rules_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "refresher_rules_name_present",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "CHECK (((name = btrim(name)) AND (name <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "refresher_rules_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "refresher_rules_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00020_refresher_schedule.sql"
      ]
    },
    {
      "rls": true,
      "name": "report_export_artefacts",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "lease_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "lease_generation",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "published_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "published_principal_authz_version",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "published_org_scope_epoch",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "requesting_principal_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "report_export_artefacts_attempt_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "lease_id",
            "attempt_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX report_export_artefacts_attempt_once ON public.report_export_artefacts USING btree (organisation_id, lease_id, attempt_id)"
        },
        {
          "name": "report_export_artefacts_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX report_export_artefacts_pkey ON public.report_export_artefacts USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "report_export_artefacts_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "report_export_artefacts_attempt_id_not_null",
          "target": null,
          "columns": [
            "attempt_id"
          ],
          "definition": "NOT NULL attempt_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "report_export_artefacts_attempt_once",
          "target": null,
          "columns": [
            "organisation_id",
            "lease_id",
            "attempt_id"
          ],
          "definition": "UNIQUE (organisation_id, lease_id, attempt_id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_artefacts_authz_positive",
          "target": null,
          "columns": [
            "published_principal_authz_version"
          ],
          "definition": "CHECK ((published_principal_authz_version > 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_artefacts_byte_length",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "report_export_artefacts_lease_fk",
          "target": "report_export_leases",
          "columns": [
            "organisation_id",
            "lease_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, lease_id) REFERENCES report_export_leases(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_lease_generation_not_null",
          "target": null,
          "columns": [
            "lease_generation"
          ],
          "definition": "NOT NULL lease_generation",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_lease_id_not_null",
          "target": null,
          "columns": [
            "lease_id"
          ],
          "definition": "NOT NULL lease_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_artefacts_object_present",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "CHECK (((object_id = btrim(object_id)) AND (object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "report_export_artefacts_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "report_export_artefacts_principal_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "requesting_principal_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, requesting_principal_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_published_at_not_null",
          "target": null,
          "columns": [
            "published_at"
          ],
          "definition": "NOT NULL published_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_published_org_scope_epoch_not_null",
          "target": null,
          "columns": [
            "published_org_scope_epoch"
          ],
          "definition": "NOT NULL published_org_scope_epoch",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_published_principal_authz_vers_not_null",
          "target": null,
          "columns": [
            "published_principal_authz_version"
          ],
          "definition": "NOT NULL published_principal_authz_version",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_artefacts_scope_positive",
          "target": null,
          "columns": [
            "published_org_scope_epoch"
          ],
          "definition": "CHECK ((published_org_scope_epoch > 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_artefacts_sha256",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "CHECK ((octet_length(sha256) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_artefacts_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00021_report_exports.sql",
        "migrations/00022_report_download_authority.sql",
        "migrations/00039_report_requests.sql"
      ]
    },
    {
      "rls": true,
      "name": "report_export_leases",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "report_key",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "lease_generation",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "report_export_leases_active_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "report_key"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX report_export_leases_active_once ON public.report_export_leases USING btree (organisation_id, report_key)"
        },
        {
          "name": "report_export_leases_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX report_export_leases_pkey ON public.report_export_leases USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "report_export_leases_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "u",
          "name": "report_export_leases_active_once",
          "target": null,
          "columns": [
            "organisation_id",
            "report_key"
          ],
          "definition": "UNIQUE (organisation_id, report_key)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_attempt_id_not_null",
          "target": null,
          "columns": [
            "attempt_id"
          ],
          "definition": "NOT NULL attempt_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_leases_generation",
          "target": null,
          "columns": [
            "lease_generation"
          ],
          "definition": "CHECK ((lease_generation > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_leases_key_present",
          "target": null,
          "columns": [
            "report_key"
          ],
          "definition": "CHECK (((report_key = btrim(report_key)) AND (report_key <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_lease_generation_not_null",
          "target": null,
          "columns": [
            "lease_generation"
          ],
          "definition": "NOT NULL lease_generation",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "report_export_leases_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_report_key_not_null",
          "target": null,
          "columns": [
            "report_key"
          ],
          "definition": "NOT NULL report_key",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_export_leases_state",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['running'::text, 'succeeded'::text, 'cancelled'::text, 'lost'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_export_leases_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00021_report_exports.sql"
      ]
    },
    {
      "rls": true,
      "name": "report_requests",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "text",
          "default": "'queued'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "artefact_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "report_requests_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX report_requests_pkey ON public.report_requests USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "report_request_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "report_requests_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_requests_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "report_requests_organisation_id_artefact_id_fkey",
          "target": "report_export_artefacts",
          "columns": [
            "organisation_id",
            "artefact_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, artefact_id) REFERENCES report_export_artefacts(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "report_requests_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "report_requests_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "report_requests_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "report_requests_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "report_requests_state_check",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "CHECK ((state = ANY (ARRAY['queued'::text, 'ready'::text, 'failed'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_requests_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "report_requests_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00039_report_requests.sql"
      ]
    },
    {
      "rls": true,
      "name": "resource_bookmarks",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "resource_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "resource_bookmarks_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id",
            "resource_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX resource_bookmarks_pkey ON public.resource_bookmarks USING btree (organisation_id, user_id, resource_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "resource_bookmarks_tenant",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "resource_bookmarks_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "resource_bookmarks_organisation_id_resource_id_fkey",
          "target": "learning_resources",
          "columns": [
            "organisation_id",
            "resource_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, resource_id) REFERENCES learning_resources(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "resource_bookmarks_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "resource_bookmarks_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id",
            "resource_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, user_id, resource_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "resource_bookmarks_resource_id_not_null",
          "target": null,
          "columns": [
            "resource_id"
          ],
          "definition": "NOT NULL resource_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "resource_bookmarks_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00042_resource_library.sql"
      ]
    },
    {
      "rls": false,
      "name": "river_client",
      "columns": [
        {
          "name": "id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "metadata",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "paused_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "river_client_pkey",
          "unique": true,
          "columns": [
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX river_client_pkey ON public.river_client USING btree (id)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "name_length",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "CHECK (((char_length(id) > 0) AND (char_length(id) < 128)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_metadata_not_null",
          "target": null,
          "columns": [
            "metadata"
          ],
          "definition": "NOT NULL metadata",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "river_client_pkey",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "PRIMARY KEY (id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": []
    },
    {
      "rls": false,
      "name": "river_client_queue",
      "columns": [
        {
          "name": "river_client_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "max_workers",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "metadata",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "num_jobs_completed",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "num_jobs_running",
          "type": "bigint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "river_client_queue_pkey",
          "unique": true,
          "columns": [
            "river_client_id",
            "name"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX river_client_queue_pkey ON public.river_client_queue USING btree (river_client_id, name)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "name_length",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "CHECK (((char_length(name) > 0) AND (char_length(name) < 128)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "num_jobs_completed_zero_or_positive",
          "target": null,
          "columns": [
            "num_jobs_completed"
          ],
          "definition": "CHECK ((num_jobs_completed >= 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "num_jobs_running_zero_or_positive",
          "target": null,
          "columns": [
            "num_jobs_running"
          ],
          "definition": "CHECK ((num_jobs_running >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_queue_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_queue_max_workers_not_null",
          "target": null,
          "columns": [
            "max_workers"
          ],
          "definition": "NOT NULL max_workers",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_queue_metadata_not_null",
          "target": null,
          "columns": [
            "metadata"
          ],
          "definition": "NOT NULL metadata",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_queue_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_queue_num_jobs_completed_not_null",
          "target": null,
          "columns": [
            "num_jobs_completed"
          ],
          "definition": "NOT NULL num_jobs_completed",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_queue_num_jobs_running_not_null",
          "target": null,
          "columns": [
            "num_jobs_running"
          ],
          "definition": "NOT NULL num_jobs_running",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "river_client_queue_pkey",
          "target": null,
          "columns": [
            "river_client_id",
            "name"
          ],
          "definition": "PRIMARY KEY (river_client_id, name)",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "river_client_queue_river_client_id_fkey",
          "target": "river_client",
          "columns": [
            "river_client_id"
          ],
          "definition": "FOREIGN KEY (river_client_id) REFERENCES river_client(id) ON DELETE CASCADE",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "river_client_queue_river_client_id_not_null",
          "target": null,
          "columns": [
            "river_client_id"
          ],
          "definition": "NOT NULL river_client_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_client_queue_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": []
    },
    {
      "rls": false,
      "name": "river_job",
      "columns": [
        {
          "name": "id",
          "type": "bigint",
          "default": "nextval('river_job_id_seq'::regclass)",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "state",
          "type": "river_job_state",
          "default": "'available'::river_job_state",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt",
          "type": "smallint",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "max_attempts",
          "type": "smallint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempted_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "finalized_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "scheduled_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "priority",
          "type": "smallint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "args",
          "type": "jsonb",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempted_by",
          "type": "text[]",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "errors",
          "type": "jsonb[]",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "kind",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "metadata",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "queue",
          "type": "text",
          "default": "'default'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "tags",
          "type": "character varying(255)[]",
          "default": "'{}'::character varying[]",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "unique_key",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "unique_states",
          "type": "bit(8)",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "river_job_args_index",
          "unique": false,
          "columns": [
            "args"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX river_job_args_index ON public.river_job USING gin (args)"
        },
        {
          "name": "river_job_kind",
          "unique": false,
          "columns": [
            "kind"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX river_job_kind ON public.river_job USING btree (kind)"
        },
        {
          "name": "river_job_metadata_index",
          "unique": false,
          "columns": [
            "metadata"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX river_job_metadata_index ON public.river_job USING gin (metadata)"
        },
        {
          "name": "river_job_pkey",
          "unique": true,
          "columns": [
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX river_job_pkey ON public.river_job USING btree (id)"
        },
        {
          "name": "river_job_prioritized_fetching_index",
          "unique": false,
          "columns": [
            "state",
            "queue",
            "priority",
            "scheduled_at",
            "id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX river_job_prioritized_fetching_index ON public.river_job USING btree (state, queue, priority, scheduled_at, id)"
        },
        {
          "name": "river_job_state_and_finalized_at_index",
          "unique": false,
          "columns": [
            "state",
            "finalized_at"
          ],
          "primary": false,
          "predicate": "(finalized_at IS NOT NULL)",
          "definition": "CREATE INDEX river_job_state_and_finalized_at_index ON public.river_job USING btree (state, finalized_at) WHERE (finalized_at IS NOT NULL)"
        },
        {
          "name": "river_job_unique_idx",
          "unique": true,
          "columns": [
            "unique_key"
          ],
          "primary": false,
          "predicate": "((unique_key IS NOT NULL) AND (unique_states IS NOT NULL) AND river_job_state_in_bitmask(unique_states, state))",
          "definition": "CREATE UNIQUE INDEX river_job_unique_idx ON public.river_job USING btree (unique_key) WHERE ((unique_key IS NOT NULL) AND (unique_states IS NOT NULL) AND river_job_state_in_bitmask(unique_states, state))"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "finalized_or_finalized_at_null",
          "target": null,
          "columns": [
            "finalized_at",
            "state"
          ],
          "definition": "CHECK ((((finalized_at IS NULL) AND (state <> ALL (ARRAY['cancelled'::river_job_state, 'completed'::river_job_state, 'discarded'::river_job_state]))) OR ((finalized_at IS NOT NULL) AND (state = ANY (ARRAY['cancelled'::river_job_state, 'completed'::river_job_state, 'discarded'::river_job_state])))))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "kind_length",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "CHECK (((char_length(kind) > 0) AND (char_length(kind) < 128)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "max_attempts_is_positive",
          "target": null,
          "columns": [
            "max_attempts"
          ],
          "definition": "CHECK ((max_attempts > 0))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "priority_in_range",
          "target": null,
          "columns": [
            "priority"
          ],
          "definition": "CHECK (((priority >= 1) AND (priority <= 4)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "queue_length",
          "target": null,
          "columns": [
            "queue"
          ],
          "definition": "CHECK (((char_length(queue) > 0) AND (char_length(queue) < 128)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_args_not_null",
          "target": null,
          "columns": [
            "args"
          ],
          "definition": "NOT NULL args",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_attempt_not_null",
          "target": null,
          "columns": [
            "attempt"
          ],
          "definition": "NOT NULL attempt",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_kind_not_null",
          "target": null,
          "columns": [
            "kind"
          ],
          "definition": "NOT NULL kind",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_max_attempts_not_null",
          "target": null,
          "columns": [
            "max_attempts"
          ],
          "definition": "NOT NULL max_attempts",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_metadata_not_null",
          "target": null,
          "columns": [
            "metadata"
          ],
          "definition": "NOT NULL metadata",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "river_job_pkey",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "PRIMARY KEY (id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_priority_not_null",
          "target": null,
          "columns": [
            "priority"
          ],
          "definition": "NOT NULL priority",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_queue_not_null",
          "target": null,
          "columns": [
            "queue"
          ],
          "definition": "NOT NULL queue",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_scheduled_at_not_null",
          "target": null,
          "columns": [
            "scheduled_at"
          ],
          "definition": "NOT NULL scheduled_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_state_not_null",
          "target": null,
          "columns": [
            "state"
          ],
          "definition": "NOT NULL state",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_job_tags_not_null",
          "target": null,
          "columns": [
            "tags"
          ],
          "definition": "NOT NULL tags",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": []
    },
    {
      "rls": false,
      "name": "river_leader",
      "columns": [
        {
          "name": "elected_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "leader_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": "'default'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "river_leader_pkey",
          "unique": true,
          "columns": [
            "name"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX river_leader_pkey ON public.river_leader USING btree (name)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "leader_id_length",
          "target": null,
          "columns": [
            "leader_id"
          ],
          "definition": "CHECK (((char_length(leader_id) > 0) AND (char_length(leader_id) < 128)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "name_length",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "CHECK ((name = 'default'::text))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_leader_elected_at_not_null",
          "target": null,
          "columns": [
            "elected_at"
          ],
          "definition": "NOT NULL elected_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_leader_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_leader_leader_id_not_null",
          "target": null,
          "columns": [
            "leader_id"
          ],
          "definition": "NOT NULL leader_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_leader_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "river_leader_pkey",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "PRIMARY KEY (name)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": []
    },
    {
      "rls": false,
      "name": "river_migration",
      "columns": [
        {
          "name": "line",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "version",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "river_migration_pkey1",
          "unique": true,
          "columns": [
            "line",
            "version"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX river_migration_pkey1 ON public.river_migration USING btree (line, version)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "line_length",
          "target": null,
          "columns": [
            "line"
          ],
          "definition": "CHECK (((char_length(line) > 0) AND (char_length(line) < 128)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_migration_created_at_not_null1",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_migration_line_not_null",
          "target": null,
          "columns": [
            "line"
          ],
          "definition": "NOT NULL line",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "river_migration_pkey1",
          "target": null,
          "columns": [
            "line",
            "version"
          ],
          "definition": "PRIMARY KEY (line, version)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_migration_version_not_null1",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "NOT NULL version",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "version_gte_1",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "CHECK ((version >= 1))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": []
    },
    {
      "rls": false,
      "name": "river_queue",
      "columns": [
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "metadata",
          "type": "jsonb",
          "default": "'{}'::jsonb",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "paused_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "river_queue_pkey",
          "unique": true,
          "columns": [
            "name"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX river_queue_pkey ON public.river_queue USING btree (name)"
        }
      ],
      "forceRls": false,
      "policies": [],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "river_queue_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_queue_metadata_not_null",
          "target": null,
          "columns": [
            "metadata"
          ],
          "definition": "NOT NULL metadata",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_queue_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "river_queue_pkey",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "PRIMARY KEY (name)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "river_queue_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": []
    },
    {
      "rls": true,
      "name": "role_bindings",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "role",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "unit_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "role_bindings_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id",
            "role",
            "unit_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX role_bindings_once ON public.role_bindings USING btree (organisation_id, user_id, role, unit_id) NULLS NOT DISTINCT"
        },
        {
          "name": "role_bindings_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX role_bindings_pkey ON public.role_bindings USING btree (organisation_id, id)"
        },
        {
          "name": "role_bindings_unit_user",
          "unique": false,
          "columns": [
            "organisation_id",
            "unit_id",
            "user_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX role_bindings_unit_user ON public.role_bindings USING btree (organisation_id, unit_id, user_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "role_bindings_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [
        "CREATE TRIGGER report_roles_changed AFTER INSERT OR DELETE OR UPDATE ON public.role_bindings FOR EACH ROW EXECUTE FUNCTION invalidate_report_scope()",
        "CREATE TRIGGER role_bindings_bump_authz AFTER INSERT OR DELETE OR UPDATE ON public.role_bindings FOR EACH ROW EXECUTE FUNCTION role_bindings_bump_authz()"
      ],
      "constraints": [
        {
          "kind": "n",
          "name": "role_bindings_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "role_bindings_once",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id",
            "role",
            "unit_id"
          ],
          "definition": "UNIQUE NULLS NOT DISTINCT (organisation_id, user_id, role, unit_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "role_bindings_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "role_bindings_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "role_bindings_role",
          "target": null,
          "columns": [
            "role"
          ],
          "definition": "CHECK ((role = ANY (ARRAY['owner'::text, 'administrator'::text, 'unit_manager'::text, 'author'::text, 'learner'::text, 'integration_principal'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "role_bindings_role_not_null",
          "target": null,
          "columns": [
            "role"
          ],
          "definition": "NOT NULL role",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "role_bindings_scope",
          "target": null,
          "columns": [
            "role",
            "unit_id"
          ],
          "definition": "CHECK ((((role = ANY (ARRAY['owner'::text, 'administrator'::text])) AND (unit_id IS NULL)) OR ((role = 'unit_manager'::text) AND (unit_id IS NOT NULL)) OR (role = ANY (ARRAY['author'::text, 'learner'::text, 'integration_principal'::text]))))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "role_bindings_unit_fk",
          "target": "units",
          "columns": [
            "organisation_id",
            "unit_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, unit_id) REFERENCES units(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "role_bindings_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "role_bindings_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00004_identity.sql",
        "migrations/00039_report_requests.sql",
        "migrations/00054_people_directory.sql"
      ]
    },
    {
      "rls": true,
      "name": "scim_connections",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "scim_connections_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX scim_connections_pkey ON public.scim_connections USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "scim_connections_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "scim_connections_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_connections_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_connections_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scim_connections_name_present",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "CHECK (((name = btrim(name)) AND (name <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scim_connections_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "scim_connections_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "scim_connections_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00023_scim_users.sql"
      ]
    },
    {
      "rls": true,
      "name": "scim_resources",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "connection_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "resource_type",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "external_id_blind",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "external_id_ciphertext",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "display_name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "active",
          "type": "boolean",
          "default": "true",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "version",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "email_index",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "tombstoned_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "scim_resources_external_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "connection_id",
            "resource_type",
            "external_id_blind"
          ],
          "primary": false,
          "predicate": "((external_id_blind IS NOT NULL) AND (tombstoned_at IS NULL))",
          "definition": "CREATE UNIQUE INDEX scim_resources_external_once ON public.scim_resources USING btree (organisation_id, connection_id, resource_type, external_id_blind) WHERE ((external_id_blind IS NOT NULL) AND (tombstoned_at IS NULL))"
        },
        {
          "name": "scim_resources_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX scim_resources_pkey ON public.scim_resources USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "scim_resources_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "scim_resources_active_not_null",
          "target": null,
          "columns": [
            "active"
          ],
          "definition": "NOT NULL active",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scim_resources_connection_fk",
          "target": "scim_connections",
          "columns": [
            "organisation_id",
            "connection_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, connection_id) REFERENCES scim_connections(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "scim_resources_connection_id_not_null",
          "target": null,
          "columns": [
            "connection_id"
          ],
          "definition": "NOT NULL connection_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_resources_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_resources_display_name_not_null",
          "target": null,
          "columns": [
            "display_name"
          ],
          "definition": "NOT NULL display_name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scim_resources_display_present",
          "target": null,
          "columns": [
            "display_name"
          ],
          "definition": "CHECK (((display_name = btrim(display_name)) AND (display_name <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scim_resources_email_index_len",
          "target": null,
          "columns": [
            "email_index"
          ],
          "definition": "CHECK (((email_index IS NULL) OR (octet_length(email_index) = 32)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scim_resources_external_pair",
          "target": null,
          "columns": [
            "external_id_blind",
            "external_id_ciphertext"
          ],
          "definition": "CHECK ((((external_id_blind IS NULL) AND (external_id_ciphertext IS NULL)) OR ((octet_length(external_id_blind) = 32) AND (external_id_ciphertext IS NOT NULL))))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_resources_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_resources_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "scim_resources_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_resources_resource_type_not_null",
          "target": null,
          "columns": [
            "resource_type"
          ],
          "definition": "NOT NULL resource_type",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scim_resources_type",
          "target": null,
          "columns": [
            "resource_type"
          ],
          "definition": "CHECK ((resource_type = ANY (ARRAY['User'::text, 'Group'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scim_resources_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scim_resources_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "scim_resources_version_not_null",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "NOT NULL version",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scim_resources_version_positive",
          "target": null,
          "columns": [
            "version"
          ],
          "definition": "CHECK ((version > 0))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00023_scim_users.sql",
        "migrations/00024_scim_groups.sql",
        "migrations/00025_scim_email_index.sql",
        "migrations/00026_scim_tombstone.sql"
      ]
    },
    {
      "rls": true,
      "name": "scorm_cmi_state",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "launch_registration_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "learning_session_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "committed_status",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "pending_status",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "open",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "updated_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "scorm_cmi_state_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX scorm_cmi_state_pkey ON public.scorm_cmi_state USING btree (organisation_id, enrolment_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "scorm_cmi_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "scorm_cmi_committed",
          "target": null,
          "columns": [
            "committed_status"
          ],
          "definition": "CHECK ((committed_status = ANY (ARRAY['passed'::text, 'completed'::text, 'failed'::text, 'incomplete'::text, 'browsed'::text, 'not attempted'::text])))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scorm_cmi_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "scorm_cmi_launch_fk",
          "target": "scorm_launch_registrations",
          "columns": [
            "organisation_id",
            "launch_registration_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, launch_registration_id) REFERENCES scorm_launch_registrations(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "c",
          "name": "scorm_cmi_pending",
          "target": null,
          "columns": [
            "pending_status"
          ],
          "definition": "CHECK (((pending_status IS NULL) OR (pending_status = ANY (ARRAY['passed'::text, 'completed'::text, 'failed'::text, 'incomplete'::text, 'browsed'::text, 'not attempted'::text]))))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scorm_cmi_session_fk",
          "target": "learning_sessions",
          "columns": [
            "organisation_id",
            "learning_session_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, learning_session_id) REFERENCES learning_sessions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_committed_status_not_null",
          "target": null,
          "columns": [
            "committed_status"
          ],
          "definition": "NOT NULL committed_status",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_launch_registration_id_not_null",
          "target": null,
          "columns": [
            "launch_registration_id"
          ],
          "definition": "NOT NULL launch_registration_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_learning_session_id_not_null",
          "target": null,
          "columns": [
            "learning_session_id"
          ],
          "definition": "NOT NULL learning_session_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_open_not_null",
          "target": null,
          "columns": [
            "open"
          ],
          "definition": "NOT NULL open",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "scorm_cmi_state_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, enrolment_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_cmi_state_updated_at_not_null",
          "target": null,
          "columns": [
            "updated_at"
          ],
          "definition": "NOT NULL updated_at",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00029_scorm_cmi_state.sql"
      ]
    },
    {
      "rls": true,
      "name": "scorm_launch_registrations",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "capability_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_version_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "package_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "launch_origin",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "launch_href",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "revoked_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "scorm_launch_hash_once",
          "unique": true,
          "columns": [
            "capability_hash"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX scorm_launch_hash_once ON public.scorm_launch_registrations USING btree (capability_hash)"
        },
        {
          "name": "scorm_launch_registrations_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX scorm_launch_registrations_pkey ON public.scorm_launch_registrations USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "scorm_launch_by_hash",
          "check": null,
          "roles": [
            "public"
          ],
          "using": "(capability_hash = decode(NULLIF(current_setting('app.scorm_launch_capability_hash'::text, true), ''::text), 'hex'::text))",
          "command": "SELECT",
          "permissive": "PERMISSIVE"
        },
        {
          "name": "scorm_launch_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "f",
          "name": "scorm_launch_enrolment_fk",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "u",
          "name": "scorm_launch_hash_once",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "UNIQUE (capability_hash)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scorm_launch_hash_present",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "CHECK ((octet_length(capability_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scorm_launch_href_present",
          "target": null,
          "columns": [
            "launch_href"
          ],
          "definition": "CHECK (((launch_href = btrim(launch_href)) AND (launch_href <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scorm_launch_origin_present",
          "target": null,
          "columns": [
            "launch_origin"
          ],
          "definition": "CHECK (((launch_origin = btrim(launch_origin)) AND (launch_origin <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scorm_launch_package_fk",
          "target": "scorm_packages",
          "columns": [
            "organisation_id",
            "package_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, package_id) REFERENCES scorm_packages(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_capability_hash_not_null",
          "target": null,
          "columns": [
            "capability_hash"
          ],
          "definition": "NOT NULL capability_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_course_version_id_not_null",
          "target": null,
          "columns": [
            "course_version_id"
          ],
          "definition": "NOT NULL course_version_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_launch_href_not_null",
          "target": null,
          "columns": [
            "launch_href"
          ],
          "definition": "NOT NULL launch_href",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_launch_origin_not_null",
          "target": null,
          "columns": [
            "launch_origin"
          ],
          "definition": "NOT NULL launch_origin",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_package_id_not_null",
          "target": null,
          "columns": [
            "package_id"
          ],
          "definition": "NOT NULL package_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "scorm_launch_registrations_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_launch_registrations_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scorm_launch_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "scorm_launch_version_fk",
          "target": "course_versions",
          "columns": [
            "organisation_id",
            "course_version_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_version_id) REFERENCES course_versions(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00028_scorm_launch_registrations.sql",
        "migrations/00029_scorm_cmi_state.sql"
      ]
    },
    {
      "rls": true,
      "name": "scorm_packages",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "course_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "object_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sha256",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "byte_length",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "item_title",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "launch_href",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "scorm_packages_course_once",
          "unique": true,
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX scorm_packages_course_once ON public.scorm_packages USING btree (organisation_id, course_id)"
        },
        {
          "name": "scorm_packages_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX scorm_packages_pkey ON public.scorm_packages USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "scorm_packages_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "scorm_packages_byte_length",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "CHECK ((byte_length > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_byte_length_not_null",
          "target": null,
          "columns": [
            "byte_length"
          ],
          "definition": "NOT NULL byte_length",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "scorm_packages_course_fk",
          "target": "courses",
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, course_id) REFERENCES courses(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "scorm_packages_course_id_not_null",
          "target": null,
          "columns": [
            "course_id"
          ],
          "definition": "NOT NULL course_id",
          "targetColumns": []
        },
        {
          "kind": "u",
          "name": "scorm_packages_course_once",
          "target": null,
          "columns": [
            "organisation_id",
            "course_id"
          ],
          "definition": "UNIQUE (organisation_id, course_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_item_title_not_null",
          "target": null,
          "columns": [
            "item_title"
          ],
          "definition": "NOT NULL item_title",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_launch_href_not_null",
          "target": null,
          "columns": [
            "launch_href"
          ],
          "definition": "NOT NULL launch_href",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scorm_packages_launch_present",
          "target": null,
          "columns": [
            "launch_href"
          ],
          "definition": "CHECK (((launch_href = btrim(launch_href)) AND (launch_href <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_object_id_not_null",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "NOT NULL object_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scorm_packages_object_present",
          "target": null,
          "columns": [
            "object_id"
          ],
          "definition": "CHECK (((object_id = btrim(object_id)) AND (object_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "scorm_packages_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scorm_packages_sha256",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "CHECK ((octet_length(sha256) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_sha256_not_null",
          "target": null,
          "columns": [
            "sha256"
          ],
          "definition": "NOT NULL sha256",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "scorm_packages_title_not_null",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "NOT NULL title",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "scorm_packages_title_present",
          "target": null,
          "columns": [
            "title"
          ],
          "definition": "CHECK (((title = btrim(title)) AND (title <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00027_scorm_packages.sql",
        "migrations/00028_scorm_launch_registrations.sql"
      ]
    },
    {
      "rls": true,
      "name": "step_up_challenges",
      "columns": [
        {
          "name": "state_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "session_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "issuer",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "subject",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "action",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "nonce",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "verifier",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "step_up_challenges_pkey",
          "unique": true,
          "columns": [
            "state_hash"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX step_up_challenges_pkey ON public.step_up_challenges USING btree (state_hash)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "step_up_by_hash",
          "check": "(state_hash = decode(NULLIF(current_setting('app.step_up_state_hash'::text, true), ''::text), 'hex'::text))",
          "roles": [
            "public"
          ],
          "using": "(state_hash = decode(NULLIF(current_setting('app.step_up_state_hash'::text, true), ''::text), 'hex'::text))",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "c",
          "name": "step_up_action_present",
          "target": null,
          "columns": [
            "action"
          ],
          "definition": "CHECK (((action = btrim(action)) AND (action <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_action_not_null",
          "target": null,
          "columns": [
            "action"
          ],
          "definition": "NOT NULL action",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_issuer_not_null",
          "target": null,
          "columns": [
            "issuer"
          ],
          "definition": "NOT NULL issuer",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_nonce_not_null",
          "target": null,
          "columns": [
            "nonce"
          ],
          "definition": "NOT NULL nonce",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "step_up_challenges_pkey",
          "target": null,
          "columns": [
            "state_hash"
          ],
          "definition": "PRIMARY KEY (state_hash)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_session_hash_not_null",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "NOT NULL session_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_state_hash_not_null",
          "target": null,
          "columns": [
            "state_hash"
          ],
          "definition": "NOT NULL state_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_subject_not_null",
          "target": null,
          "columns": [
            "subject"
          ],
          "definition": "NOT NULL subject",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "step_up_challenges_verifier_not_null",
          "target": null,
          "columns": [
            "verifier"
          ],
          "definition": "NOT NULL verifier",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "step_up_expiry",
          "target": null,
          "columns": [
            "expires_at",
            "created_at"
          ],
          "definition": "CHECK ((expires_at > created_at))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "step_up_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "c",
          "name": "step_up_session_hash",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "CHECK ((octet_length(session_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "step_up_state_hash",
          "target": null,
          "columns": [
            "state_hash"
          ],
          "definition": "CHECK ((octet_length(state_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "step_up_user_fk",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00007_step_up.sql"
      ]
    },
    {
      "rls": true,
      "name": "support_views",
      "columns": [
        {
          "name": "session_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "actor_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "target_organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "target_user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "target_authz_version",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "reason",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "expires_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "support_views_pkey",
          "unique": true,
          "columns": [
            "session_hash"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX support_views_pkey ON public.support_views USING btree (session_hash)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "support_views_session",
          "check": "(session_hash = decode(NULLIF(current_setting('app.session_hash'::text, true), ''::text), 'hex'::text))",
          "roles": [
            "public"
          ],
          "using": "(session_hash = decode(NULLIF(current_setting('app.session_hash'::text, true), ''::text), 'hex'::text))",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "support_views_actor_id_not_null",
          "target": null,
          "columns": [
            "actor_id"
          ],
          "definition": "NOT NULL actor_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "support_views_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "support_views_expires_at_not_null",
          "target": null,
          "columns": [
            "expires_at"
          ],
          "definition": "NOT NULL expires_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "support_views_organisation_id_actor_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "actor_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, actor_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "support_views_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "support_views_pkey",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "PRIMARY KEY (session_hash)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "support_views_reason_check",
          "target": null,
          "columns": [
            "reason"
          ],
          "definition": "CHECK (((length(reason) >= 10) AND (length(reason) <= 500)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "support_views_reason_not_null",
          "target": null,
          "columns": [
            "reason"
          ],
          "definition": "NOT NULL reason",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "support_views_session_hash_fkey",
          "target": "browser_sessions",
          "columns": [
            "session_hash"
          ],
          "definition": "FOREIGN KEY (session_hash) REFERENCES browser_sessions(session_hash) ON DELETE CASCADE",
          "targetColumns": [
            "session_hash"
          ]
        },
        {
          "kind": "n",
          "name": "support_views_session_hash_not_null",
          "target": null,
          "columns": [
            "session_hash"
          ],
          "definition": "NOT NULL session_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "support_views_target_authz_version_not_null",
          "target": null,
          "columns": [
            "target_authz_version"
          ],
          "definition": "NOT NULL target_authz_version",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "support_views_target_organisation_id_not_null",
          "target": null,
          "columns": [
            "target_organisation_id"
          ],
          "definition": "NOT NULL target_organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "support_views_target_organisation_id_target_user_id_fkey",
          "target": "users",
          "columns": [
            "target_organisation_id",
            "target_user_id"
          ],
          "definition": "FOREIGN KEY (target_organisation_id, target_user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "support_views_target_user_id_not_null",
          "target": null,
          "columns": [
            "target_user_id"
          ],
          "definition": "NOT NULL target_user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00055_support_views.sql"
      ]
    },
    {
      "rls": true,
      "name": "tenant_keys",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "wrapped_dek",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "wrapped_index",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "tenant_keys_pkey",
          "unique": true,
          "columns": [
            "organisation_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX tenant_keys_pkey ON public.tenant_keys USING btree (organisation_id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_keys_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "tenant_keys_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "tenant_keys_dek_present",
          "target": null,
          "columns": [
            "wrapped_dek"
          ],
          "definition": "CHECK ((wrapped_dek <> ''::text))",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "tenant_keys_index_present",
          "target": null,
          "columns": [
            "wrapped_index"
          ],
          "definition": "CHECK ((wrapped_index <> ''::text))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "tenant_keys_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "tenant_keys_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "tenant_keys_pkey",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "PRIMARY KEY (organisation_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "tenant_keys_wrapped_dek_not_null",
          "target": null,
          "columns": [
            "wrapped_dek"
          ],
          "definition": "NOT NULL wrapped_dek",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "tenant_keys_wrapped_index_not_null",
          "target": null,
          "columns": [
            "wrapped_index"
          ],
          "definition": "NOT NULL wrapped_index",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00008_profiles.sql"
      ]
    },
    {
      "rls": true,
      "name": "units",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "parent_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "units_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX units_pkey ON public.units USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "units_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [
        "CREATE TRIGGER report_units_changed AFTER INSERT OR DELETE OR UPDATE ON public.units FOR EACH ROW EXECUTE FUNCTION invalidate_report_scope()",
        "CREATE TRIGGER units_reject_cycle BEFORE INSERT OR UPDATE OF parent_id ON public.units FOR EACH ROW EXECUTE FUNCTION units_reject_cycle()"
      ],
      "constraints": [
        {
          "kind": "n",
          "name": "units_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "units_name_not_null",
          "target": null,
          "columns": [
            "name"
          ],
          "definition": "NOT NULL name",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "units_not_own_parent",
          "target": null,
          "columns": [
            "parent_id",
            "id"
          ],
          "definition": "CHECK (((parent_id IS NULL) OR (parent_id <> id)))",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "units_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "units_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "units_parent_fk",
          "target": "units",
          "columns": [
            "organisation_id",
            "parent_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, parent_id) REFERENCES units(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "p",
          "name": "units_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00003_organisations.sql",
        "migrations/00004_identity.sql",
        "migrations/00039_report_requests.sql",
        "migrations/00053_collections_pathways.sql"
      ]
    },
    {
      "rls": true,
      "name": "users",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "display_name",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "suspended",
          "type": "boolean",
          "default": "false",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "authz_version",
          "type": "bigint",
          "default": "1",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "learner_kind",
          "type": "text",
          "default": "'corporate'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "people_name_order",
          "unique": false,
          "columns": [
            "organisation_id",
            null,
            "id"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX people_name_order ON public.users USING btree (organisation_id, lower(display_name), id)"
        },
        {
          "name": "users_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX users_pkey ON public.users USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "users_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "users_authz_version_not_null",
          "target": null,
          "columns": [
            "authz_version"
          ],
          "definition": "NOT NULL authz_version",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "users_authz_version_positive",
          "target": null,
          "columns": [
            "authz_version"
          ],
          "definition": "CHECK ((authz_version > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "users_display_name_not_null",
          "target": null,
          "columns": [
            "display_name"
          ],
          "definition": "NOT NULL display_name",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "users_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "users_learner_kind",
          "target": null,
          "columns": [
            "learner_kind"
          ],
          "definition": "CHECK ((learner_kind = ANY (ARRAY['corporate'::text, 'restricted_external'::text, 'dispatch'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "users_learner_kind_not_null",
          "target": null,
          "columns": [
            "learner_kind"
          ],
          "definition": "NOT NULL learner_kind",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "users_organisation_fk",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "users_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "users_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "users_suspended_not_null",
          "target": null,
          "columns": [
            "suspended"
          ],
          "definition": "NOT NULL suspended",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00004_identity.sql",
        "migrations/00005_browser_sessions.sql",
        "migrations/00006_invitations.sql",
        "migrations/00007_step_up.sql",
        "migrations/00008_profiles.sql",
        "migrations/00011_enrolments.sql",
        "migrations/00013_learning_progress.sql",
        "migrations/00014_quiz_attempts.sql",
        "migrations/00016_media_leases.sql",
        "migrations/00018_certificates.sql",
        "migrations/00019_certificate_revocation.sql",
        "migrations/00020_refresher_schedule.sql",
        "migrations/00021_report_exports.sql",
        "migrations/00022_report_download_authority.sql",
        "migrations/00023_scim_users.sql",
        "migrations/00024_scim_groups.sql",
        "migrations/00026_scim_tombstone.sql",
        "migrations/00028_scorm_launch_registrations.sql",
        "migrations/00031_dispatch_registrations.sql",
        "migrations/00035_native_workspace.sql",
        "migrations/00039_report_requests.sql",
        "migrations/00042_resource_library.sql",
        "migrations/00043_course_bookmarks.sql",
        "migrations/00044_messaging.sql",
        "migrations/00049_learning_packages.sql",
        "migrations/00050_ai_draft_requests.sql",
        "migrations/00053_collections_pathways.sql",
        "migrations/00054_people_directory.sql",
        "migrations/00055_support_views.sql"
      ]
    },
    {
      "rls": true,
      "name": "video_engagement",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enrolment_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "activity_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "playback_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "sequence",
          "type": "bigint",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "position",
          "type": "double precision",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "duration",
          "type": "double precision",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "watched_seconds",
          "type": "double precision",
          "default": "0",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "playing",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "rate",
          "type": "double precision",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "last_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "video_engagement_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id",
            "playback_id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX video_engagement_pkey ON public.video_engagement USING btree (organisation_id, enrolment_id, activity_id, playback_id)"
        },
        {
          "name": "video_engagement_resume",
          "unique": false,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id",
            "last_at"
          ],
          "primary": false,
          "predicate": null,
          "definition": "CREATE INDEX video_engagement_resume ON public.video_engagement USING btree (organisation_id, enrolment_id, activity_id, last_at DESC)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "tenant_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "video_engagement_activity_id_not_null",
          "target": null,
          "columns": [
            "activity_id"
          ],
          "definition": "NOT NULL activity_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_duration_not_null",
          "target": null,
          "columns": [
            "duration"
          ],
          "definition": "NOT NULL duration",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_enrolment_id_not_null",
          "target": null,
          "columns": [
            "enrolment_id"
          ],
          "definition": "NOT NULL enrolment_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_last_at_not_null",
          "target": null,
          "columns": [
            "last_at"
          ],
          "definition": "NOT NULL last_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "video_engagement_organisation_id_activity_id_fkey",
          "target": "course_version_activities",
          "columns": [
            "organisation_id",
            "activity_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, activity_id) REFERENCES course_version_activities(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "f",
          "name": "video_engagement_organisation_id_enrolment_id_fkey",
          "target": "enrolments",
          "columns": [
            "organisation_id",
            "enrolment_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, enrolment_id) REFERENCES enrolments(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "video_engagement_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "video_engagement_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "enrolment_id",
            "activity_id",
            "playback_id"
          ],
          "definition": "PRIMARY KEY (organisation_id, enrolment_id, activity_id, playback_id)",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_playback_id_not_null",
          "target": null,
          "columns": [
            "playback_id"
          ],
          "definition": "NOT NULL playback_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_playing_not_null",
          "target": null,
          "columns": [
            "playing"
          ],
          "definition": "NOT NULL playing",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_position_not_null",
          "target": null,
          "columns": [
            "position"
          ],
          "definition": "NOT NULL \"position\"",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_rate_not_null",
          "target": null,
          "columns": [
            "rate"
          ],
          "definition": "NOT NULL rate",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_sequence_not_null",
          "target": null,
          "columns": [
            "sequence"
          ],
          "definition": "NOT NULL sequence",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "video_engagement_watched_seconds_not_null",
          "target": null,
          "columns": [
            "watched_seconds"
          ],
          "definition": "NOT NULL watched_seconds",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00045_experience.sql"
      ]
    },
    {
      "rls": true,
      "name": "webhook_deliveries",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "endpoint_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "event_id",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "event_type",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "payload",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "attempt_count",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "next_attempt_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "delivered_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "failed_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "last_status",
          "type": "integer",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "webhook_deliveries_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX webhook_deliveries_pkey ON public.webhook_deliveries USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "webhook_deliveries_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "webhook_deliveries_attempt_count_not_null",
          "target": null,
          "columns": [
            "attempt_count"
          ],
          "definition": "NOT NULL attempt_count",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "webhook_deliveries_attempts",
          "target": null,
          "columns": [
            "attempt_count"
          ],
          "definition": "CHECK ((attempt_count >= 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "webhook_deliveries_endpoint_fk",
          "target": "webhook_endpoints",
          "columns": [
            "organisation_id",
            "endpoint_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, endpoint_id) REFERENCES webhook_endpoints(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_endpoint_id_not_null",
          "target": null,
          "columns": [
            "endpoint_id"
          ],
          "definition": "NOT NULL endpoint_id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_event_id_not_null",
          "target": null,
          "columns": [
            "event_id"
          ],
          "definition": "NOT NULL event_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "webhook_deliveries_event_present",
          "target": null,
          "columns": [
            "event_id"
          ],
          "definition": "CHECK (((event_id = btrim(event_id)) AND (event_id <> ''::text)))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_event_type_not_null",
          "target": null,
          "columns": [
            "event_type"
          ],
          "definition": "NOT NULL event_type",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_next_attempt_at_not_null",
          "target": null,
          "columns": [
            "next_attempt_at"
          ],
          "definition": "NOT NULL next_attempt_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "webhook_deliveries_payload",
          "target": null,
          "columns": [
            "payload"
          ],
          "definition": "CHECK ((octet_length(payload) > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_deliveries_payload_not_null",
          "target": null,
          "columns": [
            "payload"
          ],
          "definition": "NOT NULL payload",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "webhook_deliveries_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "webhook_deliveries_type_present",
          "target": null,
          "columns": [
            "event_type"
          ],
          "definition": "CHECK (((event_type = btrim(event_type)) AND (event_type <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00033_api_keys_webhooks.sql"
      ]
    },
    {
      "rls": true,
      "name": "webhook_endpoints",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "url",
          "type": "text",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "secret_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "event_types",
          "type": "text[]",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "enabled",
          "type": "boolean",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "disabled_at",
          "type": "timestamp with time zone",
          "default": null,
          "identity": "",
          "nullable": true,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "webhook_endpoints_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX webhook_endpoints_pkey ON public.webhook_endpoints USING btree (organisation_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "webhook_endpoints_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "webhook_endpoints_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_endpoints_enabled_not_null",
          "target": null,
          "columns": [
            "enabled"
          ],
          "definition": "NOT NULL enabled",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_endpoints_event_types_not_null",
          "target": null,
          "columns": [
            "event_types"
          ],
          "definition": "NOT NULL event_types",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "webhook_endpoints_events",
          "target": null,
          "columns": [
            "event_types"
          ],
          "definition": "CHECK ((cardinality(event_types) > 0))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_endpoints_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_endpoints_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "webhook_endpoints_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "webhook_endpoints_secret",
          "target": null,
          "columns": [
            "secret_hash"
          ],
          "definition": "CHECK ((octet_length(secret_hash) = 32))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_endpoints_secret_hash_not_null",
          "target": null,
          "columns": [
            "secret_hash"
          ],
          "definition": "NOT NULL secret_hash",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "webhook_endpoints_url_not_null",
          "target": null,
          "columns": [
            "url"
          ],
          "definition": "NOT NULL url",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "webhook_endpoints_url_present",
          "target": null,
          "columns": [
            "url"
          ],
          "definition": "CHECK (((url = btrim(url)) AND (url <> ''::text)))",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00033_api_keys_webhooks.sql"
      ]
    },
    {
      "rls": true,
      "name": "workspace_commands",
      "columns": [
        {
          "name": "organisation_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "user_id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "id",
          "type": "uuid",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "payload_hash",
          "type": "bytea",
          "default": null,
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "created_at",
          "type": "timestamp with time zone",
          "default": "now()",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        },
        {
          "name": "result",
          "type": "text",
          "default": "'accepted'::text",
          "identity": "",
          "nullable": false,
          "generated": "",
          "description": null
        }
      ],
      "indexes": [
        {
          "name": "workspace_commands_pkey",
          "unique": true,
          "columns": [
            "organisation_id",
            "user_id",
            "id"
          ],
          "primary": true,
          "predicate": null,
          "definition": "CREATE UNIQUE INDEX workspace_commands_pkey ON public.workspace_commands USING btree (organisation_id, user_id, id)"
        }
      ],
      "forceRls": true,
      "policies": [
        {
          "name": "workspace_commands_isolation",
          "check": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "roles": [
            "public"
          ],
          "using": "(organisation_id = (NULLIF(current_setting('app.organisation_id'::text, true), ''::text))::uuid)",
          "command": "ALL",
          "permissive": "PERMISSIVE"
        }
      ],
      "triggers": [],
      "constraints": [
        {
          "kind": "n",
          "name": "workspace_commands_created_at_not_null",
          "target": null,
          "columns": [
            "created_at"
          ],
          "definition": "NOT NULL created_at",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "workspace_commands_id_not_null",
          "target": null,
          "columns": [
            "id"
          ],
          "definition": "NOT NULL id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "workspace_commands_organisation_id_fkey",
          "target": "organisations",
          "columns": [
            "organisation_id"
          ],
          "definition": "FOREIGN KEY (organisation_id) REFERENCES organisations(id)",
          "targetColumns": [
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "workspace_commands_organisation_id_not_null",
          "target": null,
          "columns": [
            "organisation_id"
          ],
          "definition": "NOT NULL organisation_id",
          "targetColumns": []
        },
        {
          "kind": "f",
          "name": "workspace_commands_organisation_id_user_id_fkey",
          "target": "users",
          "columns": [
            "organisation_id",
            "user_id"
          ],
          "definition": "FOREIGN KEY (organisation_id, user_id) REFERENCES users(organisation_id, id)",
          "targetColumns": [
            "organisation_id",
            "id"
          ]
        },
        {
          "kind": "n",
          "name": "workspace_commands_payload_hash_not_null",
          "target": null,
          "columns": [
            "payload_hash"
          ],
          "definition": "NOT NULL payload_hash",
          "targetColumns": []
        },
        {
          "kind": "p",
          "name": "workspace_commands_pkey",
          "target": null,
          "columns": [
            "organisation_id",
            "user_id",
            "id"
          ],
          "definition": "PRIMARY KEY (organisation_id, user_id, id)",
          "targetColumns": []
        },
        {
          "kind": "c",
          "name": "workspace_commands_result_check",
          "target": null,
          "columns": [
            "result"
          ],
          "definition": "CHECK ((result = ANY (ARRAY['accepted'::text, 'incorrect'::text])))",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "workspace_commands_result_not_null",
          "target": null,
          "columns": [
            "result"
          ],
          "definition": "NOT NULL result",
          "targetColumns": []
        },
        {
          "kind": "n",
          "name": "workspace_commands_user_id_not_null",
          "target": null,
          "columns": [
            "user_id"
          ],
          "definition": "NOT NULL user_id",
          "targetColumns": []
        }
      ],
      "description": null,
      "migrations": [
        "migrations/00035_native_workspace.sql",
        "migrations/00036_workspace_command_results.sql"
      ]
    }
  ],
  "sourceHash": "ead025213173c8e102451f2b6970a54659a218d7cb629529118bd863f2a11928",
  "schemaVersion": 55,
  "postgresMajor": 18,
  "provenance": "Generated from an empty disposable PostgreSQL database after all Go-admin migrations, including River; no customer rows exported.",
  "migrationFiles": [
    "migrations/00001_synthetic_tenant_guard.sql",
    "migrations/00002_platform_object_location.sql",
    "migrations/00003_organisations.sql",
    "migrations/00004_identity.sql",
    "migrations/00005_browser_sessions.sql",
    "migrations/00006_invitations.sql",
    "migrations/00007_step_up.sql",
    "migrations/00008_profiles.sql",
    "migrations/00009_drafts.sql",
    "migrations/00010_course_versions.sql",
    "migrations/00011_enrolments.sql",
    "migrations/00012_quarantine.sql",
    "migrations/00013_learning_progress.sql",
    "migrations/00014_quiz_attempts.sql",
    "migrations/00015_completions.sql",
    "migrations/00016_media_leases.sql",
    "migrations/00017_media_renditions.sql",
    "migrations/00018_certificates.sql",
    "migrations/00019_certificate_revocation.sql",
    "migrations/00020_refresher_schedule.sql",
    "migrations/00021_report_exports.sql",
    "migrations/00022_report_download_authority.sql",
    "migrations/00023_scim_users.sql",
    "migrations/00024_scim_groups.sql",
    "migrations/00025_scim_email_index.sql",
    "migrations/00026_scim_tombstone.sql",
    "migrations/00027_scorm_packages.sql",
    "migrations/00028_scorm_launch_registrations.sql",
    "migrations/00029_scorm_cmi_state.sql",
    "migrations/00030_dispatch_destinations.sql",
    "migrations/00031_dispatch_registrations.sql",
    "migrations/00032_dispatch_results.sql",
    "migrations/00033_api_keys_webhooks.sql",
    "migrations/00034_extensions.sql",
    "migrations/00035_native_workspace.sql",
    "migrations/00036_workspace_command_results.sql",
    "migrations/00037_recovery_admission.sql",
    "migrations/00038_certificate_render_leases.sql",
    "migrations/00039_report_requests.sql",
    "migrations/00040_oidc_session_revocation.sql",
    "migrations/00041_organisation_administration.sql",
    "migrations/00042_resource_library.sql",
    "migrations/00043_course_bookmarks.sql",
    "migrations/00044_messaging.sql",
    "migrations/00045_experience.sql",
    "migrations/00046_course_builder.sql",
    "migrations/00047_multi_company_sso.sql",
    "migrations/00048_company_addresses.sql",
    "migrations/00049_learning_packages.sql",
    "migrations/00050_ai_draft_requests.sql",
    "migrations/00051_ai_resource_assistance.sql",
    "migrations/00052_ai_provider_management.sql",
    "migrations/00053_collections_pathways.sql",
    "migrations/00054_people_directory.sql",
    "migrations/00055_support_views.sql"
  ]
}
