CREATE SCHEMA gitlab_partitions_dynamic;

COMMENT ON SCHEMA gitlab_partitions_dynamic IS 'Schema to hold partitions managed dynamically from the application, e.g. for time space partitioning.';

CREATE SCHEMA gitlab_partitions_static;

COMMENT ON SCHEMA gitlab_partitions_static IS 'Schema to hold static partitions, e.g. for hash partitioning';

CREATE EXTENSION IF NOT EXISTS btree_gist;

CREATE EXTENSION IF NOT EXISTS pg_trgm;

CREATE FUNCTION assign_ci_runner_taggings_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('ci_runner_taggings_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_build_tags_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('p_ci_build_tags_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_builds_execution_configs_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('p_ci_builds_execution_configs_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_builds_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('ci_builds_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_job_annotations_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('p_ci_job_annotations_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_job_artifacts_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('ci_job_artifacts_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_pipeline_variables_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('ci_pipeline_variables_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_pipelines_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('ci_pipelines_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_p_ci_stages_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('ci_stages_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION assign_zoekt_tasks_id_value() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."id" IS NOT NULL THEN
  RAISE WARNING 'Manually assigning ids is not allowed, the value will be ignored';
END IF;
NEW."id" := nextval('zoekt_tasks_id_seq'::regclass);
RETURN NEW;

END
$$;

CREATE FUNCTION delete_associated_project_namespace() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
DELETE FROM namespaces
WHERE namespaces.id = OLD.project_namespace_id AND
namespaces.type = 'Project';
RETURN NULL;

END
$$;

CREATE TABLE namespaces (
    id bigint NOT NULL,
    name character varying NOT NULL,
    path character varying NOT NULL,
    owner_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    type character varying DEFAULT 'User'::character varying NOT NULL,
    description character varying DEFAULT ''::character varying NOT NULL,
    avatar character varying,
    membership_lock boolean DEFAULT false,
    share_with_group_lock boolean DEFAULT false,
    visibility_level integer DEFAULT 20 NOT NULL,
    request_access_enabled boolean DEFAULT true NOT NULL,
    ldap_sync_status character varying DEFAULT 'ready'::character varying NOT NULL,
    ldap_sync_error character varying,
    ldap_sync_last_update_at timestamp without time zone,
    ldap_sync_last_successful_update_at timestamp without time zone,
    ldap_sync_last_sync_at timestamp without time zone,
    description_html text,
    lfs_enabled boolean,
    parent_id bigint,
    shared_runners_minutes_limit integer,
    repository_size_limit bigint,
    require_two_factor_authentication boolean DEFAULT false NOT NULL,
    two_factor_grace_period integer DEFAULT 48 NOT NULL,
    cached_markdown_version integer,
    project_creation_level integer,
    runners_token character varying,
    file_template_project_id bigint,
    saml_discovery_token character varying,
    runners_token_encrypted character varying,
    custom_project_templates_group_id bigint,
    auto_devops_enabled boolean,
    extra_shared_runners_minutes_limit integer,
    last_ci_minutes_notification_at timestamp with time zone,
    last_ci_minutes_usage_notification_level integer,
    subgroup_creation_level integer DEFAULT 1,
    emails_disabled boolean,
    max_pages_size integer,
    max_artifacts_size integer,
    mentions_disabled boolean,
    default_branch_protection smallint,
    unlock_membership_to_ldap boolean,
    max_personal_access_token_lifetime integer,
    push_rule_id bigint,
    shared_runners_enabled boolean DEFAULT true NOT NULL,
    allow_descendants_override_disabled_shared_runners boolean DEFAULT false NOT NULL,
    traversal_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL,
    organization_id bigint DEFAULT 1
);

CREATE FUNCTION find_namespaces_by_id(namespaces_id bigint) RETURNS namespaces
    LANGUAGE plpgsql STABLE COST 1 PARALLEL SAFE
    AS $$
BEGIN
  return (SELECT namespaces FROM namespaces WHERE id = namespaces_id LIMIT 1);
END;
$$;

CREATE TABLE projects (
    id bigint NOT NULL,
    name character varying,
    path character varying,
    description text,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    creator_id bigint,
    namespace_id bigint NOT NULL,
    last_activity_at timestamp without time zone,
    import_url character varying,
    visibility_level integer DEFAULT 0 NOT NULL,
    archived boolean DEFAULT false NOT NULL,
    avatar character varying,
    merge_requests_template text,
    star_count integer DEFAULT 0 NOT NULL,
    merge_requests_rebase_enabled boolean DEFAULT false,
    import_type character varying,
    import_source character varying,
    approvals_before_merge integer DEFAULT 0 NOT NULL,
    reset_approvals_on_push boolean DEFAULT true,
    merge_requests_ff_only_enabled boolean DEFAULT false,
    issues_template text,
    mirror boolean DEFAULT false NOT NULL,
    mirror_last_update_at timestamp without time zone,
    mirror_last_successful_update_at timestamp without time zone,
    mirror_user_id bigint,
    shared_runners_enabled boolean DEFAULT true NOT NULL,
    runners_token character varying,
    build_allow_git_fetch boolean DEFAULT true NOT NULL,
    build_timeout integer DEFAULT 3600 NOT NULL,
    mirror_trigger_builds boolean DEFAULT false NOT NULL,
    pending_delete boolean DEFAULT false,
    public_builds boolean DEFAULT true NOT NULL,
    last_repository_check_failed boolean,
    last_repository_check_at timestamp without time zone,
    only_allow_merge_if_pipeline_succeeds boolean DEFAULT false NOT NULL,
    has_external_issue_tracker boolean,
    repository_storage character varying DEFAULT 'default'::character varying NOT NULL,
    repository_read_only boolean,
    request_access_enabled boolean DEFAULT true NOT NULL,
    has_external_wiki boolean,
    ci_config_path character varying,
    lfs_enabled boolean,
    description_html text,
    only_allow_merge_if_all_discussions_are_resolved boolean,
    repository_size_limit bigint,
    printing_merge_request_link_enabled boolean DEFAULT true NOT NULL,
    auto_cancel_pending_pipelines integer DEFAULT 1 NOT NULL,
    service_desk_enabled boolean DEFAULT true,
    cached_markdown_version integer,
    delete_error text,
    last_repository_updated_at timestamp without time zone,
    disable_overriding_approvers_per_merge_request boolean,
    storage_version smallint,
    resolve_outdated_diff_discussions boolean,
    remote_mirror_available_overridden boolean,
    only_mirror_protected_branches boolean,
    pull_mirror_available_overridden boolean,
    jobs_cache_index integer,
    external_authorization_classification_label character varying,
    mirror_overwrites_diverged_branches boolean,
    pages_https_only boolean DEFAULT true,
    external_webhook_token character varying,
    packages_enabled boolean,
    merge_requests_author_approval boolean DEFAULT false,
    pool_repository_id bigint,
    runners_token_encrypted character varying,
    bfg_object_map character varying,
    detected_repository_languages boolean,
    merge_requests_disable_committers_approval boolean,
    require_password_to_approve boolean,
    emails_disabled boolean,
    max_pages_size integer,
    max_artifacts_size integer,
    pull_mirror_branch_prefix character varying(50),
    remove_source_branch_after_merge boolean,
    marked_for_deletion_at date,
    marked_for_deletion_by_user_id bigint,
    autoclose_referenced_issues boolean,
    suggestion_commit_message character varying(255),
    project_namespace_id bigint,
    hidden boolean DEFAULT false NOT NULL,
    organization_id bigint
);

CREATE FUNCTION find_projects_by_id(projects_id bigint) RETURNS projects
    LANGUAGE plpgsql STABLE COST 1 PARALLEL SAFE
    AS $$
BEGIN
  return (SELECT projects FROM projects WHERE id = projects_id LIMIT 1);
END;
$$;

CREATE TABLE users (
    id bigint NOT NULL,
    email character varying DEFAULT ''::character varying NOT NULL,
    encrypted_password character varying DEFAULT ''::character varying NOT NULL,
    reset_password_token character varying,
    reset_password_sent_at timestamp without time zone,
    remember_created_at timestamp without time zone,
    sign_in_count integer DEFAULT 0,
    current_sign_in_at timestamp without time zone,
    last_sign_in_at timestamp without time zone,
    current_sign_in_ip character varying,
    last_sign_in_ip character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    name character varying,
    admin boolean DEFAULT false NOT NULL,
    projects_limit integer NOT NULL,
    failed_attempts integer DEFAULT 0,
    locked_at timestamp without time zone,
    username character varying,
    can_create_group boolean DEFAULT true NOT NULL,
    can_create_team boolean DEFAULT true NOT NULL,
    state character varying,
    color_scheme_id bigint DEFAULT 1 NOT NULL,
    password_expires_at timestamp without time zone,
    created_by_id bigint,
    last_credential_check_at timestamp without time zone,
    avatar character varying,
    confirmation_token character varying,
    confirmed_at timestamp without time zone,
    confirmation_sent_at timestamp without time zone,
    unconfirmed_email character varying,
    hide_no_ssh_key boolean DEFAULT false,
    admin_email_unsubscribed_at timestamp without time zone,
    notification_email character varying,
    hide_no_password boolean DEFAULT false,
    password_automatically_set boolean DEFAULT false,
    encrypted_otp_secret character varying,
    encrypted_otp_secret_iv character varying,
    encrypted_otp_secret_salt character varying,
    otp_required_for_login boolean DEFAULT false NOT NULL,
    otp_backup_codes text,
    public_email character varying,
    dashboard integer DEFAULT 0,
    project_view integer DEFAULT 2,
    consumed_timestep integer,
    layout integer DEFAULT 0,
    hide_project_limit boolean DEFAULT false,
    note text,
    unlock_token character varying,
    otp_grace_period_started_at timestamp without time zone,
    external boolean DEFAULT false,
    incoming_email_token character varying,
    auditor boolean DEFAULT false NOT NULL,
    require_two_factor_authentication_from_group boolean DEFAULT false NOT NULL,
    two_factor_grace_period integer DEFAULT 48 NOT NULL,
    last_activity_on date,
    notified_of_own_activity boolean DEFAULT false,
    preferred_language character varying,
    theme_id smallint,
    accepted_term_id bigint,
    feed_token character varying,
    private_profile boolean DEFAULT false NOT NULL,
    roadmap_layout smallint,
    include_private_contributions boolean,
    commit_email character varying,
    group_view integer,
    managing_group_id bigint,
    first_name character varying(255),
    last_name character varying(255),
    static_object_token character varying(255),
    role smallint,
    user_type smallint DEFAULT 0,
    static_object_token_encrypted text,
    otp_secret_expires_at timestamp with time zone,
    onboarding_in_progress boolean DEFAULT false NOT NULL,
    color_mode_id smallint DEFAULT 1 NOT NULL,
    last_access_from_pipl_country_at timestamp with time zone,
    CONSTRAINT check_061f6f1c91 CHECK ((project_view IS NOT NULL)),
    CONSTRAINT check_0dd5948e38 CHECK ((user_type IS NOT NULL)),
    CONSTRAINT check_3a60c18afc CHECK ((hide_no_password IS NOT NULL)),
    CONSTRAINT check_693c6f3aab CHECK ((hide_no_ssh_key IS NOT NULL)),
    CONSTRAINT check_7bde697e8e CHECK ((char_length(static_object_token_encrypted) <= 255)),
    CONSTRAINT check_c737c04b87 CHECK ((notified_of_own_activity IS NOT NULL))
);

CREATE FUNCTION find_users_by_id(users_id bigint) RETURNS users
    LANGUAGE plpgsql STABLE COST 1 PARALLEL SAFE
    AS $$
BEGIN
  return (SELECT users FROM users WHERE id = users_id LIMIT 1);
END;
$$;

CREATE FUNCTION gitlab_schema_prevent_write() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    IF COALESCE(NULLIF(current_setting(CONCAT('lock_writes.', TG_TABLE_NAME), true), ''), 'true') THEN
      RAISE EXCEPTION 'Table: "%" is write protected within this Gitlab database.', TG_TABLE_NAME
        USING ERRCODE = 'modifying_sql_data_not_permitted',
        HINT = 'Make sure you are using the right database connection';
    END IF;
    RETURN NEW;
END
$$;

CREATE FUNCTION insert_catalog_resource_sync_event() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
INSERT INTO p_catalog_resource_sync_events (catalog_resource_id, project_id)
SELECT id, OLD.id FROM catalog_resources
WHERE project_id = OLD.id;
RETURN NULL;

END
$$;

CREATE FUNCTION insert_into_loose_foreign_keys_deleted_records() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
  INSERT INTO loose_foreign_keys_deleted_records
  (fully_qualified_table_name, primary_key_value)
  SELECT TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table;

  RETURN NULL;
END
$$;

CREATE FUNCTION insert_namespaces_sync_event() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
INSERT INTO namespaces_sync_events (namespace_id)
VALUES(COALESCE(NEW.id, OLD.id));
RETURN NULL;

END
$$;

CREATE FUNCTION insert_or_update_vulnerability_reads() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
  severity smallint;
  state smallint;
  report_type smallint;
  resolved_on_default_branch boolean;
  present_on_default_branch boolean;
  has_issues boolean;
  has_merge_request boolean;
BEGIN
  IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN
    RETURN NULL;
  END IF;

  IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN
    RETURN NULL;
  END IF;

  SELECT
    vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch, vulnerabilities.present_on_default_branch
  INTO
    severity, state, report_type, resolved_on_default_branch, present_on_default_branch
  FROM
    vulnerabilities
  WHERE
    vulnerabilities.id = NEW.vulnerability_id;

  IF present_on_default_branch IS NOT true THEN
    RETURN NULL;
  END IF;

  SELECT
    EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.vulnerability_id)
  INTO
    has_issues;

  SELECT
    EXISTS (SELECT 1 FROM vulnerability_merge_request_links WHERE vulnerability_merge_request_links.vulnerability_id = NEW.vulnerability_id)
  INTO
    has_merge_request;

  INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues, has_merge_request)
    VALUES (NEW.vulnerability_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id', CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint), has_issues, has_merge_request)
    ON CONFLICT(vulnerability_id) DO NOTHING;
  RETURN NULL;
END
$$;

CREATE FUNCTION insert_projects_sync_event() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
INSERT INTO projects_sync_events (project_id)
VALUES(COALESCE(NEW.id, OLD.id));
RETURN NULL;

END
$$;

CREATE FUNCTION insert_vulnerability_reads_from_vulnerability() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
  scanner_id bigint;
  uuid uuid;
  location_image text;
  cluster_agent_id text;
  casted_cluster_agent_id bigint;
  has_issues boolean;
  has_merge_request boolean;
BEGIN
  SELECT
    v_o.scanner_id, v_o.uuid, v_o.location->>'image', v_o.location->'kubernetes_resource'->>'agent_id', CAST(v_o.location->'kubernetes_resource'->>'agent_id' AS bigint)
  INTO
    scanner_id, uuid, location_image, cluster_agent_id, casted_cluster_agent_id
  FROM
    vulnerability_occurrences v_o
  INNER JOIN projects ON projects.id = v_o.project_id
  WHERE
    v_o.vulnerability_id = NEW.id
  LIMIT 1;

  SELECT
    EXISTS (SELECT 1 FROM vulnerability_issue_links WHERE vulnerability_issue_links.vulnerability_id = NEW.id)
  INTO
    has_issues;

  SELECT
    EXISTS (SELECT 1 FROM vulnerability_merge_request_links WHERE vulnerability_merge_request_links.vulnerability_id = NEW.id)
  INTO
    has_merge_request;

  INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues, has_merge_request)
    VALUES (NEW.id, NEW.project_id, scanner_id, NEW.report_type, NEW.severity, NEW.state, NEW.resolved_on_default_branch, uuid::uuid, location_image, cluster_agent_id, casted_cluster_agent_id, has_issues, has_merge_request)
    ON CONFLICT(vulnerability_id) DO NOTHING;
  RETURN NULL;
END
$$;

CREATE FUNCTION next_traversal_ids_sibling(traversal_ids bigint[]) RETURNS bigint[]
    LANGUAGE plpgsql IMMUTABLE STRICT
    AS $$
BEGIN
  return traversal_ids[1:array_length(traversal_ids, 1)-1] ||
  ARRAY[traversal_ids[array_length(traversal_ids, 1)]+1];
END;
$$;

CREATE FUNCTION nullify_merge_request_metrics_build_data() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF (OLD.pipeline_id IS NOT NULL) AND (NEW.pipeline_id IS NULL) THEN
  NEW.latest_build_started_at = NULL;
  NEW.latest_build_finished_at = NULL;
END IF;
RETURN NEW;

END
$$;

CREATE FUNCTION postgres_pg_stat_activity_autovacuum() RETURNS TABLE(query text, query_start timestamp with time zone)
    LANGUAGE sql SECURITY DEFINER
    SET search_path TO 'pg_catalog', 'pg_temp'
    AS $$
  SELECT query, query_start
  FROM pg_stat_activity
  WHERE datname = current_database()
    AND state = 'active'
    AND backend_type = 'autovacuum worker'
$$;

CREATE FUNCTION prevent_delete_of_default_organization() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF OLD.id = 1 THEN
  RAISE EXCEPTION 'Deletion of the default Organization is not allowed.';
END IF;
RETURN OLD;

END
$$;

CREATE FUNCTION set_has_external_issue_tracker() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
UPDATE projects SET has_external_issue_tracker = (
  EXISTS
  (
    SELECT 1
    FROM integrations
    WHERE project_id = COALESCE(NEW.project_id, OLD.project_id)
      AND active = TRUE
      AND category = 'issue_tracker'
  )
)
WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id);
RETURN NULL;

END
$$;

CREATE FUNCTION set_has_external_wiki() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
UPDATE projects SET has_external_wiki = COALESCE(NEW.active, FALSE)
WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id);
RETURN NULL;

END
$$;

CREATE FUNCTION set_has_issues_on_vulnerability_reads() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
UPDATE
  vulnerability_reads
SET
  has_issues = true
WHERE
  vulnerability_id = NEW.vulnerability_id AND has_issues IS FALSE;
RETURN NULL;

END
$$;

CREATE FUNCTION set_has_merge_request_on_vulnerability_reads() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
UPDATE
  vulnerability_reads
SET
  has_merge_request = true
WHERE
  vulnerability_id = NEW.vulnerability_id AND has_merge_request IS FALSE;
RETURN NULL;

END
$$;

CREATE FUNCTION sync_issues_dates_with_work_item_dates_sources() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
UPDATE
  issues
SET
  start_date = NEW.start_date,
  due_date = NEW.due_date
WHERE
  issues.id = NEW.issue_id;

RETURN NULL;

END
$$;

CREATE FUNCTION table_sync_function_0992e728d3() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF (TG_OP = 'DELETE') THEN
  DELETE FROM merge_request_diff_commits_b5377a7a34 where merge_request_diff_id = OLD.merge_request_diff_id AND relative_order = OLD.relative_order;
ELSIF (TG_OP = 'UPDATE') THEN
  UPDATE merge_request_diff_commits_b5377a7a34
  SET authored_date = NEW.authored_date,
    committed_date = NEW.committed_date,
    sha = NEW.sha,
    message = NEW.message,
    trailers = NEW.trailers,
    commit_author_id = NEW.commit_author_id,
    committer_id = NEW.committer_id
  WHERE merge_request_diff_commits_b5377a7a34.merge_request_diff_id = NEW.merge_request_diff_id AND merge_request_diff_commits_b5377a7a34.relative_order = NEW.relative_order;
ELSIF (TG_OP = 'INSERT') THEN
  INSERT INTO merge_request_diff_commits_b5377a7a34 (authored_date,
    committed_date,
    sha,
    message,
    trailers,
    commit_author_id,
    committer_id,
    merge_request_diff_id,
    relative_order)
  VALUES (NEW.authored_date,
    NEW.committed_date,
    NEW.sha,
    NEW.message,
    NEW.trailers,
    NEW.commit_author_id,
    NEW.committer_id,
    NEW.merge_request_diff_id,
    NEW.relative_order);
END IF;
RETURN NULL;

END
$$;

COMMENT ON FUNCTION table_sync_function_0992e728d3() IS 'Partitioning migration: table sync for merge_request_diff_commits table';

CREATE FUNCTION table_sync_function_3f39f64fc3() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF (TG_OP = 'DELETE') THEN
  DELETE FROM merge_request_diff_files_99208b8fac where "merge_request_diff_id" = OLD."merge_request_diff_id" AND "relative_order" = OLD."relative_order";
ELSIF (TG_OP = 'UPDATE') THEN
  UPDATE merge_request_diff_files_99208b8fac
  SET "new_file" = NEW."new_file",
    "renamed_file" = NEW."renamed_file",
    "deleted_file" = NEW."deleted_file",
    "too_large" = NEW."too_large",
    "a_mode" = NEW."a_mode",
    "b_mode" = NEW."b_mode",
    "new_path" = NEW."new_path",
    "old_path" = NEW."old_path",
    "diff" = NEW."diff",
    "binary" = NEW."binary",
    "external_diff_offset" = NEW."external_diff_offset",
    "external_diff_size" = NEW."external_diff_size",
    "generated" = NEW."generated"
  WHERE merge_request_diff_files_99208b8fac."merge_request_diff_id" = NEW."merge_request_diff_id" AND merge_request_diff_files_99208b8fac."relative_order" = NEW."relative_order";
ELSIF (TG_OP = 'INSERT') THEN
  INSERT INTO merge_request_diff_files_99208b8fac ("new_file",
    "renamed_file",
    "deleted_file",
    "too_large",
    "a_mode",
    "b_mode",
    "new_path",
    "old_path",
    "diff",
    "binary",
    "external_diff_offset",
    "external_diff_size",
    "generated",
    "merge_request_diff_id",
    "relative_order")
  VALUES (NEW."new_file",
    NEW."renamed_file",
    NEW."deleted_file",
    NEW."too_large",
    NEW."a_mode",
    NEW."b_mode",
    NEW."new_path",
    NEW."old_path",
    NEW."diff",
    NEW."binary",
    NEW."external_diff_offset",
    NEW."external_diff_size",
    NEW."generated",
    NEW."merge_request_diff_id",
    NEW."relative_order");
END IF;
RETURN NULL;

END
$$;

COMMENT ON FUNCTION table_sync_function_3f39f64fc3() IS 'Partitioning migration: table sync for merge_request_diff_files table';

CREATE FUNCTION table_sync_function_686d6c7993() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF (TG_OP = 'DELETE') THEN
  DELETE FROM ci_runners_e59bb2812d where "id" = OLD."id";
ELSIF (TG_OP = 'UPDATE') THEN
  UPDATE ci_runners_e59bb2812d
  SET "creator_id" = NEW."creator_id",
    "sharding_key_id" = NEW."sharding_key_id",
    "created_at" = NEW."created_at",
    "updated_at" = NEW."updated_at",
    "contacted_at" = NEW."contacted_at",
    "token_expires_at" = NEW."token_expires_at",
    "public_projects_minutes_cost_factor" = NEW."public_projects_minutes_cost_factor",
    "private_projects_minutes_cost_factor" = NEW."private_projects_minutes_cost_factor",
    "access_level" = NEW."access_level",
    "maximum_timeout" = NEW."maximum_timeout",
    "runner_type" = NEW."runner_type",
    "registration_type" = NEW."registration_type",
    "creation_state" = NEW."creation_state",
    "active" = NEW."active",
    "run_untagged" = NEW."run_untagged",
    "locked" = NEW."locked",
    "name" = NEW."name",
    "token_encrypted" = NEW."token_encrypted",
    "token" = NEW."token",
    "description" = NEW."description",
    "maintainer_note" = NEW."maintainer_note",
    "allowed_plans" = NEW."allowed_plans",
    "allowed_plan_ids" = NEW."allowed_plan_ids"
  WHERE ci_runners_e59bb2812d."id" = NEW."id";
ELSIF (TG_OP = 'INSERT') THEN
  INSERT INTO ci_runners_e59bb2812d ("id",
    "creator_id",
    "sharding_key_id",
    "created_at",
    "updated_at",
    "contacted_at",
    "token_expires_at",
    "public_projects_minutes_cost_factor",
    "private_projects_minutes_cost_factor",
    "access_level",
    "maximum_timeout",
    "runner_type",
    "registration_type",
    "creation_state",
    "active",
    "run_untagged",
    "locked",
    "name",
    "token_encrypted",
    "token",
    "description",
    "maintainer_note",
    "allowed_plans",
    "allowed_plan_ids")
  VALUES (NEW."id",
    NEW."creator_id",
    NEW."sharding_key_id",
    NEW."created_at",
    NEW."updated_at",
    NEW."contacted_at",
    NEW."token_expires_at",
    NEW."public_projects_minutes_cost_factor",
    NEW."private_projects_minutes_cost_factor",
    NEW."access_level",
    NEW."maximum_timeout",
    NEW."runner_type",
    NEW."registration_type",
    NEW."creation_state",
    NEW."active",
    NEW."run_untagged",
    NEW."locked",
    NEW."name",
    NEW."token_encrypted",
    NEW."token",
    NEW."description",
    NEW."maintainer_note",
    NEW."allowed_plans",
    NEW."allowed_plan_ids");
END IF;
RETURN NULL;

END
$$;

COMMENT ON FUNCTION table_sync_function_686d6c7993() IS 'Partitioning migration: table sync for ci_runners table';

CREATE FUNCTION table_sync_function_e438f29263() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF (TG_OP = 'DELETE') THEN
  DELETE FROM ci_runner_machines_687967fa8a where "id" = OLD."id";
ELSIF (TG_OP = 'UPDATE') THEN
  UPDATE ci_runner_machines_687967fa8a
  SET "runner_id" = NEW."runner_id",
    "sharding_key_id" = NEW."sharding_key_id",
    "created_at" = NEW."created_at",
    "updated_at" = NEW."updated_at",
    "contacted_at" = NEW."contacted_at",
    "creation_state" = NEW."creation_state",
    "executor_type" = NEW."executor_type",
    "runner_type" = NEW."runner_type",
    "config" = NEW."config",
    "system_xid" = NEW."system_xid",
    "platform" = NEW."platform",
    "architecture" = NEW."architecture",
    "revision" = NEW."revision",
    "ip_address" = NEW."ip_address",
    "version" = NEW."version"
  WHERE ci_runner_machines_687967fa8a."id" = NEW."id";
ELSIF (TG_OP = 'INSERT') THEN
  INSERT INTO ci_runner_machines_687967fa8a ("id",
    "runner_id",
    "sharding_key_id",
    "created_at",
    "updated_at",
    "contacted_at",
    "creation_state",
    "executor_type",
    "runner_type",
    "config",
    "system_xid",
    "platform",
    "architecture",
    "revision",
    "ip_address",
    "version")
  VALUES (NEW."id",
    NEW."runner_id",
    NEW."sharding_key_id",
    NEW."created_at",
    NEW."updated_at",
    NEW."contacted_at",
    NEW."creation_state",
    NEW."executor_type",
    NEW."runner_type",
    NEW."config",
    NEW."system_xid",
    NEW."platform",
    NEW."architecture",
    NEW."revision",
    NEW."ip_address",
    NEW."version");
END IF;
RETURN NULL;

END
$$;

COMMENT ON FUNCTION table_sync_function_e438f29263() IS 'Partitioning migration: table sync for ci_runner_machines table';

CREATE FUNCTION trigger_01b3fc052119() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_02450faab875() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerability_occurrences"
  WHERE "vulnerability_occurrences"."id" = NEW."occurrence_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_038fe84feff7() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_05ce163deddf() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_0a1b0adcf686() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_debian_project_distributions"
  WHERE "packages_debian_project_distributions"."id" = NEW."distribution_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_0a29d4d42b62() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "approval_project_rules"
  WHERE "approval_project_rules"."id" = NEW."approval_project_rule_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_0c326daf67cf() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."namespace_id"
  FROM "analytics_cycle_analytics_group_value_streams"
  WHERE "analytics_cycle_analytics_group_value_streams"."id" = NEW."value_stream_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_0da002390fdc() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "operations_feature_flags"
  WHERE "operations_feature_flags"."id" = NEW."feature_flag_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_0e13f214e504() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_0f38e5af9adf() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ml_candidates"
  WHERE "ml_candidates"."id" = NEW."candidate_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_13d4aa8fe3dd() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_14a39509be0a() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_158ac875f254() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "approval_group_rules"
  WHERE "approval_group_rules"."id" = NEW."approval_group_rule_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_174b23fa3dfb() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "approval_project_rules"
  WHERE "approval_project_rules"."id" = NEW."approval_project_rule_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_18bc439a6741() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_1c0f1ca199a3() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ci_resource_groups"
  WHERE "ci_resource_groups"."id" = NEW."resource_group_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_1ed40f4d5f4e() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_206cbe2dc1a2() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_207005e8e995() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "operations_feature_flags"
  WHERE "operations_feature_flags"."id" = NEW."feature_flag_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_219952df8fc4() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."blocking_merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_22262f5f16d8() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
  NEW."author_id_convert_to_bigint" := NEW."author_id";
  NEW."closed_by_id_convert_to_bigint" := NEW."closed_by_id";
  NEW."duplicated_to_id_convert_to_bigint" := NEW."duplicated_to_id";
  NEW."id_convert_to_bigint" := NEW."id";
  NEW."last_edited_by_id_convert_to_bigint" := NEW."last_edited_by_id";
  NEW."milestone_id_convert_to_bigint" := NEW."milestone_id";
  NEW."moved_to_id_convert_to_bigint" := NEW."moved_to_id";
  NEW."project_id_convert_to_bigint" := NEW."project_id";
  NEW."promoted_to_epic_id_convert_to_bigint" := NEW."promoted_to_epic_id";
  NEW."updated_by_id_convert_to_bigint" := NEW."updated_by_id";
  RETURN NEW;
END;
$$;

CREATE FUNCTION trigger_243aecba8654() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "dast_site_profiles"
  WHERE "dast_site_profiles"."id" = NEW."dast_site_profile_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_248cafd363ff() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_2514245c7fc5() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "dast_site_profiles"
  WHERE "dast_site_profiles"."id" = NEW."dast_site_profile_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_25c44c30884f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "issues"
  WHERE "issues"."id" = NEW."work_item_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_25d35f02ab55() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ml_candidates"
  WHERE "ml_candidates"."id" = NEW."candidate_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_25fe4f7da510() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerabilities"
  WHERE "vulnerabilities"."id" = NEW."vulnerability_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_2a994bb5629f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "alert_management_alerts"
  WHERE "alert_management_alerts"."id" = NEW."alert_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_2b8fdc9b4a4e() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ml_experiments"
  WHERE "ml_experiments"."id" = NEW."experiment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_2dafd0d13605() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "pages_domains"
  WHERE "pages_domains"."id" = NEW."pages_domain_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_30209d0fba3e() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "alert_management_alerts"
  WHERE "alert_management_alerts"."id" = NEW."alert_management_alert_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_3691f9f6a69f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "cluster_agents"
  WHERE "cluster_agents"."id" = NEW."cluster_agent_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_388de55cd36c() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "p_ci_builds"
  WHERE "p_ci_builds"."id" = NEW."build_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_38bfee591e40() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "dependency_proxy_blobs"
  WHERE "dependency_proxy_blobs"."id" = NEW."dependency_proxy_blob_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_3d1a58344b29() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "alert_management_alerts"
  WHERE "alert_management_alerts"."id" = NEW."alert_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_3e067fa9bfe3() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "incident_management_timeline_event_tags"
  WHERE "incident_management_timeline_event_tags"."id" = NEW."timeline_event_tag_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_3fe922f4db67() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerabilities"
  WHERE "vulnerabilities"."id" = NEW."vulnerability_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_41eaf23bf547() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "releases"
  WHERE "releases"."id" = NEW."release_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_43484cb41aca() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "project_wiki_repositories"
  WHERE "project_wiki_repositories"."id" = NEW."project_wiki_repository_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_44558add1625() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_44ff19ad0ab2() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_468b8554e533() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerability_scanners"
  WHERE "vulnerability_scanners"."id" = NEW."scanner_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_46ebe375f632() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "issues"
  WHERE "issues"."id" = NEW."issue_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_49862b4b3035() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "approval_group_rules"
  WHERE "approval_group_rules"."id" = NEW."approval_group_rule_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_49b563d0130b() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "dast_scanner_profiles"
  WHERE "dast_scanner_profiles"."id" = NEW."dast_scanner_profile_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_49e070da6320() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_4ad9a52a6614() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "sbom_occurrences"
  WHERE "sbom_occurrences"."id" = NEW."sbom_occurrence_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_4b43790d717f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."protected_environment_group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."protected_environment_group_id"
  FROM "protected_environments"
  WHERE "protected_environments"."id" = NEW."protected_environment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_54707c384ad7() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "security_orchestration_policy_configurations"
  WHERE "security_orchestration_policy_configurations"."id" = NEW."security_orchestration_policy_configuration_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_56d49f4ed623() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "workspaces"
  WHERE "workspaces"."id" = NEW."workspace_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_57ad2742ac16() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "achievements"
  WHERE "achievements"."id" = NEW."achievement_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_5ca97b87ee30() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_5f6432d2dccc() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "operations_user_lists"
  WHERE "operations_user_lists"."id" = NEW."user_list_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_627949f72f05() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_664594a3d0a7() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_68435a54ee2b() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_debian_project_distributions"
  WHERE "packages_debian_project_distributions"."id" = NEW."distribution_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_6bf50b363152() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "security_orchestration_policy_configurations"
  WHERE "security_orchestration_policy_configurations"."id" = NEW."policy_configuration_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_6c38ba395cc1() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "error_tracking_errors"
  WHERE "error_tracking_errors"."id" = NEW."error_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_6cdea9559242() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "issues"
  WHERE "issues"."id" = NEW."source_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_6d6c79ce74e1() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."protected_environment_project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."protected_environment_project_id"
  FROM "protected_environments"
  WHERE "protected_environments"."id" = NEW."protected_environment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_700f29b1312e() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_70d3f0bba1de() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "security_orchestration_policy_configurations"
  WHERE "security_orchestration_policy_configurations"."id" = NEW."policy_configuration_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_740afa9807b8() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."organization_id" IS NULL THEN
  SELECT "organization_id"
  INTO NEW."organization_id"
  FROM "subscription_add_on_purchases"
  WHERE "subscription_add_on_purchases"."id" = NEW."add_on_purchase_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_77d9fbad5b12() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_debian_project_distributions"
  WHERE "packages_debian_project_distributions"."id" = NEW."distribution_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_7a8b08eed782() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "boards_epic_boards"
  WHERE "boards_epic_boards"."id" = NEW."epic_board_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_7de792ddbc05() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "dast_site_tokens"
  WHERE "dast_site_tokens"."id" = NEW."dast_site_token_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_7e2eed79e46e() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
  NEW."assignee_id_convert_to_bigint" := NEW."assignee_id";
  NEW."id_convert_to_bigint" := NEW."id";
  NEW."reporter_id_convert_to_bigint" := NEW."reporter_id";
  NEW."resolved_by_id_convert_to_bigint" := NEW."resolved_by_id";
  NEW."user_id_convert_to_bigint" := NEW."user_id";
  RETURN NEW;
END;
$$;

CREATE FUNCTION trigger_81b4c93e7133() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "pages_deployments"
  WHERE "pages_deployments"."id" = NEW."pages_deployment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8204480b3a2e() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "incident_management_escalation_policies"
  WHERE "incident_management_escalation_policies"."id" = NEW."policy_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_84d67ad63e93() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "wiki_page_meta"
  WHERE "wiki_page_meta"."id" = NEW."wiki_page_meta_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8a38ce2327de() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "epics"
  WHERE "epics"."id" = NEW."epic_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8ac78f164b2d() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "projects"
  WHERE "projects"."id" = NEW."project_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8b39d532224c() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ci_secure_files"
  WHERE "ci_secure_files"."id" = NEW."ci_secure_file_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8d002f38bdef() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "packages_debian_group_distributions"
  WHERE "packages_debian_group_distributions"."id" = NEW."distribution_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8d17725116fe() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8e66b994e8f0() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."group_id"
  FROM "audit_events_external_audit_event_destinations"
  WHERE "audit_events_external_audit_event_destinations"."id" = NEW."external_audit_event_destination_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_8fbb044c64ad() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "projects"
  WHERE "projects"."id" = NEW."project_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_90fa5c6951f1() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "dast_profiles"
  WHERE "dast_profiles"."id" = NEW."dast_profile_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_9259aae92378() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_94514aeadc50() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "deployments"
  WHERE "deployments"."id" = NEW."deployment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_9699ea03bb37() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "epics"
  WHERE "epics"."id" = NEW."source_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_96a76ee9f147() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "issues"
  WHERE "issues"."id" = NEW."issue_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_979e7f45114f() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ml_candidates"
  WHERE "ml_candidates"."id" = NEW."candidate_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_98ad3a4c1d35() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "reviews"
  WHERE "reviews"."id" = NEW."review_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_9e137c16de79() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerability_occurrences"
  WHERE "vulnerability_occurrences"."id" = NEW."vulnerability_occurrence_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_9f3745f8fe32() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "target_project_id"
  INTO NEW."project_id"
  FROM "merge_requests"
  WHERE "merge_requests"."id" = NEW."merge_request_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_9f3de326ea61() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ci_pipeline_schedules"
  WHERE "ci_pipeline_schedules"."id" = NEW."pipeline_schedule_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_a1bc7c70cbdf() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerabilities"
  WHERE "vulnerabilities"."id" = NEW."vulnerability_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_a253cb3cacdf() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "environments"
  WHERE "environments"."id" = NEW."environment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_a465de38164e() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "p_ci_job_artifacts"
  WHERE "p_ci_job_artifacts"."id" = NEW."job_artifact_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_a4e4fb2451d9() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "epics"
  WHERE "epics"."id" = NEW."epic_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_a7e0fb195210() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerability_occurrences"
  WHERE "vulnerability_occurrences"."id" = NEW."vulnerability_occurrence_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_af3f17817e4d() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "protected_tags"
  WHERE "protected_tags"."id" = NEW."protected_tag_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_b046dd50c711() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "incident_management_oncall_schedules"
  WHERE "incident_management_oncall_schedules"."id" = NEW."oncall_schedule_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_b2612138515d() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "project_export_jobs"
  WHERE "project_export_jobs"."id" = NEW."project_export_job_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_b4520c29ea74() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "approval_project_rules"
  WHERE "approval_project_rules"."id" = NEW."approval_project_rule_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_b75e5731e305() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "dast_profiles"
  WHERE "dast_profiles"."id" = NEW."dast_profile_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_b8eecea7f351() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "dependency_proxy_manifests"
  WHERE "dependency_proxy_manifests"."id" = NEW."dependency_proxy_manifest_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_c17a166692a2() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."group_id"
  FROM "audit_events_external_audit_event_destinations"
  WHERE "audit_events_external_audit_event_destinations"."id" = NEW."external_audit_event_destination_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_c59fe6f31e71() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."namespace_id" IS NULL THEN
  SELECT "namespace_id"
  INTO NEW."namespace_id"
  FROM "security_orchestration_policy_configurations"
  WHERE "security_orchestration_policy_configurations"."id" = NEW."security_orchestration_policy_configuration_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_c5eec113ea76() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "dast_profiles"
  WHERE "dast_profiles"."id" = NEW."dast_profile_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_c8bc8646bce9() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerabilities"
  WHERE "vulnerabilities"."id" = NEW."vulnerability_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_c9090feed334() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "boards_epic_boards"
  WHERE "boards_epic_boards"."id" = NEW."epic_board_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_cac7c0698291() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "releases"
  WHERE "releases"."id" = NEW."release_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_cf646a118cbb() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "releases"
  WHERE "releases"."id" = NEW."release_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_d4487a75bd44() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "terraform_states"
  WHERE "terraform_states"."id" = NEW."terraform_state_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_d5c895007948() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."protected_environment_project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."protected_environment_project_id"
  FROM "protected_environments"
  WHERE "protected_environments"."id" = NEW."protected_environment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_da5fd3d6d75c() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_dadd660afe2c() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "packages_debian_group_distributions"
  WHERE "packages_debian_group_distributions"."id" = NEW."distribution_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_dbdd61a66a91() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."agent_project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."agent_project_id"
  FROM "cluster_agents"
  WHERE "cluster_agents"."id" = NEW."agent_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_dc13168b8025() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerability_occurrences"
  WHERE "vulnerability_occurrences"."id" = NEW."vulnerability_occurrence_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_e0864d1cff37() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "packages_debian_group_distributions"
  WHERE "packages_debian_group_distributions"."id" = NEW."distribution_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_e1da4a738230() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerabilities"
  WHERE "vulnerabilities"."id" = NEW."vulnerability_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_e49ab4d904a0() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerability_occurrences"
  WHERE "vulnerability_occurrences"."id" = NEW."vulnerability_occurrence_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_ebab34f83f1d() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "packages_packages"
  WHERE "packages_packages"."id" = NEW."package_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_ec1934755627() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "alert_management_alerts"
  WHERE "alert_management_alerts"."id" = NEW."alert_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_eff80ead42ac() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ci_unit_tests"
  WHERE "ci_unit_tests"."id" = NEW."unit_test_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_f6c61cdddf31() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "ml_models"
  WHERE "ml_models"."id" = NEW."model_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_f6f59d8216b3() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."protected_environment_group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."protected_environment_group_id"
  FROM "protected_environments"
  WHERE "protected_environments"."id" = NEW."protected_environment_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_fbd42ed69453() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "external_status_checks"
  WHERE "external_status_checks"."id" = NEW."external_status_check_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_fbd8825b3057() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."group_id" IS NULL THEN
  SELECT "group_id"
  INTO NEW."group_id"
  FROM "boards_epic_boards"
  WHERE "boards_epic_boards"."id" = NEW."epic_board_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_fd4a1be98713() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "container_repositories"
  WHERE "container_repositories"."id" = NEW."container_repository_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION trigger_ff16c1fd43ea() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
  NEW."geo_event_id_convert_to_bigint" := NEW."geo_event_id";
  RETURN NEW;
END;
$$;

CREATE FUNCTION trigger_fff8735b6b9a() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
IF NEW."project_id" IS NULL THEN
  SELECT "project_id"
  INTO NEW."project_id"
  FROM "vulnerability_occurrences"
  WHERE "vulnerability_occurrences"."id" = NEW."finding_id";
END IF;

RETURN NEW;

END
$$;

CREATE FUNCTION unset_has_issues_on_vulnerability_reads() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
  has_issue_links integer;
BEGIN
  PERFORM 1
  FROM
    vulnerability_reads
  WHERE
    vulnerability_id = OLD.vulnerability_id
  FOR UPDATE;

  SELECT 1 INTO has_issue_links FROM vulnerability_issue_links WHERE vulnerability_id = OLD.vulnerability_id LIMIT 1;

  IF (has_issue_links = 1) THEN
    RETURN NULL;
  END IF;

  UPDATE
    vulnerability_reads
  SET
    has_issues = false
  WHERE
    vulnerability_id = OLD.vulnerability_id;

  RETURN NULL;
END
$$;

CREATE FUNCTION unset_has_merge_request_on_vulnerability_reads() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
  has_merge_request_links integer;
BEGIN
  PERFORM 1
  FROM
    vulnerability_reads
  WHERE
    vulnerability_id = OLD.vulnerability_id
  FOR UPDATE;

  SELECT 1 INTO has_merge_request_links FROM vulnerability_merge_request_links WHERE vulnerability_id = OLD.vulnerability_id LIMIT 1;

  IF (has_merge_request_links = 1) THEN
    RETURN NULL;
  END IF;

  UPDATE
    vulnerability_reads
  SET
    has_merge_request = false
  WHERE
    vulnerability_id = OLD.vulnerability_id;

  RETURN NULL;
END
$$;

CREATE FUNCTION update_issue_correct_work_item_type_id_sync_event() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
SELECT "correct_id"
INTO NEW."correct_work_item_type_id"
FROM "work_item_types"
WHERE "work_item_types"."id" = NEW."work_item_type_id";
RETURN NEW;

END
$$;

CREATE FUNCTION update_location_from_vulnerability_occurrences() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
UPDATE
  vulnerability_reads
SET
  location_image = NEW.location->>'image',
  casted_cluster_agent_id = CAST(NEW.location->'kubernetes_resource'->>'agent_id' AS bigint),
  cluster_agent_id = NEW.location->'kubernetes_resource'->>'agent_id'
WHERE
  vulnerability_id = NEW.vulnerability_id;
RETURN NULL;

END
$$;

CREATE FUNCTION update_namespace_details_from_namespaces() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
INSERT INTO
  namespace_details (
    description,
    description_html,
    cached_markdown_version,
    updated_at,
    created_at,
    namespace_id
  )
VALUES
  (
    NEW.description,
    NEW.description_html,
    NEW.cached_markdown_version,
    NEW.updated_at,
    NEW.updated_at,
    NEW.id
  ) ON CONFLICT (namespace_id) DO
UPDATE
SET
  description = NEW.description,
  description_html = NEW.description_html,
  cached_markdown_version = NEW.cached_markdown_version,
  updated_at = NEW.updated_at
WHERE
  namespace_details.namespace_id = NEW.id;RETURN NULL;

END
$$;

CREATE FUNCTION update_namespace_details_from_projects() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
INSERT INTO
  namespace_details (
    description,
    description_html,
    cached_markdown_version,
    updated_at,
    created_at,
    namespace_id
  )
VALUES
  (
    NEW.description,
    NEW.description_html,
    NEW.cached_markdown_version,
    NEW.updated_at,
    NEW.updated_at,
    NEW.project_namespace_id
  ) ON CONFLICT (namespace_id) DO
UPDATE
SET
  description = NEW.description,
  description_html = NEW.description_html,
  cached_markdown_version = NEW.cached_markdown_version,
  updated_at = NEW.updated_at
WHERE
  namespace_details.namespace_id = NEW.project_namespace_id;RETURN NULL;

END
$$;

CREATE FUNCTION update_vulnerability_reads_from_vulnerability() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
UPDATE
  vulnerability_reads
SET
  severity = NEW.severity,
  state = NEW.state,
  resolved_on_default_branch = NEW.resolved_on_default_branch,
  auto_resolved = NEW.auto_resolved
WHERE vulnerability_id = NEW.id;
RETURN NULL;

END
$$;

CREATE TABLE ai_code_suggestion_events (
    id bigint NOT NULL,
    "timestamp" timestamp with time zone NOT NULL,
    user_id bigint NOT NULL,
    organization_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    event smallint NOT NULL,
    namespace_path text,
    payload jsonb,
    CONSTRAINT check_ba9ae3f258 CHECK ((char_length(namespace_path) <= 255))
)
PARTITION BY RANGE ("timestamp");

CREATE TABLE audit_events (
    id bigint NOT NULL,
    author_id bigint NOT NULL,
    entity_id bigint NOT NULL,
    entity_type character varying NOT NULL,
    details text,
    ip_address inet,
    author_name text,
    entity_path text,
    target_details text,
    created_at timestamp without time zone NOT NULL,
    target_type text,
    target_id bigint,
    CONSTRAINT check_492aaa021d CHECK ((char_length(entity_path) <= 5500)),
    CONSTRAINT check_83ff8406e2 CHECK ((char_length(author_name) <= 255)),
    CONSTRAINT check_97a8c868e7 CHECK ((char_length(target_type) <= 255)),
    CONSTRAINT check_d493ec90b5 CHECK ((char_length(target_details) <= 5500))
)
PARTITION BY RANGE (created_at);

CREATE TABLE batched_background_migration_job_transition_logs (
    id bigint NOT NULL,
    batched_background_migration_job_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    previous_status smallint NOT NULL,
    next_status smallint NOT NULL,
    exception_class text,
    exception_message text,
    CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)),
    CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100))
)
PARTITION BY RANGE (created_at);

CREATE TABLE p_ci_build_names (
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint NOT NULL,
    name text NOT NULL,
    search_vector tsvector GENERATED ALWAYS AS (to_tsvector('english'::regconfig, COALESCE(name, ''::text))) STORED,
    CONSTRAINT check_1722c96346 CHECK ((char_length(name) <= 255))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_build_sources (
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint NOT NULL,
    source smallint,
    pipeline_source smallint
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_build_tags (
    id bigint NOT NULL,
    tag_id bigint NOT NULL,
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint NOT NULL
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_build_trace_metadata (
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    trace_artifact_id bigint,
    last_archival_attempt_at timestamp with time zone,
    archived_at timestamp with time zone,
    archival_attempts smallint DEFAULT 0 NOT NULL,
    checksum bytea,
    remote_checksum bytea
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_builds (
    status character varying,
    finished_at timestamp without time zone,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    started_at timestamp without time zone,
    coverage double precision,
    name character varying,
    options text,
    allow_failure boolean DEFAULT false NOT NULL,
    stage character varying,
    stage_idx integer,
    tag boolean,
    ref character varying,
    type character varying,
    target_url character varying,
    description character varying,
    erased_at timestamp without time zone,
    artifacts_expire_at timestamp without time zone,
    environment character varying,
    "when" character varying,
    yaml_variables text,
    queued_at timestamp without time zone,
    lock_version integer DEFAULT 0,
    coverage_regex character varying,
    retried boolean,
    protected boolean,
    failure_reason integer,
    scheduled_at timestamp with time zone,
    token_encrypted character varying,
    resource_group_id bigint,
    waiting_for_resource_at timestamp with time zone,
    processed boolean,
    scheduling_type smallint,
    id bigint NOT NULL,
    stage_id bigint,
    partition_id bigint NOT NULL,
    auto_canceled_by_partition_id bigint,
    auto_canceled_by_id bigint,
    commit_id bigint,
    erased_by_id bigint,
    project_id bigint,
    runner_id bigint,
    trigger_request_id bigint,
    upstream_pipeline_id bigint,
    user_id bigint,
    execution_config_id bigint,
    upstream_pipeline_partition_id bigint,
    CONSTRAINT check_1e2fbd1b39 CHECK ((lock_version IS NOT NULL)),
    CONSTRAINT check_9aa9432137 CHECK ((project_id IS NOT NULL))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_builds_execution_configs (
    id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint NOT NULL,
    pipeline_id bigint NOT NULL,
    run_steps jsonb DEFAULT '{}'::jsonb NOT NULL
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_builds_metadata (
    project_id bigint NOT NULL,
    timeout integer,
    timeout_source integer DEFAULT 1 NOT NULL,
    interruptible boolean,
    config_options jsonb,
    config_variables jsonb,
    has_exposed_artifacts boolean,
    environment_auto_stop_in character varying(255),
    expanded_environment_name character varying(255),
    secrets jsonb DEFAULT '{}'::jsonb NOT NULL,
    build_id bigint NOT NULL,
    id bigint NOT NULL,
    runtime_runner_features jsonb DEFAULT '{}'::jsonb NOT NULL,
    id_tokens jsonb DEFAULT '{}'::jsonb NOT NULL,
    partition_id bigint NOT NULL,
    debug_trace_enabled boolean DEFAULT false NOT NULL,
    exit_code smallint
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_job_annotations (
    id bigint NOT NULL,
    partition_id bigint NOT NULL,
    job_id bigint NOT NULL,
    name text NOT NULL,
    data jsonb DEFAULT '[]'::jsonb NOT NULL,
    project_id bigint,
    CONSTRAINT check_375bb9900a CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_bac9224e45 CHECK ((char_length(name) <= 255)),
    CONSTRAINT data_is_array CHECK ((jsonb_typeof(data) = 'array'::text))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_job_artifact_reports (
    job_artifact_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint NOT NULL,
    status smallint NOT NULL,
    validation_error text,
    CONSTRAINT check_1c55aee894 CHECK ((char_length(validation_error) <= 255))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_job_artifacts (
    project_id bigint NOT NULL,
    file_type integer NOT NULL,
    size bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    expire_at timestamp with time zone,
    file character varying,
    file_store integer DEFAULT 1,
    file_sha256 bytea,
    file_format smallint,
    file_location smallint,
    id bigint NOT NULL,
    job_id bigint NOT NULL,
    locked smallint DEFAULT 2,
    partition_id bigint NOT NULL,
    accessibility smallint DEFAULT 0 NOT NULL,
    file_final_path text,
    CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL)),
    CONSTRAINT check_9f04410cf4 CHECK ((char_length(file_final_path) <= 1024))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_pipeline_variables (
    key character varying NOT NULL,
    value text,
    encrypted_value text,
    encrypted_value_salt character varying,
    encrypted_value_iv character varying,
    variable_type smallint DEFAULT 1 NOT NULL,
    partition_id bigint NOT NULL,
    raw boolean DEFAULT false NOT NULL,
    id bigint NOT NULL,
    pipeline_id bigint NOT NULL,
    project_id bigint
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_pipelines_config (
    pipeline_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    content text NOT NULL,
    project_id bigint,
    CONSTRAINT check_b2a19dd79a CHECK ((project_id IS NOT NULL))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_runner_machine_builds (
    partition_id bigint NOT NULL,
    build_id bigint NOT NULL,
    runner_machine_id bigint NOT NULL,
    project_id bigint,
    CONSTRAINT check_149ee35c38 CHECK ((project_id IS NOT NULL))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_stages (
    project_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    name character varying,
    status integer,
    lock_version integer DEFAULT 0,
    "position" integer,
    id bigint NOT NULL,
    partition_id bigint NOT NULL,
    pipeline_id bigint,
    CONSTRAINT check_74835fc631 CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_81b431e49b CHECK ((lock_version IS NOT NULL))
)
PARTITION BY LIST (partition_id);

CREATE SEQUENCE shared_audit_event_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

CREATE TABLE group_audit_events (
    id bigint DEFAULT nextval('shared_audit_event_id_seq'::regclass) NOT NULL,
    created_at timestamp with time zone NOT NULL,
    group_id bigint NOT NULL,
    author_id bigint NOT NULL,
    target_id bigint,
    event_name text,
    details text,
    ip_address inet,
    author_name text,
    entity_path text,
    target_details text,
    target_type text,
    CONSTRAINT group_audit_events_author_name_check CHECK ((char_length(author_name) <= 255)),
    CONSTRAINT group_audit_events_entity_path_check CHECK ((char_length(entity_path) <= 5500)),
    CONSTRAINT group_audit_events_event_name_check CHECK ((char_length(event_name) <= 255)),
    CONSTRAINT group_audit_events_target_details_check CHECK ((char_length(target_details) <= 5500)),
    CONSTRAINT group_audit_events_target_type_check CHECK ((char_length(target_type) <= 255))
)
PARTITION BY RANGE (created_at);

CREATE TABLE groups_visits (
    id bigint NOT NULL,
    entity_id bigint NOT NULL,
    user_id bigint NOT NULL,
    visited_at timestamp with time zone NOT NULL
)
PARTITION BY RANGE (visited_at);

CREATE TABLE incident_management_pending_alert_escalations (
    id bigint NOT NULL,
    rule_id bigint NOT NULL,
    alert_id bigint NOT NULL,
    process_at timestamp with time zone NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint
)
PARTITION BY RANGE (process_at);

CREATE TABLE incident_management_pending_issue_escalations (
    id bigint NOT NULL,
    rule_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    process_at timestamp with time zone NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
)
PARTITION BY RANGE (process_at);

CREATE TABLE instance_audit_events (
    id bigint DEFAULT nextval('shared_audit_event_id_seq'::regclass) NOT NULL,
    created_at timestamp with time zone NOT NULL,
    author_id bigint NOT NULL,
    target_id bigint,
    event_name text,
    details text,
    ip_address inet,
    author_name text,
    entity_path text,
    target_details text,
    target_type text,
    CONSTRAINT instance_audit_events_author_name_check CHECK ((char_length(author_name) <= 255)),
    CONSTRAINT instance_audit_events_entity_path_check CHECK ((char_length(entity_path) <= 5500)),
    CONSTRAINT instance_audit_events_event_name_check CHECK ((char_length(event_name) <= 255)),
    CONSTRAINT instance_audit_events_target_details_check CHECK ((char_length(target_details) <= 5500)),
    CONSTRAINT instance_audit_events_target_type_check CHECK ((char_length(target_type) <= 255))
)
PARTITION BY RANGE (created_at);

CREATE TABLE loose_foreign_keys_deleted_records (
    id bigint NOT NULL,
    partition bigint DEFAULT 1 NOT NULL,
    primary_key_value bigint NOT NULL,
    status smallint DEFAULT 1 NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    fully_qualified_table_name text NOT NULL,
    consume_after timestamp with time zone DEFAULT now(),
    cleanup_attempts smallint DEFAULT 0,
    CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150))
)
PARTITION BY LIST (partition);

CREATE TABLE merge_request_diff_commits_b5377a7a34 (
    authored_date timestamp without time zone,
    committed_date timestamp without time zone,
    sha bytea NOT NULL,
    message text,
    trailers jsonb DEFAULT '{}'::jsonb NOT NULL,
    commit_author_id bigint,
    committer_id bigint,
    merge_request_diff_id bigint NOT NULL,
    relative_order integer NOT NULL,
    project_id bigint
)
PARTITION BY RANGE (merge_request_diff_id);

CREATE TABLE merge_request_diff_files_99208b8fac (
    new_file boolean NOT NULL,
    renamed_file boolean NOT NULL,
    deleted_file boolean NOT NULL,
    too_large boolean NOT NULL,
    a_mode character varying NOT NULL,
    b_mode character varying NOT NULL,
    new_path text NOT NULL,
    old_path text NOT NULL,
    diff text,
    "binary" boolean,
    external_diff_offset integer,
    external_diff_size integer,
    generated boolean,
    merge_request_diff_id bigint NOT NULL,
    relative_order integer NOT NULL,
    project_id bigint
)
PARTITION BY RANGE (merge_request_diff_id);

CREATE TABLE p_batched_git_ref_updates_deletions (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    partition_id bigint DEFAULT 1 NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    status smallint DEFAULT 1 NOT NULL,
    ref text NOT NULL,
    CONSTRAINT check_f322d53b92 CHECK ((char_length(ref) <= 1024))
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_catalog_resource_component_usages (
    id bigint NOT NULL,
    component_id bigint NOT NULL,
    catalog_resource_id bigint NOT NULL,
    project_id bigint NOT NULL,
    used_by_project_id bigint NOT NULL,
    used_date date NOT NULL
)
PARTITION BY RANGE (used_date);

CREATE TABLE p_catalog_resource_sync_events (
    id bigint NOT NULL,
    catalog_resource_id bigint NOT NULL,
    project_id bigint NOT NULL,
    partition_id bigint DEFAULT 1 NOT NULL,
    status smallint DEFAULT 1 NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL
)
PARTITION BY LIST (partition_id);

CREATE TABLE p_ci_finished_build_ch_sync_events (
    build_id bigint NOT NULL,
    partition bigint DEFAULT 1 NOT NULL,
    build_finished_at timestamp without time zone NOT NULL,
    processed boolean DEFAULT false NOT NULL,
    project_id bigint NOT NULL
)
PARTITION BY LIST (partition);

CREATE TABLE p_ci_finished_pipeline_ch_sync_events (
    pipeline_id bigint NOT NULL,
    project_namespace_id bigint NOT NULL,
    partition bigint DEFAULT 1 NOT NULL,
    pipeline_finished_at timestamp without time zone NOT NULL,
    processed boolean DEFAULT false NOT NULL
)
PARTITION BY LIST (partition);

CREATE TABLE project_audit_events (
    id bigint DEFAULT nextval('shared_audit_event_id_seq'::regclass) NOT NULL,
    created_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    author_id bigint NOT NULL,
    target_id bigint,
    event_name text,
    details text,
    ip_address inet,
    author_name text,
    entity_path text,
    target_details text,
    target_type text,
    CONSTRAINT project_audit_events_author_name_check CHECK ((char_length(author_name) <= 255)),
    CONSTRAINT project_audit_events_entity_path_check CHECK ((char_length(entity_path) <= 5500)),
    CONSTRAINT project_audit_events_event_name_check CHECK ((char_length(event_name) <= 255)),
    CONSTRAINT project_audit_events_target_details_check CHECK ((char_length(target_details) <= 5500)),
    CONSTRAINT project_audit_events_target_type_check CHECK ((char_length(target_type) <= 255))
)
PARTITION BY RANGE (created_at);

CREATE TABLE projects_visits (
    id bigint NOT NULL,
    entity_id bigint NOT NULL,
    user_id bigint NOT NULL,
    visited_at timestamp with time zone NOT NULL
)
PARTITION BY RANGE (visited_at);

CREATE TABLE security_findings (
    id bigint NOT NULL,
    scan_id bigint NOT NULL,
    scanner_id bigint NOT NULL,
    severity smallint NOT NULL,
    confidence smallint,
    project_fingerprint text,
    deduplicated boolean DEFAULT false NOT NULL,
    uuid uuid,
    overridden_uuid uuid,
    partition_number integer DEFAULT 1 NOT NULL,
    finding_data jsonb DEFAULT '{}'::jsonb NOT NULL,
    project_id bigint,
    CONSTRAINT check_6c2851a8c9 CHECK ((uuid IS NOT NULL)),
    CONSTRAINT check_b9508c6df8 CHECK ((char_length(project_fingerprint) <= 40))
)
PARTITION BY LIST (partition_number);

CREATE TABLE user_audit_events (
    id bigint DEFAULT nextval('shared_audit_event_id_seq'::regclass) NOT NULL,
    created_at timestamp with time zone NOT NULL,
    user_id bigint NOT NULL,
    author_id bigint NOT NULL,
    target_id bigint,
    event_name text,
    details text,
    ip_address inet,
    author_name text,
    entity_path text,
    target_details text,
    target_type text,
    CONSTRAINT user_audit_events_author_name_check CHECK ((char_length(author_name) <= 255)),
    CONSTRAINT user_audit_events_entity_path_check CHECK ((char_length(entity_path) <= 5500)),
    CONSTRAINT user_audit_events_event_name_check CHECK ((char_length(event_name) <= 255)),
    CONSTRAINT user_audit_events_target_details_check CHECK ((char_length(target_details) <= 5500)),
    CONSTRAINT user_audit_events_target_type_check CHECK ((char_length(target_type) <= 255))
)
PARTITION BY RANGE (created_at);

CREATE TABLE value_stream_dashboard_counts (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    count bigint NOT NULL,
    recorded_at timestamp with time zone NOT NULL,
    metric smallint NOT NULL
)
PARTITION BY RANGE (recorded_at);

CREATE TABLE verification_codes (
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    visitor_id_code text NOT NULL,
    code text NOT NULL,
    phone text NOT NULL,
    CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)),
    CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)),
    CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50))
)
PARTITION BY RANGE (created_at);

COMMENT ON TABLE verification_codes IS 'JiHu-specific table';

CREATE TABLE web_hook_logs (
    id bigint NOT NULL,
    web_hook_id bigint NOT NULL,
    trigger character varying,
    url character varying,
    request_headers text,
    request_data text,
    response_headers text,
    response_body text,
    response_status character varying,
    execution_duration double precision,
    internal_error_message character varying,
    updated_at timestamp without time zone NOT NULL,
    created_at timestamp without time zone NOT NULL,
    url_hash text
)
PARTITION BY RANGE (created_at);

CREATE TABLE zoekt_tasks (
    id bigint NOT NULL,
    partition_id bigint DEFAULT 1 NOT NULL,
    zoekt_node_id bigint NOT NULL,
    zoekt_repository_id bigint NOT NULL,
    project_identifier bigint NOT NULL,
    perform_at timestamp with time zone DEFAULT now() NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    state smallint DEFAULT 0 NOT NULL,
    task_type smallint NOT NULL,
    retries_left smallint DEFAULT 5 NOT NULL,
    CONSTRAINT c_zoekt_tasks_on_retries_left CHECK (((retries_left > 0) OR ((retries_left = 0) AND (state = 255))))
)
PARTITION BY LIST (partition_id);

CREATE TABLE analytics_cycle_analytics_issue_stage_events (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
)
PARTITION BY HASH (stage_event_hash_id);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_01 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_02 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_03 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_04 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_05 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_06 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_07 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_08 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_09 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_10 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_11 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_12 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_13 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_14 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_15 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_16 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_17 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_18 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_19 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_20 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_21 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_22 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_23 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_24 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_25 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_26 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_27 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_28 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_29 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_30 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_31 (
    stage_event_hash_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    weight integer,
    sprint_id bigint,
    duration_in_milliseconds bigint
);

CREATE TABLE analytics_cycle_analytics_merge_request_stage_events (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
)
PARTITION BY HASH (stage_event_hash_id);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_00 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_01 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_02 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_03 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_04 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_05 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_06 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_07 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_08 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_09 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_10 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_11 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_12 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_13 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_14 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_15 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_16 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_17 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_18 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_19 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_20 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_21 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_22 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_23 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_24 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_25 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_26 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_27 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_28 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_29 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_30 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_31 (
    stage_event_hash_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    group_id bigint NOT NULL,
    project_id bigint NOT NULL,
    milestone_id bigint,
    author_id bigint,
    start_event_timestamp timestamp with time zone NOT NULL,
    end_event_timestamp timestamp with time zone,
    state_id smallint DEFAULT 1 NOT NULL,
    duration_in_milliseconds bigint
);

CREATE TABLE issue_search_data (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
)
PARTITION BY HASH (project_id);

CREATE TABLE gitlab_partitions_static.issue_search_data_00 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_01 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_02 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_03 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_04 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_05 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_06 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_07 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_08 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_09 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_10 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_11 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_12 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_13 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_14 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_15 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_16 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_17 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_18 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_19 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_20 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_21 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_22 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_23 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_24 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_25 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_26 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_27 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_28 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_29 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_30 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_31 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_32 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_33 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_34 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_35 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_36 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_37 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_38 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_39 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_40 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_41 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_42 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_43 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_44 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_45 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_46 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_47 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_48 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_49 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_50 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_51 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_52 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_53 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_54 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_55 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_56 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_57 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_58 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_59 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_60 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_61 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_62 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE gitlab_partitions_static.issue_search_data_63 (
    project_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    updated_at timestamp with time zone DEFAULT now() NOT NULL,
    search_vector tsvector,
    namespace_id bigint
);

CREATE TABLE namespace_descendants (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
)
PARTITION BY HASH (namespace_id);

CREATE TABLE gitlab_partitions_static.namespace_descendants_00 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_01 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_02 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_03 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_04 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_05 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_06 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_07 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_08 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_09 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_10 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_11 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_12 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_13 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_14 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_15 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_16 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_17 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_18 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_19 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_20 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_21 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_22 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_23 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_24 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_25 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_26 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_27 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_28 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_29 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_30 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE gitlab_partitions_static.namespace_descendants_31 (
    namespace_id bigint NOT NULL,
    self_and_descendant_group_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    all_project_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    traversal_ids bigint[] DEFAULT ARRAY[]::bigint[] NOT NULL,
    outdated_at timestamp with time zone,
    calculated_at timestamp with time zone
);

CREATE TABLE abuse_events (
    id bigint NOT NULL,
    user_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    abuse_report_id bigint,
    source smallint NOT NULL,
    category smallint,
    metadata jsonb
);

CREATE SEQUENCE abuse_events_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_events_id_seq OWNED BY abuse_events.id;

CREATE TABLE abuse_report_assignees (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    abuse_report_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

CREATE SEQUENCE abuse_report_assignees_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_report_assignees_id_seq OWNED BY abuse_report_assignees.id;

CREATE TABLE abuse_report_events (
    id bigint NOT NULL,
    abuse_report_id bigint NOT NULL,
    user_id bigint,
    created_at timestamp with time zone NOT NULL,
    action smallint DEFAULT 1 NOT NULL,
    reason smallint,
    comment text,
    CONSTRAINT check_bb4cd85618 CHECK ((char_length(comment) <= 1024))
);

CREATE SEQUENCE abuse_report_events_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_report_events_id_seq OWNED BY abuse_report_events.id;

CREATE TABLE abuse_report_label_links (
    id bigint NOT NULL,
    abuse_report_id bigint NOT NULL,
    abuse_report_label_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

CREATE SEQUENCE abuse_report_label_links_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_report_label_links_id_seq OWNED BY abuse_report_label_links.id;

CREATE TABLE abuse_report_labels (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    cached_markdown_version integer,
    title text NOT NULL,
    color text,
    description text,
    description_html text,
    CONSTRAINT check_034642a23f CHECK ((char_length(description) <= 500)),
    CONSTRAINT check_7957e7e95f CHECK ((char_length(description_html) <= 1000)),
    CONSTRAINT check_c7a15f74dc CHECK ((char_length(color) <= 7)),
    CONSTRAINT check_e264245e2a CHECK ((char_length(title) <= 255))
);

CREATE SEQUENCE abuse_report_labels_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_report_labels_id_seq OWNED BY abuse_report_labels.id;

CREATE TABLE abuse_report_notes (
    id bigint NOT NULL,
    abuse_report_id bigint NOT NULL,
    author_id bigint NOT NULL,
    updated_by_id bigint,
    resolved_by_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    resolved_at timestamp with time zone,
    last_edited_at timestamp with time zone,
    cached_markdown_version integer,
    discussion_id text,
    note text,
    note_html text,
    type text,
    CONSTRAINT check_096e19df7f CHECK ((char_length(type) <= 40)),
    CONSTRAINT check_0de721e87e CHECK ((char_length(note) <= 10000)),
    CONSTRAINT check_13235633b5 CHECK ((char_length(discussion_id) <= 255)),
    CONSTRAINT check_21b51956e3 CHECK ((char_length(note_html) <= 20000))
);

CREATE SEQUENCE abuse_report_notes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_report_notes_id_seq OWNED BY abuse_report_notes.id;

CREATE TABLE abuse_report_user_mentions (
    id bigint NOT NULL,
    abuse_report_id bigint NOT NULL,
    note_id bigint NOT NULL,
    mentioned_users_ids bigint[],
    mentioned_projects_ids bigint[],
    mentioned_groups_ids bigint[]
);

CREATE SEQUENCE abuse_report_user_mentions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_report_user_mentions_id_seq OWNED BY abuse_report_user_mentions.id;

CREATE TABLE abuse_reports (
    id bigint NOT NULL,
    reporter_id bigint,
    user_id bigint,
    message text,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    message_html text,
    cached_markdown_version integer,
    category smallint DEFAULT 1 NOT NULL,
    reported_from_url text DEFAULT ''::text NOT NULL,
    links_to_spam text[] DEFAULT '{}'::text[] NOT NULL,
    status smallint DEFAULT 1 NOT NULL,
    resolved_at timestamp with time zone,
    screenshot text,
    resolved_by_id bigint,
    assignee_id bigint,
    mitigation_steps text,
    evidence jsonb,
    assignee_id_convert_to_bigint bigint,
    id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
    reporter_id_convert_to_bigint bigint,
    resolved_by_id_convert_to_bigint bigint,
    user_id_convert_to_bigint bigint,
    CONSTRAINT abuse_reports_links_to_spam_length_check CHECK ((cardinality(links_to_spam) <= 20)),
    CONSTRAINT check_4b0a5120e0 CHECK ((char_length(screenshot) <= 255)),
    CONSTRAINT check_ab1260fa6c CHECK ((char_length(reported_from_url) <= 512)),
    CONSTRAINT check_f3c0947a2d CHECK ((char_length(mitigation_steps) <= 1000))
);

CREATE SEQUENCE abuse_reports_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_reports_id_seq OWNED BY abuse_reports.id;

CREATE TABLE abuse_trust_scores (
    id bigint NOT NULL,
    user_id bigint,
    score double precision NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    source smallint NOT NULL,
    correlation_id_value text,
    CONSTRAINT check_77ca9551db CHECK ((char_length(correlation_id_value) <= 255))
);

CREATE SEQUENCE abuse_trust_scores_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE abuse_trust_scores_id_seq OWNED BY abuse_trust_scores.id;

CREATE TABLE achievements (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    name text NOT NULL,
    avatar text,
    description text,
    CONSTRAINT check_5171b03f22 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_a7a7b84a80 CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_e174e93a9e CHECK ((char_length(avatar) <= 255))
);

CREATE SEQUENCE achievements_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE achievements_id_seq OWNED BY achievements.id;

CREATE TABLE activity_pub_releases_subscriptions (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    status smallint DEFAULT 1 NOT NULL,
    shared_inbox_url text,
    subscriber_inbox_url text,
    subscriber_url text NOT NULL,
    payload jsonb,
    CONSTRAINT check_0ebf38bcaa CHECK ((char_length(subscriber_inbox_url) <= 1024)),
    CONSTRAINT check_2afd35ba17 CHECK ((char_length(subscriber_url) <= 1024)),
    CONSTRAINT check_61b77ced49 CHECK ((char_length(shared_inbox_url) <= 1024))
);

CREATE SEQUENCE activity_pub_releases_subscriptions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE activity_pub_releases_subscriptions_id_seq OWNED BY activity_pub_releases_subscriptions.id;

CREATE TABLE agent_activity_events (
    id bigint NOT NULL,
    agent_id bigint NOT NULL,
    user_id bigint,
    project_id bigint,
    merge_request_id bigint,
    agent_token_id bigint,
    recorded_at timestamp with time zone NOT NULL,
    kind smallint NOT NULL,
    level smallint NOT NULL,
    sha bytea,
    detail text,
    agent_project_id bigint,
    CONSTRAINT check_068205e735 CHECK ((char_length(detail) <= 255)),
    CONSTRAINT check_9e09ffbd0f CHECK ((agent_project_id IS NOT NULL))
);

CREATE SEQUENCE agent_activity_events_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE agent_activity_events_id_seq OWNED BY agent_activity_events.id;

CREATE TABLE agent_group_authorizations (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    agent_id bigint NOT NULL,
    config jsonb NOT NULL
);

CREATE SEQUENCE agent_group_authorizations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE agent_group_authorizations_id_seq OWNED BY agent_group_authorizations.id;

CREATE TABLE agent_project_authorizations (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    agent_id bigint NOT NULL,
    config jsonb NOT NULL
);

CREATE SEQUENCE agent_project_authorizations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE agent_project_authorizations_id_seq OWNED BY agent_project_authorizations.id;

CREATE TABLE agent_user_access_group_authorizations (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    agent_id bigint NOT NULL,
    config jsonb NOT NULL
);

CREATE SEQUENCE agent_user_access_group_authorizations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE agent_user_access_group_authorizations_id_seq OWNED BY agent_user_access_group_authorizations.id;

CREATE TABLE agent_user_access_project_authorizations (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    agent_id bigint NOT NULL,
    config jsonb NOT NULL
);

CREATE SEQUENCE agent_user_access_project_authorizations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE agent_user_access_project_authorizations_id_seq OWNED BY agent_user_access_project_authorizations.id;

CREATE TABLE ai_agent_version_attachments (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    ai_agent_version_id bigint NOT NULL,
    ai_vectorizable_file_id bigint NOT NULL
);

CREATE SEQUENCE ai_agent_version_attachments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_agent_version_attachments_id_seq OWNED BY ai_agent_version_attachments.id;

CREATE TABLE ai_agent_versions (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    agent_id bigint NOT NULL,
    prompt text NOT NULL,
    model text NOT NULL,
    CONSTRAINT check_8cda7448e9 CHECK ((char_length(model) <= 255)),
    CONSTRAINT check_d7a4fc9834 CHECK ((char_length(prompt) <= 5000))
);

CREATE SEQUENCE ai_agent_versions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_agent_versions_id_seq OWNED BY ai_agent_versions.id;

CREATE TABLE ai_agents (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    name text NOT NULL,
    CONSTRAINT check_67934c8e85 CHECK ((char_length(name) <= 255))
);

CREATE SEQUENCE ai_agents_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_agents_id_seq OWNED BY ai_agents.id;

CREATE SEQUENCE ai_code_suggestion_events_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_code_suggestion_events_id_seq OWNED BY ai_code_suggestion_events.id;

CREATE TABLE ai_feature_settings (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    ai_self_hosted_model_id bigint,
    feature smallint NOT NULL,
    provider smallint NOT NULL
);

CREATE SEQUENCE ai_feature_settings_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_feature_settings_id_seq OWNED BY ai_feature_settings.id;

CREATE TABLE ai_self_hosted_models (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    model smallint NOT NULL,
    endpoint text NOT NULL,
    name text NOT NULL,
    encrypted_api_token bytea,
    encrypted_api_token_iv bytea,
    identifier text,
    CONSTRAINT check_a28005edb2 CHECK ((char_length(endpoint) <= 2048)),
    CONSTRAINT check_cccb37e0de CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_d1e593d04d CHECK ((char_length(identifier) <= 255))
);

CREATE SEQUENCE ai_self_hosted_models_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_self_hosted_models_id_seq OWNED BY ai_self_hosted_models.id;

CREATE TABLE ai_settings (
    id bigint NOT NULL,
    ai_gateway_url text,
    singleton boolean DEFAULT true NOT NULL,
    CONSTRAINT check_3cf9826589 CHECK ((char_length(ai_gateway_url) <= 2048)),
    CONSTRAINT check_singleton CHECK ((singleton IS TRUE))
);

COMMENT ON COLUMN ai_settings.singleton IS 'Always true, used for singleton enforcement';

CREATE SEQUENCE ai_settings_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_settings_id_seq OWNED BY ai_settings.id;

CREATE TABLE ai_testing_terms_acceptances (
    created_at timestamp with time zone NOT NULL,
    user_id bigint NOT NULL,
    user_email text NOT NULL,
    CONSTRAINT check_5efe98894e CHECK ((char_length(user_email) <= 255))
);

CREATE TABLE ai_vectorizable_files (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    name text NOT NULL,
    file text NOT NULL,
    CONSTRAINT check_c2ad8df0bf CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_fc6abf5b01 CHECK ((char_length(name) <= 255))
);

CREATE SEQUENCE ai_vectorizable_files_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE ai_vectorizable_files_id_seq OWNED BY ai_vectorizable_files.id;

CREATE TABLE alert_management_alert_assignees (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    alert_id bigint NOT NULL,
    project_id bigint
);

CREATE SEQUENCE alert_management_alert_assignees_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE alert_management_alert_assignees_id_seq OWNED BY alert_management_alert_assignees.id;

CREATE TABLE alert_management_alert_metric_images (
    id bigint NOT NULL,
    alert_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    file_store smallint,
    file text NOT NULL,
    url text,
    url_text text,
    project_id bigint,
    CONSTRAINT check_2587666252 CHECK ((char_length(url_text) <= 128)),
    CONSTRAINT check_4d811d9007 CHECK ((char_length(url) <= 255)),
    CONSTRAINT check_70fafae519 CHECK ((char_length(file) <= 255))
);

CREATE SEQUENCE alert_management_alert_metric_images_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE alert_management_alert_metric_images_id_seq OWNED BY alert_management_alert_metric_images.id;

CREATE TABLE alert_management_alert_user_mentions (
    id bigint NOT NULL,
    alert_management_alert_id bigint NOT NULL,
    note_id bigint,
    mentioned_users_ids bigint[],
    mentioned_projects_ids bigint[],
    mentioned_groups_ids bigint[],
    project_id bigint
);

CREATE SEQUENCE alert_management_alert_user_mentions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE alert_management_alert_user_mentions_id_seq OWNED BY alert_management_alert_user_mentions.id;

CREATE TABLE alert_management_alerts (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    started_at timestamp with time zone NOT NULL,
    ended_at timestamp with time zone,
    events integer DEFAULT 1 NOT NULL,
    iid integer NOT NULL,
    severity smallint DEFAULT 0 NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    fingerprint bytea,
    issue_id bigint,
    project_id bigint NOT NULL,
    title text NOT NULL,
    description text,
    service text,
    monitoring_tool text,
    hosts text[] DEFAULT '{}'::text[] NOT NULL,
    payload jsonb DEFAULT '{}'::jsonb NOT NULL,
    prometheus_alert_id bigint,
    environment_id bigint,
    domain smallint DEFAULT 0,
    CONSTRAINT check_2df3e2fdc1 CHECK ((char_length(monitoring_tool) <= 100)),
    CONSTRAINT check_5e9e57cadb CHECK ((char_length(description) <= 1000)),
    CONSTRAINT check_bac14dddde CHECK ((char_length(service) <= 100)),
    CONSTRAINT check_d1d1c2d14c CHECK ((char_length(title) <= 200))
);

CREATE SEQUENCE alert_management_alerts_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE alert_management_alerts_id_seq OWNED BY alert_management_alerts.id;

CREATE TABLE alert_management_http_integrations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    active boolean DEFAULT false NOT NULL,
    encrypted_token text NOT NULL,
    encrypted_token_iv text NOT NULL,
    endpoint_identifier text NOT NULL,
    name text NOT NULL,
    payload_example jsonb DEFAULT '{}'::jsonb NOT NULL,
    payload_attribute_mapping jsonb DEFAULT '{}'::jsonb NOT NULL,
    type_identifier smallint DEFAULT 0 NOT NULL,
    CONSTRAINT check_286943b636 CHECK ((char_length(encrypted_token_iv) <= 255)),
    CONSTRAINT check_392143ccf4 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_e270820180 CHECK ((char_length(endpoint_identifier) <= 255)),
    CONSTRAINT check_f68577c4af CHECK ((char_length(encrypted_token) <= 255))
);

CREATE SEQUENCE alert_management_http_integrations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE alert_management_http_integrations_id_seq OWNED BY alert_management_http_integrations.id;

CREATE TABLE allowed_email_domains (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    group_id bigint NOT NULL,
    domain character varying(255) NOT NULL
);

CREATE SEQUENCE allowed_email_domains_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE allowed_email_domains_id_seq OWNED BY allowed_email_domains.id;

CREATE TABLE analytics_cycle_analytics_aggregations (
    group_id bigint NOT NULL,
    incremental_runtimes_in_seconds integer[] DEFAULT '{}'::integer[] NOT NULL,
    incremental_processed_records integer[] DEFAULT '{}'::integer[] NOT NULL,
    last_incremental_issues_id bigint,
    last_incremental_merge_requests_id bigint,
    last_incremental_run_at timestamp with time zone,
    last_incremental_issues_updated_at timestamp with time zone,
    last_incremental_merge_requests_updated_at timestamp with time zone,
    last_full_run_at timestamp with time zone,
    last_consistency_check_updated_at timestamp with time zone,
    enabled boolean DEFAULT true NOT NULL,
    full_runtimes_in_seconds integer[] DEFAULT '{}'::integer[] NOT NULL,
    full_processed_records integer[] DEFAULT '{}'::integer[] NOT NULL,
    last_full_merge_requests_updated_at timestamp with time zone,
    last_full_issues_updated_at timestamp with time zone,
    last_full_issues_id bigint,
    last_full_merge_requests_id bigint,
    last_consistency_check_issues_stage_event_hash_id bigint,
    last_consistency_check_issues_start_event_timestamp timestamp with time zone,
    last_consistency_check_issues_end_event_timestamp timestamp with time zone,
    last_consistency_check_issues_issuable_id bigint,
    last_consistency_check_merge_requests_stage_event_hash_id bigint,
    last_consistency_check_merge_requests_start_event_timestamp timestamp with time zone,
    last_consistency_check_merge_requests_end_event_timestamp timestamp with time zone,
    last_consistency_check_merge_requests_issuable_id bigint,
    CONSTRAINT chk_rails_1ef688e577 CHECK ((cardinality(incremental_runtimes_in_seconds) <= 10)),
    CONSTRAINT chk_rails_e16bf3913a CHECK ((cardinality(incremental_processed_records) <= 10)),
    CONSTRAINT full_processed_records_size CHECK ((cardinality(full_processed_records) <= 10)),
    CONSTRAINT full_runtimes_in_seconds_size CHECK ((cardinality(full_runtimes_in_seconds) <= 10))
);

CREATE TABLE analytics_cycle_analytics_group_stages (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    relative_position integer,
    start_event_identifier integer NOT NULL,
    end_event_identifier integer NOT NULL,
    group_id bigint NOT NULL,
    start_event_label_id bigint,
    end_event_label_id bigint,
    hidden boolean DEFAULT false NOT NULL,
    custom boolean DEFAULT true NOT NULL,
    name character varying(255) NOT NULL,
    group_value_stream_id bigint NOT NULL,
    stage_event_hash_id bigint,
    CONSTRAINT check_e6bd4271b5 CHECK ((stage_event_hash_id IS NOT NULL))
);

CREATE SEQUENCE analytics_cycle_analytics_group_stages_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE analytics_cycle_analytics_group_stages_id_seq OWNED BY analytics_cycle_analytics_group_stages.id;

CREATE TABLE analytics_cycle_analytics_group_value_streams (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    group_id bigint NOT NULL,
    name text NOT NULL,
    CONSTRAINT check_bc1ed5f1f7 CHECK ((char_length(name) <= 100))
);

CREATE SEQUENCE analytics_cycle_analytics_group_value_streams_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE analytics_cycle_analytics_group_value_streams_id_seq OWNED BY analytics_cycle_analytics_group_value_streams.id;

CREATE TABLE analytics_cycle_analytics_stage_aggregations (
    group_id bigint NOT NULL,
    stage_id bigint NOT NULL,
    runtimes_in_seconds integer[] DEFAULT '{}'::integer[] NOT NULL,
    processed_records integer[] DEFAULT '{}'::integer[] NOT NULL,
    last_issues_id bigint,
    last_merge_requests_id bigint,
    last_run_at timestamp with time zone,
    last_issues_updated_at timestamp with time zone,
    last_merge_requests_updated_at timestamp with time zone,
    last_completed_at timestamp with time zone,
    enabled boolean DEFAULT true NOT NULL,
    CONSTRAINT chk_rails_50ee1c451c CHECK ((cardinality(runtimes_in_seconds) <= 10)),
    CONSTRAINT chk_rails_7586ea045d CHECK ((cardinality(processed_records) <= 10))
);

CREATE TABLE analytics_cycle_analytics_stage_event_hashes (
    id bigint NOT NULL,
    hash_sha256 bytea,
    organization_id bigint NOT NULL
);

CREATE SEQUENCE analytics_cycle_analytics_stage_event_hashes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE analytics_cycle_analytics_stage_event_hashes_id_seq OWNED BY analytics_cycle_analytics_stage_event_hashes.id;

CREATE TABLE analytics_cycle_analytics_value_stream_settings (
    value_stream_id bigint NOT NULL,
    project_ids_filter bigint[] DEFAULT '{}'::bigint[],
    namespace_id bigint NOT NULL,
    CONSTRAINT project_ids_filter_array_check CHECK (((cardinality(project_ids_filter) <= 100) AND (array_position(project_ids_filter, NULL::bigint) IS NULL)))
);

CREATE TABLE analytics_dashboards_pointers (
    id bigint NOT NULL,
    namespace_id bigint,
    project_id bigint,
    target_project_id bigint NOT NULL,
    CONSTRAINT chk_analytics_dashboards_pointers_project_or_namespace CHECK (((project_id IS NULL) <> (namespace_id IS NULL)))
);

CREATE SEQUENCE analytics_dashboards_pointers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE analytics_dashboards_pointers_id_seq OWNED BY analytics_dashboards_pointers.id;

CREATE TABLE analytics_devops_adoption_segments (
    id bigint NOT NULL,
    last_recorded_at timestamp with time zone,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    namespace_id bigint,
    display_namespace_id bigint
);

CREATE SEQUENCE analytics_devops_adoption_segments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE analytics_devops_adoption_segments_id_seq OWNED BY analytics_devops_adoption_segments.id;

CREATE TABLE analytics_devops_adoption_snapshots (
    id bigint NOT NULL,
    recorded_at timestamp with time zone NOT NULL,
    issue_opened boolean NOT NULL,
    merge_request_opened boolean NOT NULL,
    merge_request_approved boolean NOT NULL,
    runner_configured boolean NOT NULL,
    pipeline_succeeded boolean NOT NULL,
    deploy_succeeded boolean NOT NULL,
    end_time timestamp with time zone NOT NULL,
    total_projects_count integer,
    code_owners_used_count integer,
    namespace_id bigint,
    sast_enabled_count integer,
    dast_enabled_count integer,
    dependency_scanning_enabled_count integer,
    coverage_fuzzing_enabled_count integer,
    vulnerability_management_used_count integer,
    CONSTRAINT check_3f472de131 CHECK ((namespace_id IS NOT NULL))
);

CREATE SEQUENCE analytics_devops_adoption_snapshots_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE analytics_devops_adoption_snapshots_id_seq OWNED BY analytics_devops_adoption_snapshots.id;

CREATE TABLE analytics_language_trend_repository_languages (
    file_count integer DEFAULT 0 NOT NULL,
    programming_language_id bigint NOT NULL,
    project_id bigint NOT NULL,
    loc integer DEFAULT 0 NOT NULL,
    bytes integer DEFAULT 0 NOT NULL,
    percentage smallint DEFAULT 0 NOT NULL,
    snapshot_date date NOT NULL
);

CREATE TABLE analytics_usage_trends_measurements (
    id bigint NOT NULL,
    count bigint NOT NULL,
    recorded_at timestamp with time zone NOT NULL,
    identifier smallint NOT NULL
);

CREATE SEQUENCE analytics_usage_trends_measurements_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE analytics_usage_trends_measurements_id_seq OWNED BY analytics_usage_trends_measurements.id;

CREATE TABLE appearances (
    id bigint NOT NULL,
    title character varying NOT NULL,
    description text NOT NULL,
    logo character varying,
    updated_by integer,
    header_logo character varying,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    description_html text,
    cached_markdown_version integer,
    new_project_guidelines text,
    new_project_guidelines_html text,
    header_message text,
    header_message_html text,
    footer_message text,
    footer_message_html text,
    message_background_color text,
    message_font_color text,
    favicon character varying,
    email_header_and_footer_enabled boolean DEFAULT false NOT NULL,
    profile_image_guidelines text,
    profile_image_guidelines_html text,
    pwa_short_name text,
    pwa_icon text,
    pwa_name text,
    pwa_description text,
    member_guidelines text,
    member_guidelines_html text,
    CONSTRAINT appearances_profile_image_guidelines CHECK ((char_length(profile_image_guidelines) <= 4096)),
    CONSTRAINT check_13b2165eca CHECK ((char_length(pwa_name) <= 255)),
    CONSTRAINT check_50e9b69ab6 CHECK ((char_length(member_guidelines) <= 4096)),
    CONSTRAINT check_5c3fd63577 CHECK ((char_length(pwa_short_name) <= 255)),
    CONSTRAINT check_5e0e6f24ed CHECK ((char_length(pwa_description) <= 2048)),
    CONSTRAINT check_5e5b7ac344 CHECK ((char_length(pwa_icon) <= 1024))
);

CREATE SEQUENCE appearances_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE appearances_id_seq OWNED BY appearances.id;

CREATE TABLE application_setting_terms (
    id bigint NOT NULL,
    cached_markdown_version integer,
    terms text NOT NULL,
    terms_html text
);

CREATE SEQUENCE application_setting_terms_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE application_setting_terms_id_seq OWNED BY application_setting_terms.id;

CREATE TABLE application_settings (
    id bigint NOT NULL,
    default_projects_limit integer,
    signup_enabled boolean,
    gravatar_enabled boolean,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    home_page_url character varying,
    default_branch_protection integer DEFAULT 2,
    restricted_visibility_levels text,
    version_check_enabled boolean DEFAULT true,
    max_attachment_size integer DEFAULT 100 NOT NULL,
    default_project_visibility integer DEFAULT 0 NOT NULL,
    default_snippet_visibility integer DEFAULT 0 NOT NULL,
    user_oauth_applications boolean DEFAULT true,
    after_sign_out_path character varying,
    session_expire_delay integer DEFAULT 10080 NOT NULL,
    import_sources text,
    help_page_text text,
    require_admin_two_factor_authentication boolean DEFAULT false NOT NULL,
    shared_runners_enabled boolean DEFAULT true NOT NULL,
    max_artifacts_size integer DEFAULT 100 NOT NULL,
    max_pages_size integer DEFAULT 100 NOT NULL,
    require_two_factor_authentication boolean DEFAULT false,
    two_factor_grace_period integer DEFAULT 48,
    metrics_enabled boolean DEFAULT false,
    metrics_host character varying DEFAULT 'localhost'::character varying,
    metrics_pool_size integer DEFAULT 16,
    metrics_timeout integer DEFAULT 10,
    metrics_method_call_threshold integer DEFAULT 10,
    recaptcha_enabled boolean DEFAULT false,
    metrics_port integer DEFAULT 8089,
    akismet_enabled boolean DEFAULT false,
    metrics_sample_interval integer DEFAULT 15,
    email_author_in_body boolean DEFAULT false,
    default_group_visibility integer,
    repository_checks_enabled boolean DEFAULT false,
    shared_runners_text text,
    metrics_packet_size integer DEFAULT 1,
    disabled_oauth_sign_in_sources text,
    health_check_access_token character varying,
    container_registry_token_expire_delay integer DEFAULT 5,
    after_sign_up_text text,
    user_default_external boolean DEFAULT false NOT NULL,
    elasticsearch_indexing boolean DEFAULT false NOT NULL,
    elasticsearch_search boolean DEFAULT false NOT NULL,
    repository_storages character varying DEFAULT 'default'::character varying,
    enabled_git_access_protocol character varying,
    usage_ping_enabled boolean DEFAULT true NOT NULL,
    help_page_text_html text,
    shared_runners_text_html text,
    after_sign_up_text_html text,
    rsa_key_restriction integer DEFAULT 0 NOT NULL,
    dsa_key_restriction integer DEFAULT '-1'::integer NOT NULL,
    ecdsa_key_restriction integer DEFAULT 0 NOT NULL,
    ed25519_key_restriction integer DEFAULT 0 NOT NULL,
    housekeeping_enabled boolean DEFAULT true NOT NULL,
    housekeeping_bitmaps_enabled boolean DEFAULT true NOT NULL,
    housekeeping_incremental_repack_period integer DEFAULT 10 NOT NULL,
    housekeeping_full_repack_period integer DEFAULT 50 NOT NULL,
    housekeeping_gc_period integer DEFAULT 200 NOT NULL,
    html_emails_enabled boolean DEFAULT true,
    plantuml_url character varying,
    plantuml_enabled boolean,
    shared_runners_minutes integer DEFAULT 0 NOT NULL,
    repository_size_limit bigint DEFAULT 0,
    terminal_max_session_time integer DEFAULT 0 NOT NULL,
    unique_ips_limit_per_user integer,
    unique_ips_limit_time_window integer,
    unique_ips_limit_enabled boolean DEFAULT false NOT NULL,
    default_artifacts_expire_in character varying DEFAULT '0'::character varying NOT NULL,
    elasticsearch_url character varying DEFAULT 'http://localhost:9200'::character varying,
    elasticsearch_aws boolean DEFAULT false NOT NULL,
    elasticsearch_aws_region character varying DEFAULT 'us-east-1'::character varying,
    elasticsearch_aws_access_key character varying,
    geo_status_timeout integer DEFAULT 10,
    uuid character varying,
    polling_interval_multiplier numeric DEFAULT 1.0 NOT NULL,
    cached_markdown_version integer,
    check_namespace_plan boolean DEFAULT false NOT NULL,
    mirror_max_delay integer DEFAULT 300 NOT NULL,
    mirror_max_capacity integer DEFAULT 100 NOT NULL,
    mirror_capacity_threshold integer DEFAULT 50 NOT NULL,
    prometheus_metrics_enabled boolean DEFAULT true NOT NULL,
    authorized_keys_enabled boolean DEFAULT true NOT NULL,
    help_page_hide_commercial_content boolean DEFAULT false,
    help_page_support_url character varying,
    slack_app_enabled boolean DEFAULT false,
    slack_app_id character varying,
    performance_bar_allowed_group_id bigint,
    allow_group_owners_to_manage_ldap boolean DEFAULT true NOT NULL,
    hashed_storage_enabled boolean DEFAULT true NOT NULL,
    project_export_enabled boolean DEFAULT true NOT NULL,
    auto_devops_enabled boolean DEFAULT true NOT NULL,
    throttle_unauthenticated_enabled boolean DEFAULT false NOT NULL,
    throttle_unauthenticated_requests_per_period integer DEFAULT 3600 NOT NULL,
    throttle_unauthenticated_period_in_seconds integer DEFAULT 3600 NOT NULL,
    throttle_authenticated_api_enabled boolean DEFAULT false NOT NULL,
    throttle_authenticated_api_requests_per_period integer DEFAULT 7200 NOT NULL,
    throttle_authenticated_api_period_in_seconds integer DEFAULT 3600 NOT NULL,
    throttle_authenticated_web_enabled boolean DEFAULT false NOT NULL,
    throttle_authenticated_web_requests_per_period integer DEFAULT 7200 NOT NULL,
    throttle_authenticated_web_period_in_seconds integer DEFAULT 3600 NOT NULL,
    gitaly_timeout_default integer DEFAULT 55 NOT NULL,
    gitaly_timeout_medium integer DEFAULT 30 NOT NULL,
    gitaly_timeout_fast integer DEFAULT 10 NOT NULL,
    mirror_available boolean DEFAULT true NOT NULL,
    password_authentication_enabled_for_web boolean,
    password_authentication_enabled_for_git boolean DEFAULT true NOT NULL,
    auto_devops_domain character varying,
    external_authorization_service_enabled boolean DEFAULT false NOT NULL,
    external_authorization_service_url character varying,
    external_authorization_service_default_label character varying,
    pages_domain_verification_enabled boolean DEFAULT true NOT NULL,
    user_default_internal_regex character varying,
    external_authorization_service_timeout double precision DEFAULT 0.5,
    external_auth_client_cert text,
    encrypted_external_auth_client_key text,
    encrypted_external_auth_client_key_iv character varying,
    encrypted_external_auth_client_key_pass character varying,
    encrypted_external_auth_client_key_pass_iv character varying,
    email_additional_text character varying,
    enforce_terms boolean DEFAULT false,
    file_template_project_id bigint,
    pseudonymizer_enabled boolean DEFAULT false NOT NULL,
    hide_third_party_offers boolean DEFAULT false NOT NULL,
    snowplow_enabled boolean DEFAULT false NOT NULL,
    snowplow_collector_hostname character varying,
    snowplow_cookie_domain character varying,
    user_show_add_ssh_key_message boolean DEFAULT true NOT NULL,
    custom_project_templates_group_id bigint,
    usage_stats_set_by_user_id bigint,
    receive_max_input_size integer,
    diff_max_patch_bytes integer DEFAULT 204800 NOT NULL,
    archive_builds_in_seconds integer,
    commit_email_hostname character varying,
    protected_ci_variables boolean DEFAULT true NOT NULL,
    runners_registration_token_encrypted character varying,
    local_markdown_version integer DEFAULT 0 NOT NULL,
    first_day_of_week integer DEFAULT 0 NOT NULL,
    elasticsearch_limit_indexing boolean DEFAULT false NOT NULL,
    default_project_creation integer DEFAULT 2 NOT NULL,
    lets_encrypt_notification_email character varying,
    lets_encrypt_terms_of_service_accepted boolean DEFAULT false NOT NULL,
    geo_node_allowed_ips character varying DEFAULT '0.0.0.0/0, ::/0'::character varying,
    encrypted_lets_encrypt_private_key text,
    encrypted_lets_encrypt_private_key_iv text,
    dns_rebinding_protection_enabled boolean DEFAULT true NOT NULL,
    default_project_deletion_protection boolean DEFAULT false NOT NULL,
    grafana_enabled boolean DEFAULT false NOT NULL,
    lock_memberships_to_ldap boolean DEFAULT false NOT NULL,
    time_tracking_limit_to_hours boolean DEFAULT false NOT NULL,
    grafana_url character varying DEFAULT '/-/grafana'::character varying NOT NULL,
    login_recaptcha_protection_enabled boolean DEFAULT false NOT NULL,
    outbound_local_requests_whitelist character varying(255)[] DEFAULT '{}'::character varying[] NOT NULL,
    raw_blob_request_limit integer DEFAULT 300 NOT NULL,
    allow_local_requests_from_web_hooks_and_services boolean DEFAULT false NOT NULL,
    allow_local_requests_from_system_hooks boolean DEFAULT true NOT NULL,
    asset_proxy_enabled boolean DEFAULT false NOT NULL,
    asset_proxy_url character varying,
    encrypted_asset_proxy_secret_key text,
    encrypted_asset_proxy_secret_key_iv character varying,
    static_objects_external_storage_url character varying(255),
    max_personal_access_token_lifetime integer,
    throttle_protected_paths_enabled boolean DEFAULT false NOT NULL,
    throttle_protected_paths_requests_per_period integer DEFAULT 10 NOT NULL,
    throttle_protected_paths_period_in_seconds integer DEFAULT 60 NOT NULL,
    protected_paths character varying(255)[] DEFAULT '{/users/password,/users/sign_in,/api/v3/session.json,/api/v3/session,/api/v4/session.json,/api/v4/session,/users,/users/confirmation,/unsubscribes/,/import/github/personal_access_token,/admin/session}'::character varying[],
    throttle_incident_management_notification_enabled boolean DEFAULT false NOT NULL,
    throttle_incident_management_notification_period_in_seconds integer DEFAULT 3600,
    throttle_incident_management_notification_per_period integer DEFAULT 3600,
    push_event_hooks_limit integer DEFAULT 3 NOT NULL,
    push_event_activities_limit integer DEFAULT 3 NOT NULL,
    custom_http_clone_url_root character varying(511),
    deletion_adjourned_period integer DEFAULT 7 NOT NULL,
    license_trial_ends_on date,
    eks_integration_enabled boolean DEFAULT false NOT NULL,
    eks_account_id character varying(128),
    eks_access_key_id character varying(128),
    encrypted_eks_secret_access_key_iv character varying(255),
    encrypted_eks_secret_access_key text,
    snowplow_app_id character varying,
    productivity_analytics_start_date timestamp with time zone,
    default_ci_config_path character varying(255),
    sourcegraph_enabled boolean DEFAULT false NOT NULL,
    sourcegraph_url character varying(255),
    sourcegraph_public_only boolean DEFAULT true NOT NULL,
    snippet_size_limit bigint DEFAULT 52428800 NOT NULL,
    minimum_password_length integer DEFAULT 8 NOT NULL,
    encrypted_akismet_api_key text,
    encrypted_akismet_api_key_iv character varying(255),
    encrypted_elasticsearch_aws_secret_access_key text,
    encrypted_elasticsearch_aws_secret_access_key_iv character varying(255),
    encrypted_recaptcha_private_key text,
    encrypted_recaptcha_private_key_iv character varying(255),
    encrypted_recaptcha_site_key text,
    encrypted_recaptcha_site_key_iv character varying(255),
    encrypted_slack_app_secret text,
    encrypted_slack_app_secret_iv character varying(255),
    encrypted_slack_app_verification_token text,
    encrypted_slack_app_verification_token_iv character varying(255),
    force_pages_access_control boolean DEFAULT false NOT NULL,
    updating_name_disabled_for_users boolean DEFAULT false NOT NULL,
    elasticsearch_indexed_field_length_limit integer DEFAULT 0 NOT NULL,
    elasticsearch_max_bulk_size_mb smallint DEFAULT 10 NOT NULL,
    elasticsearch_max_bulk_concurrency smallint DEFAULT 10 NOT NULL,
    disable_overriding_approvers_per_merge_request boolean DEFAULT false NOT NULL,
    prevent_merge_requests_author_approval boolean DEFAULT false NOT NULL,
    prevent_merge_requests_committers_approval boolean DEFAULT false NOT NULL,
    email_restrictions_enabled boolean DEFAULT false NOT NULL,
    email_restrictions text,
    npm_package_requests_forwarding boolean DEFAULT true NOT NULL,
    container_expiration_policies_enable_historic_entries boolean DEFAULT false NOT NULL,
    issues_create_limit integer DEFAULT 0 NOT NULL,
    push_rule_id bigint,
    group_owners_can_manage_default_branch_protection boolean DEFAULT true NOT NULL,
    container_registry_vendor text DEFAULT ''::text NOT NULL,
    container_registry_version text DEFAULT ''::text NOT NULL,
    container_registry_features text[] DEFAULT '{}'::text[] NOT NULL,
    spam_check_endpoint_url text,
    spam_check_endpoint_enabled boolean DEFAULT false NOT NULL,
    elasticsearch_pause_indexing boolean DEFAULT false NOT NULL,
    repository_storages_weighted jsonb DEFAULT '{}'::jsonb NOT NULL,
    max_import_size integer DEFAULT 0 NOT NULL,
    compliance_frameworks smallint[] DEFAULT '{}'::smallint[] NOT NULL,
    notify_on_unknown_sign_in boolean DEFAULT true NOT NULL,
    default_branch_name text,
    project_import_limit integer DEFAULT 6 NOT NULL,
    project_export_limit integer DEFAULT 6 NOT NULL,
    project_download_export_limit integer DEFAULT 1 NOT NULL,
    group_import_limit integer DEFAULT 6 NOT NULL,
    group_export_limit integer DEFAULT 6 NOT NULL,
    group_download_export_limit integer DEFAULT 1 NOT NULL,
    maintenance_mode boolean DEFAULT false NOT NULL,
    maintenance_mode_message text,
    wiki_page_max_content_bytes bigint DEFAULT 52428800 NOT NULL,
    elasticsearch_indexed_file_size_limit_kb integer DEFAULT 1024 NOT NULL,
    enforce_namespace_storage_limit boolean DEFAULT false NOT NULL,
    container_registry_delete_tags_service_timeout integer DEFAULT 250 NOT NULL,
    kroki_url character varying,
    kroki_enabled boolean,
    elasticsearch_client_request_timeout integer DEFAULT 0 NOT NULL,
    gitpod_enabled boolean DEFAULT false NOT NULL,
    gitpod_url text DEFAULT 'https://gitpod.io/'::text,
    abuse_notification_email character varying,
    require_admin_approval_after_user_signup boolean DEFAULT true NOT NULL,
    help_page_documentation_base_url text,
    automatic_purchased_storage_allocation boolean DEFAULT false NOT NULL,
    encrypted_ci_jwt_signing_key text,
    encrypted_ci_jwt_signing_key_iv text,
    container_registry_expiration_policies_worker_capacity integer DEFAULT 4 NOT NULL,
    elasticsearch_analyzers_smartcn_enabled boolean DEFAULT false NOT NULL,
    elasticsearch_analyzers_smartcn_search boolean DEFAULT false NOT NULL,
    elasticsearch_analyzers_kuromoji_enabled boolean DEFAULT false NOT NULL,
    elasticsearch_analyzers_kuromoji_search boolean DEFAULT false NOT NULL,
    secret_detection_token_revocation_enabled boolean DEFAULT false NOT NULL,
    secret_detection_token_revocation_url text,
    encrypted_secret_detection_token_revocation_token text,
    encrypted_secret_detection_token_revocation_token_iv text,
    domain_denylist_enabled boolean DEFAULT false,
    domain_denylist text,
    domain_allowlist text,
    new_user_signups_cap integer,
    encrypted_cloud_license_auth_token text,
    encrypted_cloud_license_auth_token_iv text,
    secret_detection_revocation_token_types_url text,
    disable_feed_token boolean DEFAULT false NOT NULL,
    personal_access_token_prefix text DEFAULT 'glpat-'::text,
    rate_limiting_response_text text,
    invisible_captcha_enabled boolean DEFAULT false NOT NULL,
    container_registry_cleanup_tags_service_max_list_size integer DEFAULT 200 NOT NULL,
    git_two_factor_session_expiry integer DEFAULT 15 NOT NULL,
    keep_latest_artifact boolean DEFAULT true NOT NULL,
    notes_create_limit integer DEFAULT 300 NOT NULL,
    notes_create_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
    kroki_formats jsonb DEFAULT '{}'::jsonb NOT NULL,
    asset_proxy_whitelist text,
    admin_mode boolean DEFAULT false NOT NULL,
    external_pipeline_validation_service_timeout integer,
    encrypted_external_pipeline_validation_service_token text,
    encrypted_external_pipeline_validation_service_token_iv text,
    external_pipeline_validation_service_url text,
    throttle_unauthenticated_packages_api_requests_per_period integer DEFAULT 800 NOT NULL,
    throttle_unauthenticated_packages_api_period_in_seconds integer DEFAULT 15 NOT NULL,
    throttle_authenticated_packages_api_requests_per_period integer DEFAULT 1000 NOT NULL,
    throttle_authenticated_packages_api_period_in_seconds integer DEFAULT 15 NOT NULL,
    throttle_unauthenticated_packages_api_enabled boolean DEFAULT false NOT NULL,
    throttle_authenticated_packages_api_enabled boolean DEFAULT false NOT NULL,
    deactivate_dormant_users boolean DEFAULT false NOT NULL,
    whats_new_variant smallint DEFAULT 0,
    encrypted_spam_check_api_key bytea,
    encrypted_spam_check_api_key_iv bytea,
    floc_enabled boolean DEFAULT false NOT NULL,
    elasticsearch_username text,
    encrypted_elasticsearch_password bytea,
    encrypted_elasticsearch_password_iv bytea,
    diff_max_lines integer DEFAULT 50000 NOT NULL,
    diff_max_files integer DEFAULT 1000 NOT NULL,
    valid_runner_registrars character varying[] DEFAULT '{project,group}'::character varying[],
    encrypted_mailgun_signing_key bytea,
    encrypted_mailgun_signing_key_iv bytea,
    mailgun_events_enabled boolean DEFAULT false NOT NULL,
    usage_ping_features_enabled boolean DEFAULT false NOT NULL,
    encrypted_customers_dot_jwt_signing_key bytea,
    encrypted_customers_dot_jwt_signing_key_iv bytea,
    pypi_package_requests_forwarding boolean DEFAULT true NOT NULL,
    throttle_unauthenticated_files_api_requests_per_period integer DEFAULT 125 NOT NULL,
    throttle_unauthenticated_files_api_period_in_seconds integer DEFAULT 15 NOT NULL,
    throttle_authenticated_files_api_requests_per_period integer DEFAULT 500 NOT NULL,
    throttle_authenticated_files_api_period_in_seconds integer DEFAULT 15 NOT NULL,
    throttle_unauthenticated_files_api_enabled boolean DEFAULT false NOT NULL,
    throttle_authenticated_files_api_enabled boolean DEFAULT false NOT NULL,
    max_yaml_size_bytes bigint DEFAULT 2097152 NOT NULL,
    max_yaml_depth integer DEFAULT 100 NOT NULL,
    throttle_authenticated_git_lfs_requests_per_period integer DEFAULT 1000 NOT NULL,
    throttle_authenticated_git_lfs_period_in_seconds integer DEFAULT 60 NOT NULL,
    throttle_authenticated_git_lfs_enabled boolean DEFAULT false NOT NULL,
    user_deactivation_emails_enabled boolean DEFAULT true NOT NULL,
    throttle_unauthenticated_api_enabled boolean DEFAULT false NOT NULL,
    throttle_unauthenticated_api_requests_per_period integer DEFAULT 3600 NOT NULL,
    throttle_unauthenticated_api_period_in_seconds integer DEFAULT 3600 NOT NULL,
    jobs_per_stage_page_size integer DEFAULT 200 NOT NULL,
    sidekiq_job_limiter_mode smallint DEFAULT 1 NOT NULL,
    sidekiq_job_limiter_compression_threshold_bytes integer DEFAULT 100000 NOT NULL,
    sidekiq_job_limiter_limit_bytes integer DEFAULT 0 NOT NULL,
    suggest_pipeline_enabled boolean DEFAULT true NOT NULL,
    throttle_unauthenticated_deprecated_api_requests_per_period integer DEFAULT 1800 NOT NULL,
    throttle_unauthenticated_deprecated_api_period_in_seconds integer DEFAULT 3600 NOT NULL,
    throttle_unauthenticated_deprecated_api_enabled boolean DEFAULT false NOT NULL,
    throttle_authenticated_deprecated_api_requests_per_period integer DEFAULT 3600 NOT NULL,
    throttle_authenticated_deprecated_api_period_in_seconds integer DEFAULT 3600 NOT NULL,
    throttle_authenticated_deprecated_api_enabled boolean DEFAULT false NOT NULL,
    dependency_proxy_ttl_group_policy_worker_capacity smallint DEFAULT 2 NOT NULL,
    content_validation_endpoint_url text,
    encrypted_content_validation_api_key bytea,
    encrypted_content_validation_api_key_iv bytea,
    content_validation_endpoint_enabled boolean DEFAULT false NOT NULL,
    sentry_enabled boolean DEFAULT false NOT NULL,
    sentry_dsn text,
    sentry_clientside_dsn text,
    sentry_environment text,
    max_ssh_key_lifetime integer,
    static_objects_external_storage_auth_token_encrypted text,
    future_subscriptions jsonb DEFAULT '[]'::jsonb NOT NULL,
    packages_cleanup_package_file_worker_capacity smallint DEFAULT 2 NOT NULL,
    runner_token_expiration_interval integer,
    group_runner_token_expiration_interval integer,
    project_runner_token_expiration_interval integer,
    ecdsa_sk_key_restriction integer DEFAULT 0 NOT NULL,
    ed25519_sk_key_restriction integer DEFAULT 0 NOT NULL,
    users_get_by_id_limit integer DEFAULT 300 NOT NULL,
    users_get_by_id_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
    container_registry_expiration_policies_caching boolean DEFAULT true NOT NULL,
    search_rate_limit integer DEFAULT 300 NOT NULL,
    search_rate_limit_unauthenticated integer DEFAULT 100 NOT NULL,
    encrypted_database_grafana_api_key bytea,
    encrypted_database_grafana_api_key_iv bytea,
    database_grafana_api_url text,
    database_grafana_tag text,
    public_runner_releases_url text DEFAULT 'https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-runner/releases'::text NOT NULL,
    password_uppercase_required boolean DEFAULT false NOT NULL,
    password_lowercase_required boolean DEFAULT false NOT NULL,
    password_number_required boolean DEFAULT false NOT NULL,
    password_symbol_required boolean DEFAULT false NOT NULL,
    encrypted_arkose_labs_public_api_key bytea,
    encrypted_arkose_labs_public_api_key_iv bytea,
    encrypted_arkose_labs_private_api_key bytea,
    encrypted_arkose_labs_private_api_key_iv bytea,
    delete_inactive_projects boolean DEFAULT false NOT NULL,
    inactive_projects_delete_after_months integer DEFAULT 2 NOT NULL,
    inactive_projects_min_size_mb integer DEFAULT 0 NOT NULL,
    inactive_projects_send_warning_email_after_months integer DEFAULT 1 NOT NULL,
    maven_package_requests_forwarding boolean DEFAULT true NOT NULL,
    arkose_labs_namespace text DEFAULT 'client'::text NOT NULL,
    max_export_size integer DEFAULT 0,
    encrypted_slack_app_signing_secret bytea,
    encrypted_slack_app_signing_secret_iv bytea,
    pipeline_limit_per_project_user_sha integer DEFAULT 0 NOT NULL,
    dingtalk_integration_enabled boolean DEFAULT false NOT NULL,
    encrypted_dingtalk_corpid bytea,
    encrypted_dingtalk_corpid_iv bytea,
    encrypted_dingtalk_app_key bytea,
    encrypted_dingtalk_app_key_iv bytea,
    encrypted_dingtalk_app_secret bytea,
    encrypted_dingtalk_app_secret_iv bytea,
    jira_connect_application_key text,
    globally_allowed_ips text DEFAULT ''::text NOT NULL,
    license_usage_data_exported boolean DEFAULT false NOT NULL,
    phone_verification_code_enabled boolean DEFAULT false NOT NULL,
    max_number_of_repository_downloads smallint DEFAULT 0 NOT NULL,
    max_number_of_repository_downloads_within_time_period integer DEFAULT 0 NOT NULL,
    feishu_integration_enabled boolean DEFAULT false NOT NULL,
    encrypted_feishu_app_key bytea,
    encrypted_feishu_app_key_iv bytea,
    encrypted_feishu_app_secret bytea,
    encrypted_feishu_app_secret_iv bytea,
    error_tracking_enabled boolean DEFAULT false NOT NULL,
    error_tracking_api_url text,
    git_rate_limit_users_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
    error_tracking_access_token_encrypted text,
    invitation_flow_enforcement boolean DEFAULT false NOT NULL,
    package_registry_cleanup_policies_worker_capacity integer DEFAULT 2 NOT NULL,
    deactivate_dormant_users_period integer DEFAULT 90 NOT NULL,
    auto_ban_user_on_excessive_projects_download boolean DEFAULT false NOT NULL,
    max_pages_custom_domains_per_project integer DEFAULT 0 NOT NULL,
    cube_api_base_url text,
    encrypted_cube_api_key bytea,
    encrypted_cube_api_key_iv bytea,
    dashboard_limit_enabled boolean DEFAULT false NOT NULL,
    dashboard_limit integer DEFAULT 0 NOT NULL,
    can_create_group boolean DEFAULT true NOT NULL,
    lock_maven_package_requests_forwarding boolean DEFAULT false NOT NULL,
    lock_pypi_package_requests_forwarding boolean DEFAULT false NOT NULL,
    lock_npm_package_requests_forwarding boolean DEFAULT false NOT NULL,
    jira_connect_proxy_url text,
    password_expiration_enabled boolean DEFAULT false NOT NULL,
    password_expires_in_days integer DEFAULT 90 NOT NULL,
    password_expires_notice_before_days integer DEFAULT 7 NOT NULL,
    product_analytics_enabled boolean DEFAULT false NOT NULL,
    email_confirmation_setting smallint DEFAULT 0,
    disable_admin_oauth_scopes boolean DEFAULT false NOT NULL,
    default_preferred_language text DEFAULT 'en'::text NOT NULL,
    disable_download_button boolean DEFAULT false NOT NULL,
    encrypted_telesign_customer_xid bytea,
    encrypted_telesign_customer_xid_iv bytea,
    encrypted_telesign_api_key bytea,
    encrypted_telesign_api_key_iv bytea,
    disable_personal_access_tokens boolean DEFAULT false NOT NULL,
    max_terraform_state_size_bytes integer DEFAULT 0 NOT NULL,
    bulk_import_enabled boolean DEFAULT false NOT NULL,
    allow_runner_registration_token boolean DEFAULT true NOT NULL,
    user_defaults_to_private_profile boolean DEFAULT false NOT NULL,
    allow_possible_spam boolean DEFAULT false NOT NULL,
    default_syntax_highlighting_theme integer DEFAULT 1 NOT NULL,
    search_max_shard_size_gb integer DEFAULT 50 NOT NULL,
    search_max_docs_denominator integer DEFAULT 5000000 NOT NULL,
    search_min_docs_before_rollover integer DEFAULT 100000 NOT NULL,
    deactivation_email_additional_text text,
    jira_connect_public_key_storage_enabled boolean DEFAULT false NOT NULL,
    git_rate_limit_users_alertlist integer[] DEFAULT '{}'::integer[] NOT NULL,
    allow_deploy_tokens_and_keys_with_external_authn boolean DEFAULT false NOT NULL,
    security_policy_global_group_approvers_enabled boolean DEFAULT true NOT NULL,
    projects_api_rate_limit_unauthenticated integer DEFAULT 400 NOT NULL,
    deny_all_requests_except_allowed boolean DEFAULT false NOT NULL,
    product_analytics_data_collector_host text,
    lock_memberships_to_saml boolean DEFAULT false NOT NULL,
    gitlab_dedicated_instance boolean DEFAULT false NOT NULL,
    update_runner_versions_enabled boolean DEFAULT true NOT NULL,
    encrypted_openai_api_key bytea,
    encrypted_openai_api_key_iv bytea,
    database_max_running_batched_background_migrations integer DEFAULT 2 NOT NULL,
    encrypted_product_analytics_configurator_connection_string bytea,
    encrypted_product_analytics_configurator_connection_string_iv bytea,
    silent_mode_enabled boolean DEFAULT false NOT NULL,
    package_metadata_purl_types smallint[] DEFAULT '{1,2,3,4,5,6,7,8,9,10,11,12,13,14}'::smallint[],
    ci_max_includes integer DEFAULT 150 NOT NULL,
    remember_me_enabled boolean DEFAULT true NOT NULL,
    encrypted_anthropic_api_key bytea,
    encrypted_anthropic_api_key_iv bytea,
    diagramsnet_enabled boolean DEFAULT true NOT NULL,
    diagramsnet_url text DEFAULT 'https://embed.diagrams.net'::text,
    allow_account_deletion boolean DEFAULT true NOT NULL,
    wiki_asciidoc_allow_uri_includes boolean DEFAULT false NOT NULL,
    namespace_aggregation_schedule_lease_duration_in_seconds integer DEFAULT 300 NOT NULL,
    container_registry_data_repair_detail_worker_max_concurrency integer DEFAULT 2 NOT NULL,
    vertex_ai_host text,
    encrypted_vertex_ai_credentials bytea,
    encrypted_vertex_ai_credentials_iv bytea,
    vertex_ai_project text,
    delete_unconfirmed_users boolean DEFAULT false NOT NULL,
    unconfirmed_users_delete_after_days integer DEFAULT 7 NOT NULL,
    default_branch_protection_defaults jsonb DEFAULT '{}'::jsonb NOT NULL,
    gitlab_shell_operation_limit integer DEFAULT 600,
    elasticsearch_requeue_workers boolean DEFAULT false NOT NULL,
    elasticsearch_worker_number_of_shards integer DEFAULT 2 NOT NULL,
    protected_paths_for_get_request text[] DEFAULT '{}'::text[] NOT NULL,
    namespace_storage_forks_cost_factor double precision DEFAULT 1.0 NOT NULL,
    package_registry_allow_anyone_to_pull_option boolean DEFAULT true NOT NULL,
    bulk_import_max_download_file_size bigint DEFAULT 5120 NOT NULL,
    max_import_remote_file_size bigint DEFAULT 10240 NOT NULL,
    max_decompressed_archive_size integer DEFAULT 25600 NOT NULL,
    sentry_clientside_traces_sample_rate double precision DEFAULT 0.0 NOT NULL,
    prometheus_alert_db_indicators_settings jsonb,
    ci_max_total_yaml_size_bytes integer DEFAULT 314572800 NOT NULL,
    decompress_archive_file_timeout integer DEFAULT 210 NOT NULL,
    search_rate_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
    snowplow_database_collector_hostname text,
    container_registry_db_enabled boolean DEFAULT false NOT NULL,
    failed_login_attempts_unlock_period_in_minutes integer,
    max_login_attempts integer,
    encrypted_vertex_ai_access_token bytea,
    encrypted_vertex_ai_access_token_iv bytea,
    project_jobs_api_rate_limit integer DEFAULT 600 NOT NULL,
    math_rendering_limits_enabled boolean DEFAULT true NOT NULL,
    service_access_tokens_expiration_enforced boolean DEFAULT true NOT NULL,
    make_profile_private boolean DEFAULT true NOT NULL,
    enable_artifact_external_redirect_warning_page boolean DEFAULT true NOT NULL,
    allow_project_creation_for_guest_and_below boolean DEFAULT true NOT NULL,
    update_namespace_name_rate_limit smallint DEFAULT 120 NOT NULL,
    pre_receive_secret_detection_enabled boolean DEFAULT false NOT NULL,
    can_create_organization boolean DEFAULT true NOT NULL,
    bulk_import_concurrent_pipeline_batch_limit smallint DEFAULT 25 NOT NULL,
    web_ide_oauth_application_id bigint,
    instance_level_ai_beta_features_enabled boolean DEFAULT false NOT NULL,
    security_txt_content text,
    encrypted_arkose_labs_data_exchange_key bytea,
    encrypted_arkose_labs_data_exchange_key_iv bytea,
    rate_limits jsonb DEFAULT '{}'::jsonb NOT NULL,
    elasticsearch_max_code_indexing_concurrency integer DEFAULT 30 NOT NULL,
    enable_member_promotion_management boolean DEFAULT false NOT NULL,
    lock_math_rendering_limits_enabled boolean DEFAULT false NOT NULL,
    security_approval_policies_limit integer DEFAULT 5 NOT NULL,
    encrypted_arkose_labs_client_xid bytea,
    encrypted_arkose_labs_client_xid_iv bytea,
    encrypted_arkose_labs_client_secret bytea,
    encrypted_arkose_labs_client_secret_iv bytea,
    duo_features_enabled boolean DEFAULT true NOT NULL,
    lock_duo_features_enabled boolean DEFAULT false NOT NULL,
    asciidoc_max_includes smallint DEFAULT 32 NOT NULL,
    clickhouse jsonb DEFAULT '{}'::jsonb NOT NULL,
    include_optional_metrics_in_service_ping boolean DEFAULT true NOT NULL,
    zoekt_settings jsonb DEFAULT '{}'::jsonb NOT NULL,
    service_ping_settings jsonb DEFAULT '{}'::jsonb NOT NULL,
    package_registry jsonb DEFAULT '{}'::jsonb NOT NULL,
    rate_limits_unauthenticated_git_http jsonb DEFAULT '{}'::jsonb NOT NULL,
    importers jsonb DEFAULT '{}'::jsonb NOT NULL,
    security_policy_scheduled_scans_max_concurrency integer DEFAULT 10000 NOT NULL,
    code_creation jsonb DEFAULT '{}'::jsonb NOT NULL,
    code_suggestions_api_rate_limit integer DEFAULT 60 NOT NULL,
    ai_action_api_rate_limit integer DEFAULT 160 NOT NULL,
    require_personal_access_token_expiry boolean DEFAULT true NOT NULL,
    duo_workflow jsonb DEFAULT '{}'::jsonb,
    max_artifacts_content_include_size integer DEFAULT 5242880 NOT NULL,
    max_number_of_vulnerabilities_per_project integer,
    cluster_agents jsonb DEFAULT '{}'::jsonb NOT NULL,
    observability_backend_ssl_verification_enabled boolean DEFAULT true NOT NULL,
    pages jsonb DEFAULT '{}'::jsonb NOT NULL,
    security_policies jsonb DEFAULT '{}'::jsonb NOT NULL,
    spp_repository_pipeline_access boolean DEFAULT false NOT NULL,
    lock_spp_repository_pipeline_access boolean DEFAULT false NOT NULL,
    required_instance_ci_template text,
    enforce_ci_inbound_job_token_scope_enabled boolean DEFAULT false NOT NULL,
    allow_top_level_group_owners_to_create_service_accounts boolean DEFAULT false NOT NULL,
    sign_in_restrictions jsonb DEFAULT '{}'::jsonb NOT NULL,
    transactional_emails jsonb DEFAULT '{}'::jsonb NOT NULL,
    identity_verification_settings jsonb DEFAULT '{}'::jsonb NOT NULL,
    elasticsearch_retry_on_failure integer DEFAULT 0 NOT NULL,
    integrations jsonb DEFAULT '{}'::jsonb NOT NULL,
    user_seat_management jsonb DEFAULT '{}'::jsonb NOT NULL,
    CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
    CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)),
    CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)),
    CONSTRAINT app_settings_failed_login_attempts_unlock_period_positive CHECK ((failed_login_attempts_unlock_period_in_minutes > 0)),
    CONSTRAINT app_settings_git_rate_limit_users_alertlist_max_usernames CHECK ((cardinality(git_rate_limit_users_alertlist) <= 100)),
    CONSTRAINT app_settings_git_rate_limit_users_allowlist_max_usernames CHECK ((cardinality(git_rate_limit_users_allowlist) <= 100)),
    CONSTRAINT app_settings_max_decompressed_archive_size_positive CHECK ((max_decompressed_archive_size >= 0)),
    CONSTRAINT app_settings_max_login_attempts_positive CHECK ((max_login_attempts > 0)),
    CONSTRAINT app_settings_max_pages_custom_domains_per_project_check CHECK ((max_pages_custom_domains_per_project >= 0)),
    CONSTRAINT app_settings_max_terraform_state_size_bytes_check CHECK ((max_terraform_state_size_bytes >= 0)),
    CONSTRAINT app_settings_p_cleanup_package_file_worker_capacity_positive CHECK ((packages_cleanup_package_file_worker_capacity >= 0)),
    CONSTRAINT app_settings_pkg_registry_cleanup_pol_worker_capacity_gte_zero CHECK ((package_registry_cleanup_policies_worker_capacity >= 0)),
    CONSTRAINT app_settings_protected_paths_max_length CHECK ((cardinality(protected_paths_for_get_request) <= 100)),
    CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)),
    CONSTRAINT app_settings_registry_repair_worker_max_concurrency_positive CHECK ((container_registry_data_repair_detail_worker_max_concurrency >= 0)),
    CONSTRAINT app_settings_yaml_max_depth_positive CHECK ((max_yaml_depth > 0)),
    CONSTRAINT app_settings_yaml_max_size_positive CHECK ((max_yaml_size_bytes > 0)),
    CONSTRAINT check_0542340619 CHECK ((char_length(diagramsnet_url) <= 2048)),
    CONSTRAINT check_12f01f1dcd CHECK ((char_length(vertex_ai_project) <= 255)),
    CONSTRAINT check_17d9558205 CHECK ((char_length((kroki_url)::text) <= 1024)),
    CONSTRAINT check_2b820eaac3 CHECK ((char_length(database_grafana_tag) <= 255)),
    CONSTRAINT check_2dba05b802 CHECK ((char_length(gitpod_url) <= 255)),
    CONSTRAINT check_32710817e9 CHECK ((char_length(static_objects_external_storage_auth_token_encrypted) <= 255)),
    CONSTRAINT check_3455368420 CHECK ((char_length(database_grafana_api_url) <= 255)),
    CONSTRAINT check_3b22213b72 CHECK ((char_length(snowplow_database_collector_hostname) <= 255)),
    CONSTRAINT check_3def0f1829 CHECK ((char_length(sentry_clientside_dsn) <= 255)),
    CONSTRAINT check_4847426287 CHECK ((char_length(jira_connect_proxy_url) <= 255)),
    CONSTRAINT check_492cc1354d CHECK ((char_length(error_tracking_api_url) <= 255)),
    CONSTRAINT check_4f8b811780 CHECK ((char_length(sentry_dsn) <= 255)),
    CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)),
    CONSTRAINT check_5688c70478 CHECK ((char_length(error_tracking_access_token_encrypted) <= 255)),
    CONSTRAINT check_57123c9593 CHECK ((char_length(help_page_documentation_base_url) <= 255)),
    CONSTRAINT check_5a84c3ffdc CHECK ((char_length(content_validation_endpoint_url) <= 255)),
    CONSTRAINT check_5bcba483c4 CHECK ((char_length(sentry_environment) <= 255)),
    CONSTRAINT check_718b4458ae CHECK ((char_length(personal_access_token_prefix) <= 20)),
    CONSTRAINT check_7227fad848 CHECK ((char_length(rate_limiting_response_text) <= 255)),
    CONSTRAINT check_72c984b2a5 CHECK ((char_length(product_analytics_data_collector_host) <= 255)),
    CONSTRAINT check_734cc9407a CHECK ((char_length(globally_allowed_ips) <= 255)),
    CONSTRAINT check_7ccfe2764a CHECK ((char_length(arkose_labs_namespace) <= 255)),
    CONSTRAINT check_85a39b68ff CHECK ((char_length(encrypted_ci_jwt_signing_key_iv) <= 255)),
    CONSTRAINT check_8dca35398a CHECK ((char_length(public_runner_releases_url) <= 255)),
    CONSTRAINT check_8e7df605a1 CHECK ((char_length(cube_api_base_url) <= 512)),
    CONSTRAINT check_9a719834eb CHECK ((char_length(secret_detection_token_revocation_url) <= 255)),
    CONSTRAINT check_9c6c447a13 CHECK ((char_length(maintenance_mode_message) <= 255)),
    CONSTRAINT check_a5704163cc CHECK ((char_length(secret_detection_revocation_token_types_url) <= 255)),
    CONSTRAINT check_ae53cf7f82 CHECK ((char_length(vertex_ai_host) <= 255)),
    CONSTRAINT check_app_settings_namespace_storage_forks_cost_factor_range CHECK (((namespace_storage_forks_cost_factor >= (0)::double precision) AND (namespace_storage_forks_cost_factor <= (1)::double precision))),
    CONSTRAINT check_app_settings_sentry_clientside_traces_sample_rate_range CHECK (((sentry_clientside_traces_sample_rate >= (0)::double precision) AND (sentry_clientside_traces_sample_rate <= (1)::double precision))),
    CONSTRAINT check_application_settings_clickhouse_is_hash CHECK ((jsonb_typeof(clickhouse) = 'object'::text)),
    CONSTRAINT check_application_settings_cluster_agents_is_hash CHECK ((jsonb_typeof(cluster_agents) = 'object'::text)),
    CONSTRAINT check_application_settings_code_creation_is_hash CHECK ((jsonb_typeof(code_creation) = 'object'::text)),
    CONSTRAINT check_application_settings_duo_workflow_is_hash CHECK ((jsonb_typeof(duo_workflow) = 'object'::text)),
    CONSTRAINT check_application_settings_importers_is_hash CHECK ((jsonb_typeof(importers) = 'object'::text)),
    CONSTRAINT check_application_settings_integrations_is_hash CHECK ((jsonb_typeof(integrations) = 'object'::text)),
    CONSTRAINT check_application_settings_package_registry_is_hash CHECK ((jsonb_typeof(package_registry) = 'object'::text)),
    CONSTRAINT check_application_settings_rate_limits_is_hash CHECK ((jsonb_typeof(rate_limits) = 'object'::text)),
    CONSTRAINT check_application_settings_rate_limits_unauth_git_http_is_hash CHECK ((jsonb_typeof(rate_limits_unauthenticated_git_http) = 'object'::text)),
    CONSTRAINT check_application_settings_security_policies_is_hash CHECK ((jsonb_typeof(security_policies) = 'object'::text)),
    CONSTRAINT check_application_settings_service_ping_settings_is_hash CHECK ((jsonb_typeof(service_ping_settings) = 'object'::text)),
    CONSTRAINT check_application_settings_sign_in_restrictions_is_hash CHECK ((jsonb_typeof(sign_in_restrictions) = 'object'::text)),
    CONSTRAINT check_application_settings_transactional_emails_is_hash CHECK ((jsonb_typeof(transactional_emails) = 'object'::text)),
    CONSTRAINT check_b8c74ea5b3 CHECK ((char_length(deactivation_email_additional_text) <= 1000)),
    CONSTRAINT check_bf5157a366 CHECK ((char_length(required_instance_ci_template) <= 1024)),
    CONSTRAINT check_cdfbd99405 CHECK ((char_length(security_txt_content) <= 2048)),
    CONSTRAINT check_d03919528d CHECK ((char_length(container_registry_vendor) <= 255)),
    CONSTRAINT check_d820146492 CHECK ((char_length(spam_check_endpoint_url) <= 255)),
    CONSTRAINT check_e2692d7523 CHECK ((char_length(default_preferred_language) <= 32)),
    CONSTRAINT check_e2dd6e290a CHECK ((char_length(jira_connect_application_key) <= 255)),
    CONSTRAINT check_e5024c8801 CHECK ((char_length(elasticsearch_username) <= 255)),
    CONSTRAINT check_e5aba18f02 CHECK ((char_length(container_registry_version) <= 255)),
    CONSTRAINT check_ef6176834f CHECK ((char_length(encrypted_cloud_license_auth_token_iv) <= 255)),
    CONSTRAINT check_identity_verification_settings_is_hash CHECK ((jsonb_typeof(identity_verification_settings) = 'object'::text))
);

COMMENT ON COLUMN application_settings.content_validation_endpoint_url IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_content_validation_api_key IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_content_validation_api_key_iv IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.content_validation_endpoint_enabled IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.dingtalk_integration_enabled IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_dingtalk_corpid IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_dingtalk_corpid_iv IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_dingtalk_app_key IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_dingtalk_app_key_iv IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_dingtalk_app_secret IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_dingtalk_app_secret_iv IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.phone_verification_code_enabled IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.feishu_integration_enabled IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_feishu_app_key IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_feishu_app_key_iv IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_feishu_app_secret IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.encrypted_feishu_app_secret_iv IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.password_expiration_enabled IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.password_expires_in_days IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.password_expires_notice_before_days IS 'JiHu-specific column';

COMMENT ON COLUMN application_settings.disable_download_button IS 'JiHu-specific column';

CREATE SEQUENCE application_settings_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE application_settings_id_seq OWNED BY application_settings.id;

CREATE TABLE approval_group_rules (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    approvals_required smallint DEFAULT 0 NOT NULL,
    report_type smallint,
    rule_type smallint DEFAULT 1 NOT NULL,
    security_orchestration_policy_configuration_id bigint,
    scan_result_policy_id bigint,
    name text NOT NULL,
    applies_to_all_protected_branches boolean DEFAULT false NOT NULL,
    approval_policy_rule_id bigint,
    CONSTRAINT check_25d42add43 CHECK ((char_length(name) <= 255))
);

CREATE TABLE approval_group_rules_groups (
    id bigint NOT NULL,
    approval_group_rule_id bigint NOT NULL,
    group_id bigint NOT NULL
);

CREATE SEQUENCE approval_group_rules_groups_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_group_rules_groups_id_seq OWNED BY approval_group_rules_groups.id;

CREATE SEQUENCE approval_group_rules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_group_rules_id_seq OWNED BY approval_group_rules.id;

CREATE TABLE approval_group_rules_protected_branches (
    id bigint NOT NULL,
    approval_group_rule_id bigint NOT NULL,
    protected_branch_id bigint NOT NULL,
    group_id bigint
);

CREATE SEQUENCE approval_group_rules_protected_branches_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_group_rules_protected_branches_id_seq OWNED BY approval_group_rules_protected_branches.id;

CREATE TABLE approval_group_rules_users (
    id bigint NOT NULL,
    approval_group_rule_id bigint NOT NULL,
    user_id bigint NOT NULL,
    group_id bigint,
    CONSTRAINT check_6db3034f1c CHECK ((group_id IS NOT NULL))
);

CREATE SEQUENCE approval_group_rules_users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_group_rules_users_id_seq OWNED BY approval_group_rules_users.id;

CREATE TABLE approval_merge_request_rule_sources (
    id bigint NOT NULL,
    approval_merge_request_rule_id bigint NOT NULL,
    approval_project_rule_id bigint NOT NULL,
    project_id bigint
);

CREATE SEQUENCE approval_merge_request_rule_sources_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_merge_request_rule_sources_id_seq OWNED BY approval_merge_request_rule_sources.id;

CREATE TABLE approval_merge_request_rules (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    merge_request_id bigint NOT NULL,
    approvals_required smallint DEFAULT 0 NOT NULL,
    name character varying NOT NULL,
    rule_type smallint DEFAULT 1 NOT NULL,
    report_type smallint,
    section text,
    modified_from_project_rule boolean DEFAULT false NOT NULL,
    orchestration_policy_idx smallint,
    vulnerabilities_allowed smallint DEFAULT 0 NOT NULL,
    scanners text[] DEFAULT '{}'::text[] NOT NULL,
    severity_levels text[] DEFAULT '{}'::text[] NOT NULL,
    vulnerability_states text[] DEFAULT '{new_needs_triage,new_dismissed}'::text[] NOT NULL,
    security_orchestration_policy_configuration_id bigint,
    scan_result_policy_id bigint,
    applicable_post_merge boolean,
    project_id bigint,
    approval_policy_rule_id bigint,
    CONSTRAINT check_6fca5928b2 CHECK ((char_length(section) <= 255))
);

CREATE TABLE approval_merge_request_rules_approved_approvers (
    id bigint NOT NULL,
    approval_merge_request_rule_id bigint NOT NULL,
    user_id bigint NOT NULL
);

CREATE SEQUENCE approval_merge_request_rules_approved_approvers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_merge_request_rules_approved_approvers_id_seq OWNED BY approval_merge_request_rules_approved_approvers.id;

CREATE TABLE approval_merge_request_rules_groups (
    id bigint NOT NULL,
    approval_merge_request_rule_id bigint NOT NULL,
    group_id bigint NOT NULL
);

CREATE SEQUENCE approval_merge_request_rules_groups_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_merge_request_rules_groups_id_seq OWNED BY approval_merge_request_rules_groups.id;

CREATE SEQUENCE approval_merge_request_rules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_merge_request_rules_id_seq OWNED BY approval_merge_request_rules.id;

CREATE TABLE approval_merge_request_rules_users (
    id bigint NOT NULL,
    approval_merge_request_rule_id bigint NOT NULL,
    user_id bigint NOT NULL
);

CREATE SEQUENCE approval_merge_request_rules_users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_merge_request_rules_users_id_seq OWNED BY approval_merge_request_rules_users.id;

CREATE TABLE approval_policy_rule_project_links (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    approval_policy_rule_id bigint NOT NULL
);

CREATE SEQUENCE approval_policy_rule_project_links_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_policy_rule_project_links_id_seq OWNED BY approval_policy_rule_project_links.id;

CREATE TABLE approval_policy_rules (
    id bigint NOT NULL,
    security_policy_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    rule_index smallint NOT NULL,
    type smallint NOT NULL,
    content jsonb DEFAULT '{}'::jsonb NOT NULL,
    security_policy_management_project_id bigint NOT NULL
);

CREATE SEQUENCE approval_policy_rules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_policy_rules_id_seq OWNED BY approval_policy_rules.id;

CREATE TABLE approval_project_rules (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    approvals_required smallint DEFAULT 0 NOT NULL,
    name character varying NOT NULL,
    rule_type smallint DEFAULT 0 NOT NULL,
    scanners text[] DEFAULT '{}'::text[],
    vulnerabilities_allowed smallint DEFAULT 0 NOT NULL,
    severity_levels text[] DEFAULT '{}'::text[] NOT NULL,
    report_type smallint,
    vulnerability_states text[] DEFAULT '{new_needs_triage,new_dismissed}'::text[] NOT NULL,
    orchestration_policy_idx smallint,
    applies_to_all_protected_branches boolean DEFAULT false NOT NULL,
    security_orchestration_policy_configuration_id bigint,
    scan_result_policy_id bigint,
    approval_policy_rule_id bigint
);

CREATE TABLE approval_project_rules_groups (
    id bigint NOT NULL,
    approval_project_rule_id bigint NOT NULL,
    group_id bigint NOT NULL
);

CREATE SEQUENCE approval_project_rules_groups_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_project_rules_groups_id_seq OWNED BY approval_project_rules_groups.id;

CREATE SEQUENCE approval_project_rules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_project_rules_id_seq OWNED BY approval_project_rules.id;

CREATE TABLE approval_project_rules_protected_branches (
    approval_project_rule_id bigint NOT NULL,
    protected_branch_id bigint NOT NULL,
    project_id bigint
);

CREATE TABLE approval_project_rules_users (
    id bigint NOT NULL,
    approval_project_rule_id bigint NOT NULL,
    user_id bigint NOT NULL,
    project_id bigint
);

CREATE SEQUENCE approval_project_rules_users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approval_project_rules_users_id_seq OWNED BY approval_project_rules_users.id;

CREATE TABLE approvals (
    id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    patch_id_sha bytea,
    project_id bigint
);

CREATE SEQUENCE approvals_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approvals_id_seq OWNED BY approvals.id;

CREATE TABLE approver_groups (
    id bigint NOT NULL,
    target_id bigint NOT NULL,
    target_type character varying NOT NULL,
    group_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);

CREATE SEQUENCE approver_groups_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approver_groups_id_seq OWNED BY approver_groups.id;

CREATE TABLE approvers (
    id bigint NOT NULL,
    target_id bigint NOT NULL,
    target_type character varying,
    user_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);

CREATE SEQUENCE approvers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE approvers_id_seq OWNED BY approvers.id;

CREATE TABLE ar_internal_metadata (
    key character varying NOT NULL,
    value character varying,
    created_at timestamp(6) without time zone NOT NULL,
    updated_at timestamp(6) without time zone NOT NULL
);

CREATE TABLE atlassian_identities (
    user_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    expires_at timestamp with time zone,
    extern_uid text NOT NULL,
    encrypted_token bytea,
    encrypted_token_iv bytea,
    encrypted_refresh_token bytea,
    encrypted_refresh_token_iv bytea,
    CONSTRAINT atlassian_identities_refresh_token_iv_length_constraint CHECK ((octet_length(encrypted_refresh_token_iv) <= 12)),
    CONSTRAINT atlassian_identities_refresh_token_length_constraint CHECK ((octet_length(encrypted_refresh_token) <= 5000)),
    CONSTRAINT atlassian_identities_token_iv_length_constraint CHECK ((octet_length(encrypted_token_iv) <= 12)),
    CONSTRAINT atlassian_identities_token_length_constraint CHECK ((octet_length(encrypted_token) <= 5120)),
    CONSTRAINT check_32f5779763 CHECK ((char_length(extern_uid) <= 255))
);

CREATE SEQUENCE atlassian_identities_user_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE atlassian_identities_user_id_seq OWNED BY atlassian_identities.user_id;

CREATE TABLE audit_events_amazon_s3_configurations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    namespace_id bigint NOT NULL,
    access_key_xid text NOT NULL,
    name text NOT NULL,
    bucket_name text NOT NULL,
    aws_region text NOT NULL,
    encrypted_secret_access_key bytea NOT NULL,
    encrypted_secret_access_key_iv bytea NOT NULL,
    CONSTRAINT check_3a41f4ea06 CHECK ((char_length(bucket_name) <= 63)),
    CONSTRAINT check_72b5aaa71b CHECK ((char_length(aws_region) <= 50)),
    CONSTRAINT check_90505816db CHECK ((char_length(name) <= 72)),
    CONSTRAINT check_ec46f06e01 CHECK ((char_length(access_key_xid) <= 128))
);

CREATE SEQUENCE audit_events_amazon_s3_configurations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_amazon_s3_configurations_id_seq OWNED BY audit_events_amazon_s3_configurations.id;

CREATE TABLE audit_events_external_audit_event_destinations (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    destination_url text NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    verification_token text,
    name text NOT NULL,
    CONSTRAINT check_2feafb9daf CHECK ((char_length(destination_url) <= 255)),
    CONSTRAINT check_8ec80a7d06 CHECK ((char_length(verification_token) <= 24)),
    CONSTRAINT check_c52ff8e90e CHECK ((char_length(name) <= 72))
);

CREATE SEQUENCE audit_events_external_audit_event_destinations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_external_audit_event_destinations_id_seq OWNED BY audit_events_external_audit_event_destinations.id;

CREATE TABLE audit_events_google_cloud_logging_configurations (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    google_project_id_name text NOT NULL,
    client_email text NOT NULL,
    log_id_name text DEFAULT 'audit_events'::text,
    encrypted_private_key bytea NOT NULL,
    encrypted_private_key_iv bytea NOT NULL,
    name text NOT NULL,
    CONSTRAINT check_0ef835c61e CHECK ((char_length(client_email) <= 254)),
    CONSTRAINT check_55783c7c19 CHECK ((char_length(google_project_id_name) <= 30)),
    CONSTRAINT check_898a76b005 CHECK ((char_length(log_id_name) <= 511)),
    CONSTRAINT check_cdf6883cd6 CHECK ((char_length(name) <= 72))
);

CREATE SEQUENCE audit_events_google_cloud_logging_configurations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_google_cloud_logging_configurations_id_seq OWNED BY audit_events_google_cloud_logging_configurations.id;

CREATE TABLE audit_events_group_external_streaming_destinations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    group_id bigint NOT NULL,
    category smallint NOT NULL,
    name text NOT NULL,
    config jsonb NOT NULL,
    encrypted_secret_token bytea NOT NULL,
    encrypted_secret_token_iv bytea NOT NULL,
    CONSTRAINT check_97d157fbd0 CHECK ((char_length(name) <= 72))
);

CREATE SEQUENCE audit_events_group_external_streaming_destinations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_group_external_streaming_destinations_id_seq OWNED BY audit_events_group_external_streaming_destinations.id;

CREATE TABLE audit_events_group_streaming_event_type_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    external_streaming_destination_id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    audit_event_type text NOT NULL,
    CONSTRAINT check_389708af23 CHECK ((char_length(audit_event_type) <= 255))
);

CREATE SEQUENCE audit_events_group_streaming_event_type_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_group_streaming_event_type_filters_id_seq OWNED BY audit_events_group_streaming_event_type_filters.id;

CREATE SEQUENCE audit_events_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_id_seq OWNED BY audit_events.id;

CREATE TABLE audit_events_instance_amazon_s3_configurations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    access_key_xid text NOT NULL,
    name text NOT NULL,
    bucket_name text NOT NULL,
    aws_region text NOT NULL,
    encrypted_secret_access_key bytea NOT NULL,
    encrypted_secret_access_key_iv bytea NOT NULL,
    CONSTRAINT check_1a908bd36f CHECK ((char_length(name) <= 72)),
    CONSTRAINT check_8083750c42 CHECK ((char_length(bucket_name) <= 63)),
    CONSTRAINT check_d2ca3eb90e CHECK ((char_length(aws_region) <= 50)),
    CONSTRAINT check_d6d6bd8e8b CHECK ((char_length(access_key_xid) <= 128))
);

CREATE SEQUENCE audit_events_instance_amazon_s3_configurations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_instance_amazon_s3_configurations_id_seq OWNED BY audit_events_instance_amazon_s3_configurations.id;

CREATE TABLE audit_events_instance_external_audit_event_destinations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    destination_url text NOT NULL,
    encrypted_verification_token bytea NOT NULL,
    encrypted_verification_token_iv bytea NOT NULL,
    name text NOT NULL,
    CONSTRAINT check_433fbb3305 CHECK ((char_length(name) <= 72)),
    CONSTRAINT check_4dc67167ce CHECK ((char_length(destination_url) <= 255))
);

CREATE SEQUENCE audit_events_instance_external_audit_event_destinations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_instance_external_audit_event_destinations_id_seq OWNED BY audit_events_instance_external_audit_event_destinations.id;

CREATE TABLE audit_events_instance_external_streaming_destinations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    category smallint NOT NULL,
    name text NOT NULL,
    config jsonb NOT NULL,
    encrypted_secret_token bytea NOT NULL,
    encrypted_secret_token_iv bytea NOT NULL,
    CONSTRAINT check_219decfb51 CHECK ((char_length(name) <= 72))
);

CREATE SEQUENCE audit_events_instance_external_streaming_destinations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_instance_external_streaming_destinations_id_seq OWNED BY audit_events_instance_external_streaming_destinations.id;

CREATE TABLE audit_events_instance_google_cloud_logging_configurations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    google_project_id_name text NOT NULL,
    client_email text NOT NULL,
    log_id_name text DEFAULT 'audit_events'::text,
    name text NOT NULL,
    encrypted_private_key bytea NOT NULL,
    encrypted_private_key_iv bytea NOT NULL,
    CONSTRAINT check_0da5c76c49 CHECK ((char_length(client_email) <= 254)),
    CONSTRAINT check_74fd943192 CHECK ((char_length(log_id_name) <= 511)),
    CONSTRAINT check_ab65f57721 CHECK ((char_length(google_project_id_name) <= 30)),
    CONSTRAINT check_ac42ad3ca2 CHECK ((char_length(name) <= 72))
);

CREATE SEQUENCE audit_events_instance_google_cloud_logging_configuration_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_instance_google_cloud_logging_configuration_id_seq OWNED BY audit_events_instance_google_cloud_logging_configurations.id;

CREATE TABLE audit_events_instance_streaming_event_type_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    external_streaming_destination_id bigint NOT NULL,
    audit_event_type text NOT NULL,
    CONSTRAINT check_4a5e8e01b5 CHECK ((char_length(audit_event_type) <= 255))
);

CREATE SEQUENCE audit_events_instance_streaming_event_type_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_instance_streaming_event_type_filters_id_seq OWNED BY audit_events_instance_streaming_event_type_filters.id;

CREATE TABLE audit_events_streaming_event_type_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    external_audit_event_destination_id bigint NOT NULL,
    audit_event_type text NOT NULL,
    group_id bigint,
    CONSTRAINT check_d20c8e5a51 CHECK ((char_length(audit_event_type) <= 255))
);

CREATE SEQUENCE audit_events_streaming_event_type_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_streaming_event_type_filters_id_seq OWNED BY audit_events_streaming_event_type_filters.id;

CREATE TABLE audit_events_streaming_group_namespace_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    external_streaming_destination_id bigint NOT NULL,
    namespace_id bigint NOT NULL
);

CREATE SEQUENCE audit_events_streaming_group_namespace_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_streaming_group_namespace_filters_id_seq OWNED BY audit_events_streaming_group_namespace_filters.id;

CREATE TABLE audit_events_streaming_headers (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    external_audit_event_destination_id bigint NOT NULL,
    key text NOT NULL,
    value text NOT NULL,
    active boolean DEFAULT true NOT NULL,
    group_id bigint,
    CONSTRAINT check_53c3152034 CHECK ((char_length(key) <= 255)),
    CONSTRAINT check_ac213cca22 CHECK ((char_length(value) <= 255))
);

CREATE SEQUENCE audit_events_streaming_headers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_streaming_headers_id_seq OWNED BY audit_events_streaming_headers.id;

CREATE TABLE audit_events_streaming_http_group_namespace_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    external_audit_event_destination_id bigint NOT NULL,
    namespace_id bigint NOT NULL
);

CREATE SEQUENCE audit_events_streaming_http_group_namespace_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_streaming_http_group_namespace_filters_id_seq OWNED BY audit_events_streaming_http_group_namespace_filters.id;

CREATE TABLE audit_events_streaming_http_instance_namespace_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    audit_events_instance_external_audit_event_destination_id bigint NOT NULL,
    namespace_id bigint NOT NULL
);

CREATE SEQUENCE audit_events_streaming_http_instance_namespace_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_streaming_http_instance_namespace_filters_id_seq OWNED BY audit_events_streaming_http_instance_namespace_filters.id;

CREATE TABLE audit_events_streaming_instance_event_type_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    instance_external_audit_event_destination_id bigint NOT NULL,
    audit_event_type text NOT NULL,
    CONSTRAINT check_249c9370cc CHECK ((char_length(audit_event_type) <= 255))
);

CREATE SEQUENCE audit_events_streaming_instance_event_type_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_streaming_instance_event_type_filters_id_seq OWNED BY audit_events_streaming_instance_event_type_filters.id;

CREATE TABLE audit_events_streaming_instance_namespace_filters (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    external_streaming_destination_id bigint NOT NULL,
    namespace_id bigint NOT NULL
);

CREATE SEQUENCE audit_events_streaming_instance_namespace_filters_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE audit_events_streaming_instance_namespace_filters_id_seq OWNED BY audit_events_streaming_instance_namespace_filters.id;

CREATE TABLE authentication_events (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    user_id bigint,
    result smallint NOT NULL,
    ip_address inet,
    provider text NOT NULL,
    user_name text NOT NULL,
    CONSTRAINT check_45a6cc4e80 CHECK ((char_length(user_name) <= 255)),
    CONSTRAINT check_c64f424630 CHECK ((char_length(provider) <= 64))
);

CREATE SEQUENCE authentication_events_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE authentication_events_id_seq OWNED BY authentication_events.id;

CREATE TABLE automation_rules (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    issues_events boolean DEFAULT false NOT NULL,
    merge_requests_events boolean DEFAULT false NOT NULL,
    permanently_disabled boolean DEFAULT false NOT NULL,
    name text NOT NULL,
    rule text NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    CONSTRAINT check_0be3e2c953 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_ed5a4fcbd5 CHECK ((char_length(rule) <= 2048))
);

CREATE SEQUENCE automation_rules_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE automation_rules_id_seq OWNED BY automation_rules.id;

CREATE TABLE award_emoji (
    id bigint NOT NULL,
    name character varying,
    user_id bigint,
    awardable_type character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    awardable_id bigint
);

CREATE SEQUENCE award_emoji_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE award_emoji_id_seq OWNED BY award_emoji.id;

CREATE TABLE aws_roles (
    user_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    role_arn character varying(2048),
    role_external_id character varying(64) NOT NULL,
    region text,
    CONSTRAINT check_57adedab55 CHECK ((char_length(region) <= 255))
);

CREATE TABLE background_migration_jobs (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    class_name text NOT NULL,
    arguments jsonb NOT NULL,
    CONSTRAINT check_b0de0a5852 CHECK ((char_length(class_name) <= 200))
);

CREATE SEQUENCE background_migration_jobs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE background_migration_jobs_id_seq OWNED BY background_migration_jobs.id;

CREATE TABLE badges (
    id bigint NOT NULL,
    link_url character varying NOT NULL,
    image_url character varying NOT NULL,
    project_id bigint,
    group_id bigint,
    type character varying NOT NULL,
    name character varying(255),
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

CREATE SEQUENCE badges_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE badges_id_seq OWNED BY badges.id;

CREATE TABLE banned_users (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    user_id bigint NOT NULL
);

CREATE SEQUENCE batched_background_migration_job_transition_logs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE batched_background_migration_job_transition_logs_id_seq OWNED BY batched_background_migration_job_transition_logs.id;

CREATE TABLE batched_background_migration_jobs (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    started_at timestamp with time zone,
    finished_at timestamp with time zone,
    batched_background_migration_id bigint NOT NULL,
    min_value bigint,
    max_value bigint,
    batch_size integer NOT NULL,
    sub_batch_size integer NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    attempts smallint DEFAULT 0 NOT NULL,
    metrics jsonb DEFAULT '{}'::jsonb NOT NULL,
    pause_ms integer DEFAULT 100 NOT NULL,
    min_cursor jsonb,
    max_cursor jsonb,
    CONSTRAINT check_18d498ea58 CHECK (((jsonb_typeof(min_cursor) = 'array'::text) AND (jsonb_typeof(max_cursor) = 'array'::text))),
    CONSTRAINT check_c1ce96fe3b CHECK (((num_nonnulls(min_value, max_value) = 2) OR (num_nonnulls(min_cursor, max_cursor) = 2)))
);

CREATE SEQUENCE batched_background_migration_jobs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE batched_background_migration_jobs_id_seq OWNED BY batched_background_migration_jobs.id;

CREATE TABLE batched_background_migrations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    min_value bigint DEFAULT 1,
    max_value bigint,
    batch_size integer NOT NULL,
    sub_batch_size integer NOT NULL,
    "interval" smallint NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    job_class_name text NOT NULL,
    batch_class_name text DEFAULT 'PrimaryKeyBatchingStrategy'::text NOT NULL,
    table_name text NOT NULL,
    column_name text NOT NULL,
    job_arguments jsonb DEFAULT '[]'::jsonb NOT NULL,
    total_tuple_count bigint,
    pause_ms integer DEFAULT 100 NOT NULL,
    max_batch_size integer,
    started_at timestamp with time zone,
    on_hold_until timestamp with time zone,
    gitlab_schema text NOT NULL,
    finished_at timestamp with time zone,
    queued_migration_version text,
    min_cursor jsonb,
    max_cursor jsonb,
    CONSTRAINT check_0406d9776f CHECK ((char_length(gitlab_schema) <= 255)),
    CONSTRAINT check_122750e705 CHECK (((jsonb_typeof(min_cursor) = 'array'::text) AND (jsonb_typeof(max_cursor) = 'array'::text))),
    CONSTRAINT check_5bb0382d6f CHECK ((char_length(column_name) <= 63)),
    CONSTRAINT check_6b6a06254a CHECK ((char_length(table_name) <= 63)),
    CONSTRAINT check_713f147aea CHECK ((char_length(queued_migration_version) <= 14)),
    CONSTRAINT check_batch_size_in_range CHECK ((batch_size >= sub_batch_size)),
    CONSTRAINT check_e6c75b1e29 CHECK ((char_length(job_class_name) <= 100)),
    CONSTRAINT check_f5158baa12 CHECK (((num_nonnulls(min_value, max_value) = 2) OR (num_nonnulls(min_cursor, max_cursor) = 2))),
    CONSTRAINT check_fe10674721 CHECK ((char_length(batch_class_name) <= 100)),
    CONSTRAINT check_max_value_in_range CHECK ((max_value >= min_value)),
    CONSTRAINT check_positive_min_value CHECK ((min_value > 0)),
    CONSTRAINT check_positive_sub_batch_size CHECK ((sub_batch_size > 0))
);

COMMENT ON COLUMN batched_background_migrations.on_hold_until IS 'execution of this migration is on hold until this time';

CREATE SEQUENCE batched_background_migrations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE batched_background_migrations_id_seq OWNED BY batched_background_migrations.id;

CREATE TABLE board_assignees (
    id bigint NOT NULL,
    board_id bigint NOT NULL,
    assignee_id bigint NOT NULL
);

CREATE SEQUENCE board_assignees_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE board_assignees_id_seq OWNED BY board_assignees.id;

CREATE TABLE board_group_recent_visits (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    user_id bigint,
    board_id bigint,
    group_id bigint,
    CONSTRAINT check_409f6caea4 CHECK ((user_id IS NOT NULL)),
    CONSTRAINT check_ddc74243ef CHECK ((group_id IS NOT NULL)),
    CONSTRAINT check_fa7711a898 CHECK ((board_id IS NOT NULL))
);

CREATE SEQUENCE board_group_recent_visits_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE board_group_recent_visits_id_seq OWNED BY board_group_recent_visits.id;

CREATE TABLE board_labels (
    id bigint NOT NULL,
    board_id bigint NOT NULL,
    label_id bigint NOT NULL
);

CREATE SEQUENCE board_labels_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE board_labels_id_seq OWNED BY board_labels.id;

CREATE TABLE board_project_recent_visits (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    user_id bigint,
    project_id bigint,
    board_id bigint,
    CONSTRAINT check_0386e26981 CHECK ((board_id IS NOT NULL)),
    CONSTRAINT check_d9cc9b79da CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_df7762a99a CHECK ((user_id IS NOT NULL))
);

CREATE SEQUENCE board_project_recent_visits_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE board_project_recent_visits_id_seq OWNED BY board_project_recent_visits.id;

CREATE TABLE board_user_preferences (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    board_id bigint NOT NULL,
    hide_labels boolean,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

CREATE SEQUENCE board_user_preferences_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE board_user_preferences_id_seq OWNED BY board_user_preferences.id;

CREATE TABLE boards (
    id bigint NOT NULL,
    project_id bigint,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    name character varying DEFAULT 'Development'::character varying NOT NULL,
    milestone_id bigint,
    group_id bigint,
    weight integer,
    hide_backlog_list boolean DEFAULT false NOT NULL,
    hide_closed_list boolean DEFAULT false NOT NULL,
    iteration_id bigint,
    iteration_cadence_id bigint
);

CREATE TABLE boards_epic_board_labels (
    id bigint NOT NULL,
    epic_board_id bigint NOT NULL,
    label_id bigint NOT NULL,
    group_id bigint
);

CREATE SEQUENCE boards_epic_board_labels_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE boards_epic_board_labels_id_seq OWNED BY boards_epic_board_labels.id;

CREATE TABLE boards_epic_board_positions (
    id bigint NOT NULL,
    epic_board_id bigint NOT NULL,
    epic_id bigint NOT NULL,
    relative_position integer,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    group_id bigint
);

CREATE SEQUENCE boards_epic_board_positions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE boards_epic_board_positions_id_seq OWNED BY boards_epic_board_positions.id;

CREATE TABLE boards_epic_board_recent_visits (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    epic_board_id bigint NOT NULL,
    group_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

CREATE SEQUENCE boards_epic_board_recent_visits_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE boards_epic_board_recent_visits_id_seq OWNED BY boards_epic_board_recent_visits.id;

CREATE TABLE boards_epic_boards (
    id bigint NOT NULL,
    hide_backlog_list boolean DEFAULT false NOT NULL,
    hide_closed_list boolean DEFAULT false NOT NULL,
    group_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    name text DEFAULT 'Development'::text NOT NULL,
    display_colors boolean DEFAULT true NOT NULL,
    CONSTRAINT check_bcbbffe601 CHECK ((char_length(name) <= 255))
);

CREATE SEQUENCE boards_epic_boards_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE boards_epic_boards_id_seq OWNED BY boards_epic_boards.id;

CREATE TABLE boards_epic_list_user_preferences (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    epic_list_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    collapsed boolean DEFAULT false NOT NULL
);

CREATE SEQUENCE boards_epic_list_user_preferences_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE boards_epic_list_user_preferences_id_seq OWNED BY boards_epic_list_user_preferences.id;

CREATE TABLE boards_epic_lists (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    epic_board_id bigint NOT NULL,
    label_id bigint,
    "position" integer,
    list_type smallint DEFAULT 1 NOT NULL,
    group_id bigint,
    CONSTRAINT boards_epic_lists_position_constraint CHECK (((list_type <> 1) OR (("position" IS NOT NULL) AND ("position" >= 0))))
);

CREATE SEQUENCE boards_epic_lists_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

ALTER SEQUENCE boards_epic_lists_id_seq OWNED BY boards_epic_lists.id;

