CREATE TABLE boards_epic_user_preferences (
    id bigint NOT NULL,
    board_id bigint NOT NULL,
    user_id bigint NOT NULL,
    epic_id bigint NOT NULL,
    collapsed boolean DEFAULT false NOT NULL,
    group_id bigint
);

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

ALTER SEQUENCE boards_epic_user_preferences_id_seq OWNED BY boards_epic_user_preferences.id;

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

ALTER SEQUENCE boards_id_seq OWNED BY boards.id;

CREATE TABLE broadcast_messages (
    id bigint NOT NULL,
    message text NOT NULL,
    starts_at timestamp without time zone NOT NULL,
    ends_at timestamp without time zone NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    color character varying,
    font character varying,
    message_html text NOT NULL,
    cached_markdown_version integer,
    target_path character varying(255),
    broadcast_type smallint DEFAULT 1 NOT NULL,
    dismissable boolean,
    target_access_levels integer[] DEFAULT '{}'::integer[] NOT NULL,
    theme smallint DEFAULT 0 NOT NULL,
    show_in_cli boolean DEFAULT true NOT NULL
);

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

ALTER SEQUENCE broadcast_messages_id_seq OWNED BY broadcast_messages.id;

CREATE TABLE bulk_import_batch_trackers (
    id bigint NOT NULL,
    tracker_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,
    batch_number integer DEFAULT 0 NOT NULL,
    fetched_objects_count integer DEFAULT 0 NOT NULL,
    imported_objects_count integer DEFAULT 0 NOT NULL,
    error text,
    CONSTRAINT check_3d6963a51f CHECK ((char_length(error) <= 255))
);

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

ALTER SEQUENCE bulk_import_batch_trackers_id_seq OWNED BY bulk_import_batch_trackers.id;

CREATE TABLE bulk_import_configurations (
    id bigint NOT NULL,
    bulk_import_id bigint NOT NULL,
    encrypted_url text,
    encrypted_url_iv text,
    encrypted_access_token text,
    encrypted_access_token_iv text,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    migrate_memberships boolean DEFAULT true NOT NULL
);

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

ALTER SEQUENCE bulk_import_configurations_id_seq OWNED BY bulk_import_configurations.id;

CREATE TABLE bulk_import_entities (
    id bigint NOT NULL,
    bulk_import_id bigint NOT NULL,
    parent_id bigint,
    namespace_id bigint,
    project_id bigint,
    source_type smallint NOT NULL,
    source_full_path text NOT NULL,
    destination_name text NOT NULL,
    destination_namespace text NOT NULL,
    status smallint NOT NULL,
    jid text,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    source_xid integer,
    migrate_projects boolean DEFAULT true NOT NULL,
    has_failures boolean DEFAULT false,
    migrate_memberships boolean DEFAULT true NOT NULL,
    CONSTRAINT check_13f279f7da CHECK ((char_length(source_full_path) <= 255)),
    CONSTRAINT check_715d725ea2 CHECK ((char_length(destination_name) <= 255)),
    CONSTRAINT check_796a4d9cc6 CHECK ((char_length(jid) <= 255)),
    CONSTRAINT check_b834fff4d9 CHECK ((char_length(destination_namespace) <= 255))
);

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

ALTER SEQUENCE bulk_import_entities_id_seq OWNED BY bulk_import_entities.id;

CREATE TABLE bulk_import_export_batches (
    id bigint NOT NULL,
    export_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,
    batch_number integer DEFAULT 0 NOT NULL,
    objects_count integer DEFAULT 0 NOT NULL,
    error text,
    CONSTRAINT check_046dc60dfe CHECK ((char_length(error) <= 255))
);

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

ALTER SEQUENCE bulk_import_export_batches_id_seq OWNED BY bulk_import_export_batches.id;

CREATE TABLE bulk_import_export_uploads (
    id bigint NOT NULL,
    export_id bigint NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    export_file text,
    batch_id bigint,
    CONSTRAINT check_5add76239d CHECK ((char_length(export_file) <= 255))
);

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

ALTER SEQUENCE bulk_import_export_uploads_id_seq OWNED BY bulk_import_export_uploads.id;

CREATE TABLE bulk_import_exports (
    id bigint NOT NULL,
    group_id bigint,
    project_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    relation text NOT NULL,
    jid text,
    error text,
    batched boolean DEFAULT false NOT NULL,
    batches_count integer DEFAULT 0 NOT NULL,
    total_objects_count integer DEFAULT 0 NOT NULL,
    user_id bigint,
    CONSTRAINT check_24cb010672 CHECK ((char_length(relation) <= 255)),
    CONSTRAINT check_8f0f357334 CHECK ((char_length(error) <= 255)),
    CONSTRAINT check_9ee6d14d33 CHECK ((char_length(jid) <= 255)),
    CONSTRAINT check_e84b7c0730 CHECK ((num_nonnulls(group_id, project_id) = 1))
);

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

ALTER SEQUENCE bulk_import_exports_id_seq OWNED BY bulk_import_exports.id;

CREATE TABLE bulk_import_failures (
    id bigint NOT NULL,
    bulk_import_entity_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    pipeline_class text NOT NULL,
    exception_class text NOT NULL,
    exception_message text NOT NULL,
    correlation_id_value text,
    pipeline_step text,
    source_url text,
    source_title text,
    subrelation text,
    CONSTRAINT check_053d65c7a4 CHECK ((char_length(pipeline_class) <= 255)),
    CONSTRAINT check_6eca8f972e CHECK ((char_length(exception_message) <= 255)),
    CONSTRAINT check_721a422375 CHECK ((char_length(pipeline_step) <= 255)),
    CONSTRAINT check_74414228d4 CHECK ((char_length(source_title) <= 255)),
    CONSTRAINT check_c7dba8398e CHECK ((char_length(exception_class) <= 255)),
    CONSTRAINT check_e035a720ad CHECK ((char_length(source_url) <= 255)),
    CONSTRAINT check_e787285882 CHECK ((char_length(correlation_id_value) <= 255)),
    CONSTRAINT check_f99665a440 CHECK ((char_length(subrelation) <= 255))
);

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

ALTER SEQUENCE bulk_import_failures_id_seq OWNED BY bulk_import_failures.id;

CREATE TABLE bulk_import_trackers (
    id bigint NOT NULL,
    bulk_import_entity_id bigint NOT NULL,
    relation text NOT NULL,
    next_page text,
    has_next_page boolean DEFAULT false NOT NULL,
    jid text,
    stage smallint DEFAULT 0 NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    batched boolean DEFAULT false,
    source_objects_count bigint DEFAULT 0 NOT NULL,
    fetched_objects_count bigint DEFAULT 0 NOT NULL,
    imported_objects_count bigint DEFAULT 0 NOT NULL,
    CONSTRAINT check_2d45cae629 CHECK ((char_length(relation) <= 255)),
    CONSTRAINT check_40aeaa600b CHECK ((char_length(next_page) <= 255)),
    CONSTRAINT check_603f91cb06 CHECK ((char_length(jid) <= 255)),
    CONSTRAINT check_next_page_requirement CHECK (((has_next_page IS FALSE) OR (next_page IS NOT NULL)))
);

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

ALTER SEQUENCE bulk_import_trackers_id_seq OWNED BY bulk_import_trackers.id;

CREATE TABLE bulk_imports (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    source_type smallint NOT NULL,
    status smallint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    source_version text,
    source_enterprise boolean DEFAULT true NOT NULL,
    has_failures boolean DEFAULT false,
    CONSTRAINT check_ea4e58775a CHECK ((char_length(source_version) <= 63))
);

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

ALTER SEQUENCE bulk_imports_id_seq OWNED BY bulk_imports.id;

CREATE TABLE catalog_resource_component_last_usages (
    id bigint NOT NULL,
    component_id bigint NOT NULL,
    catalog_resource_id bigint NOT NULL,
    component_project_id bigint NOT NULL,
    used_by_project_id bigint NOT NULL,
    last_used_date date NOT NULL
);

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

ALTER SEQUENCE catalog_resource_component_last_usages_id_seq OWNED BY catalog_resource_component_last_usages.id;

CREATE TABLE catalog_resource_components (
    id bigint NOT NULL,
    catalog_resource_id bigint NOT NULL,
    version_id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    name text NOT NULL,
    spec jsonb DEFAULT '{}'::jsonb NOT NULL,
    last_30_day_usage_count integer DEFAULT 0 NOT NULL,
    last_30_day_usage_count_updated_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
    component_type smallint DEFAULT 1,
    CONSTRAINT check_47c5537132 CHECK ((component_type IS NOT NULL)),
    CONSTRAINT check_ddca729980 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE catalog_resource_components_id_seq OWNED BY catalog_resource_components.id;

CREATE TABLE catalog_resource_versions (
    id bigint NOT NULL,
    release_id bigint NOT NULL,
    catalog_resource_id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    released_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
    semver_major integer,
    semver_minor integer,
    semver_patch integer,
    semver_prerelease text,
    semver_prefixed boolean DEFAULT false,
    cached_markdown_version integer,
    readme text,
    readme_html text,
    published_by_id bigint,
    CONSTRAINT check_701bdce47b CHECK ((char_length(semver_prerelease) <= 255))
);

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

ALTER SEQUENCE catalog_resource_versions_id_seq OWNED BY catalog_resource_versions.id;

CREATE TABLE catalog_resources (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    state smallint DEFAULT 0 NOT NULL,
    latest_released_at timestamp with time zone,
    name character varying,
    description text,
    visibility_level integer DEFAULT 0 NOT NULL,
    search_vector tsvector GENERATED ALWAYS AS ((setweight(to_tsvector('english'::regconfig, (COALESCE(name, ''::character varying))::text), 'A'::"char") || setweight(to_tsvector('english'::regconfig, COALESCE(description, ''::text)), 'B'::"char"))) STORED,
    verification_level smallint DEFAULT 0,
    last_30_day_usage_count integer DEFAULT 0 NOT NULL,
    last_30_day_usage_count_updated_at timestamp with time zone DEFAULT now() NOT NULL
);

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

ALTER SEQUENCE catalog_resources_id_seq OWNED BY catalog_resources.id;

CREATE TABLE catalog_verified_namespaces (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    verification_level smallint DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE catalog_verified_namespaces_id_seq OWNED BY catalog_verified_namespaces.id;

CREATE TABLE chat_names (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    team_id character varying NOT NULL,
    team_domain character varying,
    chat_id character varying NOT NULL,
    chat_name character varying,
    last_used_at timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    encrypted_token bytea,
    encrypted_token_iv bytea
);

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

ALTER SEQUENCE chat_names_id_seq OWNED BY chat_names.id;

CREATE TABLE chat_teams (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    team_id character varying,
    name character varying,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE chat_teams_id_seq OWNED BY chat_teams.id;

CREATE TABLE ci_build_needs (
    name text NOT NULL,
    artifacts boolean DEFAULT true NOT NULL,
    optional boolean DEFAULT false NOT NULL,
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE ci_build_needs_id_seq OWNED BY ci_build_needs.id;

CREATE TABLE ci_build_pending_states (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    build_id bigint NOT NULL,
    state smallint,
    failure_reason smallint,
    trace_checksum bytea,
    trace_bytesize bigint,
    partition_id bigint NOT NULL
);

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

ALTER SEQUENCE ci_build_pending_states_id_seq OWNED BY ci_build_pending_states.id;

CREATE TABLE ci_build_report_results (
    build_id bigint NOT NULL,
    project_id bigint NOT NULL,
    data jsonb DEFAULT '{}'::jsonb NOT NULL,
    partition_id bigint NOT NULL
);

CREATE TABLE ci_build_trace_chunks (
    id bigint NOT NULL,
    chunk_index integer NOT NULL,
    data_store integer NOT NULL,
    raw_data bytea,
    checksum bytea,
    lock_version integer DEFAULT 0 NOT NULL,
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL
);

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

ALTER SEQUENCE ci_build_trace_chunks_id_seq OWNED BY ci_build_trace_chunks.id;

CREATE TABLE 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))
);

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

ALTER SEQUENCE ci_builds_id_seq OWNED BY p_ci_builds.id;

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

ALTER SEQUENCE ci_builds_metadata_id_seq OWNED BY p_ci_builds_metadata.id;

CREATE TABLE 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 DEFAULT nextval('ci_builds_metadata_id_seq'::regclass) 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
);

CREATE TABLE ci_builds_runner_session (
    id bigint NOT NULL,
    url character varying NOT NULL,
    certificate character varying,
    "authorization" character varying,
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE ci_builds_runner_session_id_seq OWNED BY ci_builds_runner_session.id;

CREATE TABLE ci_cost_settings (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    runner_id bigint NOT NULL,
    standard_factor double precision DEFAULT 1.0 NOT NULL,
    os_contribution_factor double precision DEFAULT 0.008 NOT NULL,
    os_plan_factor double precision DEFAULT 0.5 NOT NULL
);

CREATE TABLE ci_daily_build_group_report_results (
    id bigint NOT NULL,
    date date NOT NULL,
    project_id bigint NOT NULL,
    last_pipeline_id bigint NOT NULL,
    ref_path text NOT NULL,
    group_name text NOT NULL,
    data jsonb NOT NULL,
    default_branch boolean DEFAULT false NOT NULL,
    group_id bigint,
    partition_id bigint NOT NULL
);

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

ALTER SEQUENCE ci_daily_build_group_report_results_id_seq OWNED BY ci_daily_build_group_report_results.id;

CREATE TABLE ci_deleted_objects (
    id bigint NOT NULL,
    file_store smallint DEFAULT 1 NOT NULL,
    pick_up_at timestamp with time zone DEFAULT now() NOT NULL,
    store_dir text NOT NULL,
    file text NOT NULL,
    project_id bigint,
    CONSTRAINT check_5e151d6912 CHECK ((char_length(store_dir) <= 1024)),
    CONSTRAINT check_98f90d6c53 CHECK ((project_id IS NOT NULL))
);

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

ALTER SEQUENCE ci_deleted_objects_id_seq OWNED BY ci_deleted_objects.id;

CREATE TABLE ci_freeze_periods (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    freeze_start character varying(998) NOT NULL,
    freeze_end character varying(998) NOT NULL,
    cron_timezone character varying(255) NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE ci_freeze_periods_id_seq OWNED BY ci_freeze_periods.id;

CREATE TABLE ci_group_variables (
    id bigint NOT NULL,
    key character varying NOT NULL,
    value text,
    encrypted_value text,
    encrypted_value_salt character varying,
    encrypted_value_iv character varying,
    group_id bigint NOT NULL,
    protected boolean DEFAULT false NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    masked boolean DEFAULT false NOT NULL,
    variable_type smallint DEFAULT 1 NOT NULL,
    environment_scope text DEFAULT '*'::text NOT NULL,
    raw boolean DEFAULT false NOT NULL,
    description text,
    hidden boolean DEFAULT false NOT NULL,
    CONSTRAINT check_dfe009485a CHECK ((char_length(environment_scope) <= 255)),
    CONSTRAINT check_e2e50ff879 CHECK ((char_length(description) <= 255))
);

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

ALTER SEQUENCE ci_group_variables_id_seq OWNED BY ci_group_variables.id;

CREATE TABLE ci_instance_variables (
    id bigint NOT NULL,
    variable_type smallint DEFAULT 1 NOT NULL,
    masked boolean DEFAULT false,
    protected boolean DEFAULT false,
    key text NOT NULL,
    encrypted_value text,
    encrypted_value_iv text,
    raw boolean DEFAULT false NOT NULL,
    description text,
    CONSTRAINT check_07a45a5bcb CHECK ((char_length(encrypted_value_iv) <= 255)),
    CONSTRAINT check_5aede12208 CHECK ((char_length(key) <= 255)),
    CONSTRAINT check_956afd70f1 CHECK ((char_length(encrypted_value) <= 13579)),
    CONSTRAINT check_a0a9762afa CHECK ((char_length(description) <= 255))
);

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

ALTER SEQUENCE ci_instance_variables_id_seq OWNED BY ci_instance_variables.id;

CREATE TABLE ci_job_artifact_states (
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    job_artifact_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint,
    verification_checksum bytea,
    verification_failure text,
    partition_id bigint NOT NULL,
    project_id bigint,
    CONSTRAINT check_df832b66ea CHECK ((char_length(verification_failure) <= 255))
);

CREATE TABLE 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))
);

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

ALTER SEQUENCE ci_job_artifacts_id_seq OWNED BY p_ci_job_artifacts.id;

CREATE TABLE ci_job_token_authorizations (
    id bigint NOT NULL,
    accessed_project_id bigint NOT NULL,
    origin_project_id bigint NOT NULL,
    last_authorized_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE ci_job_token_authorizations_id_seq OWNED BY ci_job_token_authorizations.id;

CREATE TABLE ci_job_token_group_scope_links (
    id bigint NOT NULL,
    source_project_id bigint NOT NULL,
    target_group_id bigint NOT NULL,
    added_by_id bigint,
    created_at timestamp with time zone NOT NULL,
    job_token_policies jsonb DEFAULT '[]'::jsonb
);

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

ALTER SEQUENCE ci_job_token_group_scope_links_id_seq OWNED BY ci_job_token_group_scope_links.id;

CREATE TABLE ci_job_token_project_scope_links (
    id bigint NOT NULL,
    source_project_id bigint NOT NULL,
    target_project_id bigint NOT NULL,
    added_by_id bigint,
    created_at timestamp with time zone NOT NULL,
    direction smallint DEFAULT 0 NOT NULL,
    job_token_policies jsonb DEFAULT '[]'::jsonb
);

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

ALTER SEQUENCE ci_job_token_project_scope_links_id_seq OWNED BY ci_job_token_project_scope_links.id;

CREATE TABLE ci_job_variables (
    id bigint NOT NULL,
    key character varying NOT NULL,
    encrypted_value text,
    encrypted_value_iv character varying,
    job_id bigint NOT NULL,
    variable_type smallint DEFAULT 1 NOT NULL,
    source smallint DEFAULT 0 NOT NULL,
    raw boolean DEFAULT false NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint,
    CONSTRAINT check_567d1ccb72 CHECK ((project_id IS NOT NULL))
);

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

ALTER SEQUENCE ci_job_variables_id_seq OWNED BY ci_job_variables.id;

CREATE TABLE ci_minutes_additional_packs (
    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,
    expires_at date,
    number_of_minutes integer NOT NULL,
    purchase_xid text,
    CONSTRAINT check_d7ef254af0 CHECK ((char_length(purchase_xid) <= 50))
);

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

ALTER SEQUENCE ci_minutes_additional_packs_id_seq OWNED BY ci_minutes_additional_packs.id;

CREATE TABLE ci_namespace_mirrors (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    traversal_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL
);

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

ALTER SEQUENCE ci_namespace_mirrors_id_seq OWNED BY ci_namespace_mirrors.id;

CREATE TABLE ci_namespace_monthly_usages (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    date date NOT NULL,
    notification_level smallint DEFAULT 100 NOT NULL,
    created_at timestamp with time zone,
    amount_used numeric(18,4) DEFAULT 0.0 NOT NULL,
    shared_runners_duration bigint DEFAULT 0 NOT NULL,
    CONSTRAINT ci_namespace_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone)))
);

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

ALTER SEQUENCE ci_namespace_monthly_usages_id_seq OWNED BY ci_namespace_monthly_usages.id;

CREATE TABLE ci_partitions (
    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
);

CREATE TABLE ci_pending_builds (
    id bigint NOT NULL,
    build_id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    protected boolean DEFAULT false NOT NULL,
    instance_runners_enabled boolean DEFAULT false NOT NULL,
    namespace_id bigint,
    minutes_exceeded boolean DEFAULT false NOT NULL,
    tag_ids bigint[] DEFAULT '{}'::bigint[],
    namespace_traversal_ids bigint[] DEFAULT '{}'::bigint[],
    partition_id bigint NOT NULL,
    plan_id bigint
);

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

ALTER SEQUENCE ci_pending_builds_id_seq OWNED BY ci_pending_builds.id;

CREATE TABLE ci_pipeline_artifacts (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    pipeline_id bigint NOT NULL,
    project_id bigint NOT NULL,
    size integer NOT NULL,
    file_store smallint DEFAULT 1 NOT NULL,
    file_type smallint NOT NULL,
    file_format smallint NOT NULL,
    file text,
    expire_at timestamp with time zone,
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint,
    verification_checksum bytea,
    verification_failure text,
    locked smallint DEFAULT 2,
    partition_id bigint NOT NULL,
    CONSTRAINT check_191b5850ec CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_abeeb71caf CHECK ((file IS NOT NULL)),
    CONSTRAINT ci_pipeline_artifacts_verification_failure_text_limit CHECK ((char_length(verification_failure) <= 255))
);

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

ALTER SEQUENCE ci_pipeline_artifacts_id_seq OWNED BY ci_pipeline_artifacts.id;

CREATE TABLE ci_pipeline_chat_data (
    id bigint NOT NULL,
    chat_name_id bigint NOT NULL,
    response_url text NOT NULL,
    pipeline_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint,
    CONSTRAINT check_f6412eda6f CHECK ((project_id IS NOT NULL))
);

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

ALTER SEQUENCE ci_pipeline_chat_data_id_seq OWNED BY ci_pipeline_chat_data.id;

CREATE TABLE ci_pipeline_messages (
    id bigint NOT NULL,
    severity smallint DEFAULT 0 NOT NULL,
    content text NOT NULL,
    pipeline_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint,
    CONSTRAINT check_58ca2981b2 CHECK ((char_length(content) <= 10000))
);

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

ALTER SEQUENCE ci_pipeline_messages_id_seq OWNED BY ci_pipeline_messages.id;

CREATE TABLE ci_pipeline_metadata (
    project_id bigint NOT NULL,
    pipeline_id bigint NOT NULL,
    name text,
    auto_cancel_on_new_commit smallint DEFAULT 0 NOT NULL,
    auto_cancel_on_job_failure smallint DEFAULT 0 NOT NULL,
    partition_id bigint NOT NULL,
    CONSTRAINT check_9d3665463c CHECK ((char_length(name) <= 255))
);

CREATE TABLE ci_pipeline_schedule_variables (
    id bigint NOT NULL,
    key character varying NOT NULL,
    value text,
    encrypted_value text,
    encrypted_value_salt character varying,
    encrypted_value_iv character varying,
    pipeline_schedule_id bigint NOT NULL,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    variable_type smallint DEFAULT 1 NOT NULL,
    raw boolean DEFAULT false NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE ci_pipeline_schedule_variables_id_seq OWNED BY ci_pipeline_schedule_variables.id;

CREATE TABLE ci_pipeline_schedules (
    id bigint NOT NULL,
    description character varying,
    ref character varying,
    cron character varying,
    cron_timezone character varying,
    next_run_at timestamp without time zone,
    project_id bigint,
    owner_id bigint,
    active boolean DEFAULT true,
    created_at timestamp without time zone,
    updated_at timestamp without time zone
);

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

ALTER SEQUENCE ci_pipeline_schedules_id_seq OWNED BY ci_pipeline_schedules.id;

CREATE TABLE 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
);

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

ALTER SEQUENCE ci_pipeline_variables_id_seq OWNED BY p_ci_pipeline_variables.id;

CREATE TABLE p_ci_pipelines (
    ref character varying,
    sha character varying,
    before_sha character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    tag boolean DEFAULT false,
    yaml_errors text,
    committed_at timestamp without time zone,
    project_id bigint,
    status character varying,
    started_at timestamp without time zone,
    finished_at timestamp without time zone,
    duration integer,
    user_id bigint,
    lock_version integer DEFAULT 0,
    pipeline_schedule_id bigint,
    source integer,
    config_source integer,
    protected boolean,
    failure_reason integer,
    iid integer,
    merge_request_id bigint,
    source_sha bytea,
    target_sha bytea,
    external_pull_request_id bigint,
    ci_ref_id bigint,
    locked smallint DEFAULT 1 NOT NULL,
    partition_id bigint NOT NULL,
    id bigint NOT NULL,
    auto_canceled_by_id bigint,
    auto_canceled_by_partition_id bigint,
    CONSTRAINT check_2ba2a044b9 CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_d7e99a025e CHECK ((lock_version IS NOT NULL))
)
PARTITION BY LIST (partition_id);

CREATE TABLE ci_pipelines (
    ref character varying,
    sha character varying,
    before_sha character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    tag boolean DEFAULT false,
    yaml_errors text,
    committed_at timestamp without time zone,
    project_id bigint,
    status character varying,
    started_at timestamp without time zone,
    finished_at timestamp without time zone,
    duration integer,
    user_id bigint,
    lock_version integer DEFAULT 0,
    pipeline_schedule_id bigint,
    source integer,
    config_source integer,
    protected boolean,
    failure_reason integer,
    iid integer,
    merge_request_id bigint,
    source_sha bytea,
    target_sha bytea,
    external_pull_request_id bigint,
    ci_ref_id bigint,
    locked smallint DEFAULT 1 NOT NULL,
    partition_id bigint NOT NULL,
    id bigint NOT NULL,
    auto_canceled_by_id bigint,
    auto_canceled_by_partition_id bigint,
    CONSTRAINT check_2ba2a044b9 CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_d7e99a025e CHECK ((lock_version IS NOT NULL))
);

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

ALTER SEQUENCE ci_pipelines_id_seq OWNED BY p_ci_pipelines.id;

CREATE TABLE ci_project_mirrors (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    namespace_id bigint NOT NULL
);

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

ALTER SEQUENCE ci_project_mirrors_id_seq OWNED BY ci_project_mirrors.id;

CREATE TABLE ci_project_monthly_usages (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    date date NOT NULL,
    created_at timestamp with time zone,
    amount_used numeric(18,4) DEFAULT 0.0 NOT NULL,
    shared_runners_duration bigint DEFAULT 0 NOT NULL,
    CONSTRAINT ci_project_monthly_usages_year_month_constraint CHECK ((date = date_trunc('month'::text, (date)::timestamp with time zone)))
);

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

ALTER SEQUENCE ci_project_monthly_usages_id_seq OWNED BY ci_project_monthly_usages.id;

CREATE TABLE ci_refs (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    lock_version integer DEFAULT 0 NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    ref_path text NOT NULL
);

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

ALTER SEQUENCE ci_refs_id_seq OWNED BY ci_refs.id;

CREATE TABLE ci_resource_groups (
    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,
    key character varying(255) NOT NULL,
    process_mode smallint DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE ci_resource_groups_id_seq OWNED BY ci_resource_groups.id;

CREATE TABLE ci_resources (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    resource_group_id bigint NOT NULL,
    build_id bigint,
    partition_id bigint,
    project_id bigint
);

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

ALTER SEQUENCE ci_resources_id_seq OWNED BY ci_resources.id;

CREATE TABLE ci_runner_machines (
    id bigint NOT NULL,
    runner_id bigint NOT NULL,
    executor_type smallint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    contacted_at timestamp with time zone,
    version text,
    revision text,
    platform text,
    architecture text,
    ip_address text,
    config jsonb DEFAULT '{}'::jsonb NOT NULL,
    system_xid text,
    creation_state smallint DEFAULT 0 NOT NULL,
    runner_type smallint,
    sharding_key_id bigint,
    CONSTRAINT check_1537c1f66f CHECK ((char_length(platform) <= 255)),
    CONSTRAINT check_5253913ae9 CHECK ((char_length(system_xid) <= 64)),
    CONSTRAINT check_6f45a91da7 CHECK ((char_length(version) <= 2048)),
    CONSTRAINT check_9b521b3105 CHECK ((char_length(architecture) <= 255)),
    CONSTRAINT check_afb8efc1a2 CHECK ((char_length(revision) <= 255)),
    CONSTRAINT check_b714f452d5 CHECK ((system_xid IS NOT NULL)),
    CONSTRAINT check_f214590856 CHECK ((char_length(ip_address) <= 1024))
);

CREATE TABLE ci_runner_machines_687967fa8a (
    id bigint NOT NULL,
    runner_id bigint NOT NULL,
    sharding_key_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    contacted_at timestamp with time zone,
    creation_state smallint DEFAULT 0 NOT NULL,
    executor_type smallint,
    runner_type smallint NOT NULL,
    config jsonb DEFAULT '{}'::jsonb NOT NULL,
    system_xid text NOT NULL,
    platform text,
    architecture text,
    revision text,
    ip_address text,
    version text,
    CONSTRAINT check_3d8736b3af CHECK ((char_length(system_xid) <= 64)),
    CONSTRAINT check_5bad2a6944 CHECK ((char_length(revision) <= 255)),
    CONSTRAINT check_7dc4eee8a5 CHECK ((char_length(version) <= 2048)),
    CONSTRAINT check_b1e456641b CHECK ((char_length(ip_address) <= 1024)),
    CONSTRAINT check_c788f4b18a CHECK ((char_length(platform) <= 255)),
    CONSTRAINT check_f3d25ab844 CHECK ((char_length(architecture) <= 255))
)
PARTITION BY LIST (runner_type);

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

ALTER SEQUENCE ci_runner_machines_id_seq OWNED BY ci_runner_machines.id;

CREATE TABLE ci_runner_namespaces (
    id bigint NOT NULL,
    runner_id bigint,
    namespace_id bigint,
    CONSTRAINT check_5f3dce48df CHECK ((namespace_id IS NOT NULL))
);

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

ALTER SEQUENCE ci_runner_namespaces_id_seq OWNED BY ci_runner_namespaces.id;

CREATE TABLE ci_runner_projects (
    id bigint NOT NULL,
    runner_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    project_id bigint,
    CONSTRAINT check_db297016c6 CHECK ((project_id IS NOT NULL))
);

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

ALTER SEQUENCE ci_runner_projects_id_seq OWNED BY ci_runner_projects.id;

CREATE TABLE ci_runner_taggings (
    id bigint NOT NULL,
    tag_id bigint NOT NULL,
    runner_id bigint NOT NULL,
    sharding_key_id bigint,
    runner_type smallint NOT NULL
)
PARTITION BY LIST (runner_type);

CREATE TABLE ci_runner_taggings_group_type (
    id bigint NOT NULL,
    tag_id bigint NOT NULL,
    runner_id bigint NOT NULL,
    sharding_key_id bigint,
    runner_type smallint NOT NULL,
    CONSTRAINT check_sharding_key_id_nullness CHECK ((sharding_key_id IS NOT NULL))
);

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

ALTER SEQUENCE ci_runner_taggings_id_seq OWNED BY ci_runner_taggings.id;

CREATE TABLE ci_runner_taggings_instance_type (
    id bigint NOT NULL,
    tag_id bigint NOT NULL,
    runner_id bigint NOT NULL,
    sharding_key_id bigint,
    runner_type smallint NOT NULL,
    CONSTRAINT check_sharding_key_id_nullness CHECK ((sharding_key_id IS NULL))
);

CREATE TABLE ci_runner_taggings_project_type (
    id bigint NOT NULL,
    tag_id bigint NOT NULL,
    runner_id bigint NOT NULL,
    sharding_key_id bigint,
    runner_type smallint NOT NULL,
    CONSTRAINT check_sharding_key_id_nullness CHECK ((sharding_key_id IS NOT NULL))
);

CREATE TABLE ci_runner_versions (
    version text NOT NULL,
    status smallint,
    CONSTRAINT check_b5a3714594 CHECK ((char_length(version) <= 2048))
);

CREATE TABLE ci_runners (
    id bigint NOT NULL,
    token character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    description character varying,
    contacted_at timestamp without time zone,
    active boolean DEFAULT true NOT NULL,
    name character varying,
    run_untagged boolean DEFAULT true NOT NULL,
    locked boolean DEFAULT false NOT NULL,
    access_level integer DEFAULT 0 NOT NULL,
    maximum_timeout integer,
    runner_type smallint NOT NULL,
    token_encrypted character varying,
    public_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    maintainer_note text,
    token_expires_at timestamp with time zone,
    allowed_plans text[] DEFAULT '{}'::text[] NOT NULL,
    registration_type smallint DEFAULT 0 NOT NULL,
    creator_id bigint,
    creation_state smallint DEFAULT 0 NOT NULL,
    allowed_plan_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL,
    sharding_key_id bigint,
    CONSTRAINT check_46c685e76f CHECK ((char_length((description)::text) <= 1024)),
    CONSTRAINT check_91230910ec CHECK ((char_length((name)::text) <= 256)),
    CONSTRAINT check_ce275cee06 CHECK ((char_length(maintainer_note) <= 1024))
);

CREATE TABLE ci_runners_e59bb2812d (
    id bigint NOT NULL,
    creator_id bigint,
    sharding_key_id bigint,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    contacted_at timestamp with time zone,
    token_expires_at timestamp with time zone,
    public_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    access_level integer DEFAULT 0 NOT NULL,
    maximum_timeout integer,
    runner_type smallint NOT NULL,
    registration_type smallint DEFAULT 0 NOT NULL,
    creation_state smallint DEFAULT 0 NOT NULL,
    active boolean DEFAULT true NOT NULL,
    run_untagged boolean DEFAULT true NOT NULL,
    locked boolean DEFAULT false NOT NULL,
    name text,
    token_encrypted text,
    token text,
    description text,
    maintainer_note text,
    allowed_plans text[] DEFAULT '{}'::text[] NOT NULL,
    allowed_plan_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL,
    CONSTRAINT check_1f8618ab23 CHECK ((char_length(name) <= 256)),
    CONSTRAINT check_24b281f5bf CHECK ((char_length(maintainer_note) <= 1024)),
    CONSTRAINT check_31c16b2a99 CHECK ((char_length(token_encrypted) <= 128)),
    CONSTRAINT check_5db8ae9d30 CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_af25130d5a CHECK ((char_length(token) <= 128))
)
PARTITION BY LIST (runner_type);

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

ALTER SEQUENCE ci_runners_id_seq OWNED BY ci_runners.id;

CREATE TABLE ci_running_builds (
    id bigint NOT NULL,
    build_id bigint NOT NULL,
    project_id bigint NOT NULL,
    runner_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    runner_type smallint NOT NULL,
    partition_id bigint NOT NULL,
    runner_owner_namespace_xid bigint
);

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

ALTER SEQUENCE ci_running_builds_id_seq OWNED BY ci_running_builds.id;

CREATE TABLE ci_secure_file_states (
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    ci_secure_file_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint,
    verification_checksum bytea,
    verification_failure text,
    project_id bigint,
    CONSTRAINT check_a79e5a9261 CHECK ((char_length(verification_failure) <= 255))
);

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

ALTER SEQUENCE ci_secure_file_states_ci_secure_file_id_seq OWNED BY ci_secure_file_states.ci_secure_file_id;

CREATE TABLE ci_secure_files (
    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,
    file_store smallint DEFAULT 1 NOT NULL,
    name text NOT NULL,
    file text NOT NULL,
    checksum bytea NOT NULL,
    key_data text,
    metadata jsonb,
    expires_at timestamp with time zone,
    CONSTRAINT check_320790634d CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_402c7b4a56 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_7279b4e293 CHECK ((char_length(key_data) <= 128))
);

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

ALTER SEQUENCE ci_secure_files_id_seq OWNED BY ci_secure_files.id;

CREATE TABLE ci_sources_pipelines (
    id bigint NOT NULL,
    project_id bigint,
    source_project_id bigint,
    source_job_id bigint,
    partition_id bigint NOT NULL,
    source_partition_id bigint NOT NULL,
    pipeline_id bigint,
    source_pipeline_id bigint
);

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

ALTER SEQUENCE ci_sources_pipelines_id_seq OWNED BY ci_sources_pipelines.id;

CREATE TABLE ci_sources_projects (
    id bigint NOT NULL,
    pipeline_id bigint NOT NULL,
    source_project_id bigint NOT NULL,
    partition_id bigint NOT NULL
);

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

ALTER SEQUENCE ci_sources_projects_id_seq OWNED BY ci_sources_projects.id;

CREATE TABLE 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))
);

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

ALTER SEQUENCE ci_stages_id_seq OWNED BY p_ci_stages.id;

CREATE TABLE ci_subscriptions_projects (
    id bigint NOT NULL,
    downstream_project_id bigint NOT NULL,
    upstream_project_id bigint NOT NULL,
    author_id bigint
);

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

ALTER SEQUENCE ci_subscriptions_projects_id_seq OWNED BY ci_subscriptions_projects.id;

CREATE TABLE ci_trigger_requests (
    id bigint NOT NULL,
    trigger_id bigint NOT NULL,
    variables text,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    commit_id bigint,
    project_id bigint
);

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

ALTER SEQUENCE ci_trigger_requests_id_seq OWNED BY ci_trigger_requests.id;

CREATE TABLE ci_triggers (
    id bigint NOT NULL,
    token character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    project_id bigint,
    owner_id bigint NOT NULL,
    description character varying,
    encrypted_token bytea,
    encrypted_token_iv bytea
);

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

ALTER SEQUENCE ci_triggers_id_seq OWNED BY ci_triggers.id;

CREATE TABLE ci_unit_test_failures (
    id bigint NOT NULL,
    failed_at timestamp with time zone NOT NULL,
    unit_test_id bigint NOT NULL,
    build_id bigint NOT NULL,
    partition_id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE ci_unit_test_failures_id_seq OWNED BY ci_unit_test_failures.id;

CREATE TABLE ci_unit_tests (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    key_hash text NOT NULL,
    name text NOT NULL,
    suite_name text NOT NULL,
    CONSTRAINT check_248fae1a3b CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_b288215ffe CHECK ((char_length(key_hash) <= 64)),
    CONSTRAINT check_c2d57b3c49 CHECK ((char_length(suite_name) <= 255))
);

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

ALTER SEQUENCE ci_unit_tests_id_seq OWNED BY ci_unit_tests.id;

CREATE TABLE ci_variables (
    id bigint NOT NULL,
    key character varying NOT NULL,
    value text,
    encrypted_value text,
    encrypted_value_salt character varying,
    encrypted_value_iv character varying,
    project_id bigint NOT NULL,
    protected boolean DEFAULT false NOT NULL,
    environment_scope character varying DEFAULT '*'::character varying NOT NULL,
    masked boolean DEFAULT false NOT NULL,
    variable_type smallint DEFAULT 1 NOT NULL,
    raw boolean DEFAULT false NOT NULL,
    description text,
    hidden boolean DEFAULT false NOT NULL,
    CONSTRAINT check_7e46c006aa CHECK ((char_length(description) <= 255))
);

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

ALTER SEQUENCE ci_variables_id_seq OWNED BY ci_variables.id;

CREATE TABLE cloud_connector_access (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    data jsonb NOT NULL
);

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

ALTER SEQUENCE cloud_connector_access_id_seq OWNED BY cloud_connector_access.id;

CREATE TABLE cluster_agent_tokens (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    agent_id bigint NOT NULL,
    token_encrypted text NOT NULL,
    created_by_user_id bigint,
    description text,
    name text,
    last_used_at timestamp with time zone,
    status smallint DEFAULT 0 NOT NULL,
    project_id bigint,
    CONSTRAINT check_0fb634d04d CHECK ((name IS NOT NULL)),
    CONSTRAINT check_2b79dbb315 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_4e4ec5070a CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_c60daed227 CHECK ((char_length(token_encrypted) <= 255))
);

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

ALTER SEQUENCE cluster_agent_tokens_id_seq OWNED BY cluster_agent_tokens.id;

CREATE TABLE cluster_agent_url_configurations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    agent_id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_by_user_id bigint,
    status smallint DEFAULT 0 NOT NULL,
    url text NOT NULL,
    ca_cert text,
    client_key text,
    client_cert text,
    tls_host text,
    public_key bytea,
    encrypted_private_key bytea,
    encrypted_private_key_iv bytea,
    CONSTRAINT check_1ffcfef6d6 CHECK ((char_length(tls_host) <= 2048)),
    CONSTRAINT check_25ef8c679c CHECK ((char_length(ca_cert) <= 16384)),
    CONSTRAINT check_93a57284e5 CHECK ((char_length(client_cert) <= 16384)),
    CONSTRAINT check_e3736d97df CHECK ((char_length(client_key) <= 16384)),
    CONSTRAINT check_ed21ced327 CHECK ((char_length(url) <= 2048))
);

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

ALTER SEQUENCE cluster_agent_url_configurations_id_seq OWNED BY cluster_agent_url_configurations.id;

CREATE TABLE cluster_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,
    created_by_user_id bigint,
    has_vulnerabilities boolean DEFAULT false NOT NULL,
    connection_mode smallint DEFAULT 0 NOT NULL,
    is_receptive boolean DEFAULT false NOT NULL,
    CONSTRAINT check_3498369510 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE cluster_agents_id_seq OWNED BY cluster_agents.id;

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

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

ALTER SEQUENCE cluster_enabled_grants_id_seq OWNED BY cluster_enabled_grants.id;

CREATE TABLE cluster_groups (
    id bigint NOT NULL,
    cluster_id bigint NOT NULL,
    group_id bigint NOT NULL
);

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

ALTER SEQUENCE cluster_groups_id_seq OWNED BY cluster_groups.id;

CREATE TABLE cluster_platforms_kubernetes (
    id bigint NOT NULL,
    cluster_id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    api_url text,
    ca_cert text,
    namespace character varying,
    username character varying,
    encrypted_password text,
    encrypted_password_iv character varying,
    encrypted_token text,
    encrypted_token_iv character varying,
    authorization_type smallint
);

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

ALTER SEQUENCE cluster_platforms_kubernetes_id_seq OWNED BY cluster_platforms_kubernetes.id;

CREATE TABLE cluster_projects (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    cluster_id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE cluster_projects_id_seq OWNED BY cluster_projects.id;

CREATE TABLE cluster_providers_aws (
    id bigint NOT NULL,
    cluster_id bigint NOT NULL,
    num_nodes integer NOT NULL,
    status integer NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    key_name character varying(255) NOT NULL,
    role_arn character varying(2048) NOT NULL,
    region character varying(255) NOT NULL,
    vpc_id character varying(255) NOT NULL,
    subnet_ids character varying(255)[] DEFAULT '{}'::character varying[] NOT NULL,
    security_group_id character varying(255) NOT NULL,
    instance_type character varying(255) NOT NULL,
    access_key_id character varying(255),
    encrypted_secret_access_key_iv character varying(255),
    encrypted_secret_access_key text,
    session_token text,
    status_reason text,
    kubernetes_version text DEFAULT '1.14'::text NOT NULL,
    CONSTRAINT check_f1f42cd85e CHECK ((char_length(kubernetes_version) <= 30))
);

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

ALTER SEQUENCE cluster_providers_aws_id_seq OWNED BY cluster_providers_aws.id;

CREATE TABLE cluster_providers_gcp (
    id bigint NOT NULL,
    cluster_id bigint NOT NULL,
    status integer,
    num_nodes integer NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    status_reason text,
    gcp_project_id character varying NOT NULL,
    zone character varying NOT NULL,
    machine_type character varying,
    operation_id character varying,
    endpoint character varying,
    encrypted_access_token text,
    encrypted_access_token_iv character varying,
    legacy_abac boolean DEFAULT false NOT NULL,
    cloud_run boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE cluster_providers_gcp_id_seq OWNED BY cluster_providers_gcp.id;

CREATE TABLE clusters (
    id bigint NOT NULL,
    user_id bigint,
    provider_type integer,
    platform_type integer,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    enabled boolean DEFAULT true,
    name character varying NOT NULL,
    environment_scope character varying DEFAULT '*'::character varying NOT NULL,
    cluster_type smallint DEFAULT 3 NOT NULL,
    domain character varying,
    managed boolean DEFAULT true NOT NULL,
    namespace_per_environment boolean DEFAULT true NOT NULL,
    management_project_id bigint,
    cleanup_status smallint DEFAULT 1 NOT NULL,
    cleanup_status_reason text,
    helm_major_version integer DEFAULT 3 NOT NULL
);

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

ALTER SEQUENCE clusters_id_seq OWNED BY clusters.id;

CREATE TABLE clusters_integration_prometheus (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    cluster_id bigint NOT NULL,
    enabled boolean DEFAULT false NOT NULL,
    encrypted_alert_manager_token text,
    encrypted_alert_manager_token_iv text,
    health_status smallint DEFAULT 0 NOT NULL
);

CREATE TABLE clusters_kubernetes_namespaces (
    id bigint NOT NULL,
    cluster_id bigint NOT NULL,
    project_id bigint,
    cluster_project_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    encrypted_service_account_token text,
    encrypted_service_account_token_iv character varying,
    namespace character varying NOT NULL,
    service_account_name character varying,
    environment_id bigint
);

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

ALTER SEQUENCE clusters_kubernetes_namespaces_id_seq OWNED BY clusters_kubernetes_namespaces.id;

CREATE TABLE commit_user_mentions (
    id bigint NOT NULL,
    mentioned_users_ids bigint[],
    mentioned_projects_ids bigint[],
    mentioned_groups_ids bigint[],
    commit_id character varying NOT NULL,
    note_id bigint NOT NULL
);

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

ALTER SEQUENCE commit_user_mentions_id_seq OWNED BY commit_user_mentions.id;

CREATE TABLE compliance_framework_security_policies (
    id bigint NOT NULL,
    framework_id bigint NOT NULL,
    policy_configuration_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    policy_index smallint NOT NULL,
    project_id bigint,
    namespace_id bigint
);

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

ALTER SEQUENCE compliance_framework_security_policies_id_seq OWNED BY compliance_framework_security_policies.id;

CREATE TABLE compliance_management_frameworks (
    id bigint NOT NULL,
    name text NOT NULL,
    description text NOT NULL,
    color text NOT NULL,
    namespace_id bigint NOT NULL,
    pipeline_configuration_full_path text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    CONSTRAINT check_08cd34b2c2 CHECK ((char_length(color) <= 10)),
    CONSTRAINT check_1617e0b87e CHECK ((char_length(description) <= 255)),
    CONSTRAINT check_ab00bc2193 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_e7a9972435 CHECK ((char_length(pipeline_configuration_full_path) <= 255))
);

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

ALTER SEQUENCE compliance_management_frameworks_id_seq OWNED BY compliance_management_frameworks.id;

CREATE TABLE compliance_requirements (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    framework_id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    name text NOT NULL,
    description text NOT NULL,
    control_expression text,
    requirement_type smallint DEFAULT 0 NOT NULL,
    CONSTRAINT check_71d7c59197 CHECK ((char_length(description) <= 255)),
    CONSTRAINT check_be5c3cfc16 CHECK ((char_length(control_expression) <= 2048)),
    CONSTRAINT check_f1fb6fdd81 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE compliance_requirements_id_seq OWNED BY compliance_requirements.id;

CREATE TABLE container_expiration_policies (
    project_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    next_run_at timestamp with time zone,
    name_regex character varying(255) DEFAULT '.*'::character varying,
    cadence character varying(12) DEFAULT '1d'::character varying NOT NULL,
    older_than character varying(12) DEFAULT '90d'::character varying,
    keep_n integer DEFAULT 10,
    enabled boolean DEFAULT false NOT NULL,
    name_regex_keep text,
    CONSTRAINT container_expiration_policies_name_regex_keep CHECK ((char_length(name_regex_keep) <= 255))
);

CREATE TABLE container_registry_data_repair_details (
    missing_count integer DEFAULT 0,
    project_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
);

CREATE TABLE container_registry_protection_rules (
    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,
    repository_path_pattern text,
    minimum_access_level_for_push smallint,
    minimum_access_level_for_delete smallint,
    CONSTRAINT check_0dc4ab5f43 CHECK ((num_nonnulls(minimum_access_level_for_delete, minimum_access_level_for_push) > 0)),
    CONSTRAINT check_3658b31291 CHECK ((repository_path_pattern IS NOT NULL)),
    CONSTRAINT check_d53a270af5 CHECK ((char_length(repository_path_pattern) <= 255))
);

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

ALTER SEQUENCE container_registry_protection_rules_id_seq OWNED BY container_registry_protection_rules.id;

CREATE TABLE container_repositories (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    name character varying NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    status smallint,
    expiration_policy_started_at timestamp with time zone,
    expiration_policy_cleanup_status smallint DEFAULT 0 NOT NULL,
    expiration_policy_completed_at timestamp with time zone,
    last_cleanup_deleted_tags_count integer,
    delete_started_at timestamp with time zone,
    status_updated_at timestamp with time zone,
    failed_deletion_count integer DEFAULT 0 NOT NULL,
    next_delete_attempt_at timestamp with time zone,
    CONSTRAINT check_container_repositories_non_negative_failed_deletion_count CHECK ((failed_deletion_count >= 0))
);

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

ALTER SEQUENCE container_repositories_id_seq OWNED BY container_repositories.id;

CREATE TABLE container_repository_states (
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    container_repository_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint DEFAULT 0 NOT NULL,
    verification_checksum bytea,
    verification_failure text,
    project_id bigint,
    CONSTRAINT check_c96417dbc5 CHECK ((char_length(verification_failure) <= 255))
);

CREATE TABLE content_blocked_states (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    commit_sha bytea NOT NULL,
    blob_sha bytea NOT NULL,
    path text NOT NULL,
    container_identifier text NOT NULL,
    CONSTRAINT check_023093d38f CHECK ((char_length(container_identifier) <= 255)),
    CONSTRAINT check_1870100678 CHECK ((char_length(path) <= 2048))
);

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

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

ALTER SEQUENCE content_blocked_states_id_seq OWNED BY content_blocked_states.id;

CREATE TABLE conversational_development_index_metrics (
    id bigint NOT NULL,
    leader_issues double precision NOT NULL,
    instance_issues double precision NOT NULL,
    leader_notes double precision NOT NULL,
    instance_notes double precision NOT NULL,
    leader_milestones double precision NOT NULL,
    instance_milestones double precision NOT NULL,
    leader_boards double precision NOT NULL,
    instance_boards double precision NOT NULL,
    leader_merge_requests double precision NOT NULL,
    instance_merge_requests double precision NOT NULL,
    leader_ci_pipelines double precision NOT NULL,
    instance_ci_pipelines double precision NOT NULL,
    leader_environments double precision NOT NULL,
    instance_environments double precision NOT NULL,
    leader_deployments double precision NOT NULL,
    instance_deployments double precision NOT NULL,
    leader_projects_prometheus_active double precision NOT NULL,
    instance_projects_prometheus_active double precision NOT NULL,
    leader_service_desk_issues double precision NOT NULL,
    instance_service_desk_issues double precision NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    percentage_boards double precision DEFAULT 0.0 NOT NULL,
    percentage_ci_pipelines double precision DEFAULT 0.0 NOT NULL,
    percentage_deployments double precision DEFAULT 0.0 NOT NULL,
    percentage_environments double precision DEFAULT 0.0 NOT NULL,
    percentage_issues double precision DEFAULT 0.0 NOT NULL,
    percentage_merge_requests double precision DEFAULT 0.0 NOT NULL,
    percentage_milestones double precision DEFAULT 0.0 NOT NULL,
    percentage_notes double precision DEFAULT 0.0 NOT NULL,
    percentage_projects_prometheus_active double precision DEFAULT 0.0 NOT NULL,
    percentage_service_desk_issues double precision DEFAULT 0.0 NOT NULL
);

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

ALTER SEQUENCE conversational_development_index_metrics_id_seq OWNED BY conversational_development_index_metrics.id;

CREATE TABLE country_access_logs (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    access_count_reset_at timestamp with time zone,
    first_access_at timestamp with time zone,
    last_access_at timestamp with time zone,
    user_id bigint NOT NULL,
    access_count integer DEFAULT 0 NOT NULL,
    country_code smallint NOT NULL
);

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

ALTER SEQUENCE country_access_logs_id_seq OWNED BY country_access_logs.id;

CREATE TABLE coverage_fuzzing_corpuses (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    user_id bigint,
    package_id bigint NOT NULL,
    file_updated_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
);

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

ALTER SEQUENCE coverage_fuzzing_corpuses_id_seq OWNED BY coverage_fuzzing_corpuses.id;

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

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

ALTER SEQUENCE csv_issue_imports_id_seq OWNED BY csv_issue_imports.id;

CREATE TABLE custom_emoji (
    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,
    file text NOT NULL,
    external boolean DEFAULT true NOT NULL,
    creator_id bigint NOT NULL,
    CONSTRAINT check_8c586dd507 CHECK ((char_length(name) <= 36)),
    CONSTRAINT check_dd5d60f1fb CHECK ((char_length(file) <= 255))
);

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

ALTER SEQUENCE custom_emoji_id_seq OWNED BY custom_emoji.id;

CREATE TABLE custom_field_select_options (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    custom_field_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    "position" smallint NOT NULL,
    value text NOT NULL,
    CONSTRAINT check_fbed57c2bf CHECK ((char_length(value) <= 255))
);

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

ALTER SEQUENCE custom_field_select_options_id_seq OWNED BY custom_field_select_options.id;

CREATE TABLE custom_fields (
    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,
    archived_at timestamp with time zone,
    field_type smallint NOT NULL,
    name text NOT NULL,
    created_by_id bigint,
    updated_by_id bigint,
    CONSTRAINT check_b047b04af9 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE custom_fields_id_seq OWNED BY custom_fields.id;

CREATE TABLE custom_software_licenses (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    name text NOT NULL,
    CONSTRAINT check_4e365784ce CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE custom_software_licenses_id_seq OWNED BY custom_software_licenses.id;

CREATE TABLE customer_relations_contacts (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    organization_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    state smallint DEFAULT 1 NOT NULL,
    phone text,
    first_name text NOT NULL,
    last_name text NOT NULL,
    email text,
    description text,
    CONSTRAINT check_1195f4c929 CHECK ((char_length(first_name) <= 255)),
    CONSTRAINT check_40c70da037 CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_cd2d67c484 CHECK ((char_length(last_name) <= 255)),
    CONSTRAINT check_f4b7f78c89 CHECK ((char_length(phone) <= 32)),
    CONSTRAINT check_fc0adabf60 CHECK ((char_length(email) <= 255))
);

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

ALTER SEQUENCE customer_relations_contacts_id_seq OWNED BY customer_relations_contacts.id;

CREATE TABLE customer_relations_organizations (
    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,
    state smallint DEFAULT 1 NOT NULL,
    default_rate numeric(18,2),
    name text NOT NULL,
    description text,
    CONSTRAINT check_2ba9ef1c4c CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_e476b6058e CHECK ((char_length(description) <= 1024))
);

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

ALTER SEQUENCE customer_relations_organizations_id_seq OWNED BY customer_relations_organizations.id;

CREATE TABLE dast_pre_scan_verification_steps (
    id bigint NOT NULL,
    dast_pre_scan_verification_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    name text,
    verification_errors text[] DEFAULT '{}'::text[] NOT NULL,
    check_type smallint DEFAULT 0 NOT NULL,
    CONSTRAINT check_cd216b95e4 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE dast_pre_scan_verification_steps_id_seq OWNED BY dast_pre_scan_verification_steps.id;

CREATE TABLE dast_pre_scan_verifications (
    id bigint NOT NULL,
    dast_profile_id bigint NOT NULL,
    ci_pipeline_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE dast_pre_scan_verifications_id_seq OWNED BY dast_pre_scan_verifications.id;

CREATE TABLE dast_profile_schedules (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    dast_profile_id bigint NOT NULL,
    user_id bigint,
    next_run_at timestamp with time zone NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    active boolean DEFAULT true NOT NULL,
    cron text NOT NULL,
    cadence jsonb DEFAULT '{}'::jsonb NOT NULL,
    timezone text NOT NULL,
    starts_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT check_86531ea73f CHECK ((char_length(cron) <= 255)),
    CONSTRAINT check_be4d1c3af1 CHECK ((char_length(timezone) <= 255))
);

COMMENT ON TABLE dast_profile_schedules IS '{"owner":"group::dynamic analysis","description":"Scheduling for scans using DAST Profiles"}';

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

ALTER SEQUENCE dast_profile_schedules_id_seq OWNED BY dast_profile_schedules.id;

CREATE TABLE dast_profiles (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    dast_site_profile_id bigint NOT NULL,
    dast_scanner_profile_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    name text NOT NULL,
    description text NOT NULL,
    branch_name text,
    CONSTRAINT check_5fcf73bf61 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_6c9d775949 CHECK ((char_length(branch_name) <= 255)),
    CONSTRAINT check_c34e505c24 CHECK ((char_length(description) <= 255))
);

COMMENT ON TABLE dast_profiles IS '{"owner":"group::dynamic analysis","description":"Profile used to run a DAST on-demand scan"}';

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

ALTER SEQUENCE dast_profiles_id_seq OWNED BY dast_profiles.id;

CREATE TABLE dast_profiles_pipelines (
    dast_profile_id bigint NOT NULL,
    ci_pipeline_id bigint NOT NULL,
    project_id bigint
);

COMMENT ON TABLE dast_profiles_pipelines IS '{"owner":"group::dynamic analysis","description":"Join table between DAST Profiles and CI Pipelines"}';

CREATE TABLE dast_profiles_tags (
    id bigint NOT NULL,
    dast_profile_id bigint NOT NULL,
    tag_id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE dast_profiles_tags_id_seq OWNED BY dast_profiles_tags.id;

CREATE TABLE dast_scanner_profiles (
    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,
    spider_timeout smallint,
    target_timeout smallint,
    name text NOT NULL,
    scan_type smallint DEFAULT 1 NOT NULL,
    use_ajax_spider boolean DEFAULT false NOT NULL,
    show_debug_messages boolean DEFAULT false NOT NULL,
    CONSTRAINT check_568568fabf CHECK ((char_length(name) <= 255))
);

CREATE TABLE dast_scanner_profiles_builds (
    dast_scanner_profile_id bigint NOT NULL,
    ci_build_id bigint NOT NULL,
    project_id bigint
);

COMMENT ON TABLE dast_scanner_profiles_builds IS '{"owner":"group::dynamic analysis","description":"Join table between DAST Scanner Profiles and CI Builds"}';

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

ALTER SEQUENCE dast_scanner_profiles_id_seq OWNED BY dast_scanner_profiles.id;

CREATE TABLE dast_site_profile_secret_variables (
    id bigint NOT NULL,
    dast_site_profile_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    variable_type smallint DEFAULT 1 NOT NULL,
    key text NOT NULL,
    encrypted_value bytea NOT NULL,
    encrypted_value_iv bytea NOT NULL,
    project_id bigint,
    CONSTRAINT check_236213f179 CHECK ((length(encrypted_value) <= 13352)),
    CONSTRAINT check_8cbef204b2 CHECK ((char_length(key) <= 255)),
    CONSTRAINT check_b49080abbf CHECK ((length(encrypted_value_iv) <= 17))
);

COMMENT ON TABLE dast_site_profile_secret_variables IS '{"owner":"group::dynamic analysis","description":"Secret variables used in DAST on-demand scans"}';

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

ALTER SEQUENCE dast_site_profile_secret_variables_id_seq OWNED BY dast_site_profile_secret_variables.id;

CREATE TABLE dast_site_profiles (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    dast_site_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    name text NOT NULL,
    excluded_urls text[] DEFAULT '{}'::text[] NOT NULL,
    auth_enabled boolean DEFAULT false NOT NULL,
    auth_url text,
    auth_username_field text,
    auth_password_field text,
    auth_username text,
    target_type smallint DEFAULT 0 NOT NULL,
    scan_method smallint DEFAULT 0 NOT NULL,
    auth_submit_field text,
    scan_file_path text,
    CONSTRAINT check_5203110fee CHECK ((char_length(auth_username_field) <= 255)),
    CONSTRAINT check_6cfab17b48 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_8d2aa0f66d CHECK ((char_length(scan_file_path) <= 1024)),
    CONSTRAINT check_af44f54c96 CHECK ((char_length(auth_submit_field) <= 255)),
    CONSTRAINT check_c329dffdba CHECK ((char_length(auth_password_field) <= 255)),
    CONSTRAINT check_d446f7047b CHECK ((char_length(auth_url) <= 1024)),
    CONSTRAINT check_f22f18002a CHECK ((char_length(auth_username) <= 255))
);

CREATE TABLE dast_site_profiles_builds (
    dast_site_profile_id bigint NOT NULL,
    ci_build_id bigint NOT NULL,
    project_id bigint
);

COMMENT ON TABLE dast_site_profiles_builds IS '{"owner":"group::dynamic analysis","description":"Join table between DAST Site Profiles and CI Builds"}';

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

ALTER SEQUENCE dast_site_profiles_id_seq OWNED BY dast_site_profiles.id;

CREATE TABLE dast_site_tokens (
    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,
    expired_at timestamp with time zone,
    token text NOT NULL,
    url text NOT NULL,
    CONSTRAINT check_02a6bf20a7 CHECK ((char_length(token) <= 255)),
    CONSTRAINT check_69ab8622a6 CHECK ((char_length(url) <= 255))
);

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

ALTER SEQUENCE dast_site_tokens_id_seq OWNED BY dast_site_tokens.id;

CREATE TABLE dast_site_validations (
    id bigint NOT NULL,
    dast_site_token_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    validation_started_at timestamp with time zone,
    validation_passed_at timestamp with time zone,
    validation_failed_at timestamp with time zone,
    validation_last_retried_at timestamp with time zone,
    validation_strategy smallint NOT NULL,
    url_base text NOT NULL,
    url_path text NOT NULL,
    state text DEFAULT 'pending'::text NOT NULL,
    project_id bigint,
    CONSTRAINT check_13b34efe4b CHECK ((char_length(url_path) <= 255)),
    CONSTRAINT check_283be72e9b CHECK ((char_length(state) <= 255)),
    CONSTRAINT check_cd3b538210 CHECK ((char_length(url_base) <= 255))
);

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

ALTER SEQUENCE dast_site_validations_id_seq OWNED BY dast_site_validations.id;

CREATE TABLE dast_sites (
    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,
    url text NOT NULL,
    dast_site_validation_id bigint,
    CONSTRAINT check_46df8b449c CHECK ((char_length(url) <= 255))
);

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

ALTER SEQUENCE dast_sites_id_seq OWNED BY dast_sites.id;

CREATE TABLE dependency_list_export_parts (
    id bigint NOT NULL,
    dependency_list_export_id bigint NOT NULL,
    start_id bigint NOT NULL,
    end_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,
    file_store integer,
    file text,
    CONSTRAINT check_f799431fc1 CHECK ((char_length(file) <= 255))
);

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

ALTER SEQUENCE dependency_list_export_parts_id_seq OWNED BY dependency_list_export_parts.id;

CREATE TABLE dependency_list_exports (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint,
    user_id bigint,
    file_store integer,
    status smallint DEFAULT 0 NOT NULL,
    file text,
    group_id bigint,
    pipeline_id bigint,
    export_type smallint DEFAULT 0 NOT NULL,
    organization_id bigint,
    CONSTRAINT check_67a9c23e79 CHECK ((num_nonnulls(group_id, organization_id, project_id) > 0)),
    CONSTRAINT check_fff6fc9b2f CHECK ((char_length(file) <= 255))
);

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

ALTER SEQUENCE dependency_list_exports_id_seq OWNED BY dependency_list_exports.id;

CREATE TABLE dependency_proxy_blob_states (
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    dependency_proxy_blob_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint DEFAULT 0 NOT NULL,
    verification_checksum bytea,
    verification_failure text,
    group_id bigint,
    CONSTRAINT check_8e4f76fffe CHECK ((char_length(verification_failure) <= 255))
);

COMMENT ON TABLE dependency_proxy_blob_states IS '{"owner":"group::geo","description":"Geo-specific table to store the verification state of DependencyProxy::Blob objects"}';

CREATE TABLE dependency_proxy_blobs (
    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,
    size bigint,
    file_store integer,
    file_name character varying NOT NULL,
    file text NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    read_at timestamp with time zone DEFAULT now() NOT NULL
);

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

ALTER SEQUENCE dependency_proxy_blobs_id_seq OWNED BY dependency_proxy_blobs.id;

CREATE TABLE dependency_proxy_group_settings (
    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,
    enabled boolean DEFAULT true NOT NULL
);

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

ALTER SEQUENCE dependency_proxy_group_settings_id_seq OWNED BY dependency_proxy_group_settings.id;

CREATE TABLE dependency_proxy_image_ttl_group_policies (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    group_id bigint NOT NULL,
    ttl integer DEFAULT 90,
    enabled boolean DEFAULT false NOT NULL
);

CREATE TABLE dependency_proxy_manifest_states (
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    dependency_proxy_manifest_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint DEFAULT 0 NOT NULL,
    verification_checksum bytea,
    verification_failure text,
    group_id bigint,
    CONSTRAINT check_fdd5d9791b CHECK ((char_length(verification_failure) <= 255))
);

CREATE TABLE dependency_proxy_manifests (
    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,
    size bigint,
    file_store smallint,
    file_name text NOT NULL,
    file text NOT NULL,
    digest text NOT NULL,
    content_type text,
    status smallint DEFAULT 0 NOT NULL,
    read_at timestamp with time zone DEFAULT now() NOT NULL,
    CONSTRAINT check_079b293a7b CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_167a9a8a91 CHECK ((char_length(content_type) <= 255)),
    CONSTRAINT check_c579e3f586 CHECK ((char_length(file_name) <= 255)),
    CONSTRAINT check_f5d9996bf1 CHECK ((char_length(digest) <= 255))
);

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

ALTER SEQUENCE dependency_proxy_manifests_id_seq OWNED BY dependency_proxy_manifests.id;

CREATE TABLE dependency_proxy_packages_settings (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    enabled boolean DEFAULT false,
    maven_external_registry_url text,
    encrypted_maven_external_registry_username bytea,
    encrypted_maven_external_registry_username_iv bytea,
    encrypted_maven_external_registry_password bytea,
    encrypted_maven_external_registry_password_iv bytea,
    npm_external_registry_url text,
    encrypted_npm_external_registry_basic_auth bytea,
    encrypted_npm_external_registry_basic_auth_iv bytea,
    encrypted_npm_external_registry_auth_token bytea,
    encrypted_npm_external_registry_auth_token_iv bytea,
    CONSTRAINT check_12c046b67f CHECK ((char_length(npm_external_registry_url) <= 255)),
    CONSTRAINT check_14a2818907 CHECK (((num_nulls(encrypted_maven_external_registry_username, encrypted_maven_external_registry_password) = 0) OR (num_nulls(encrypted_maven_external_registry_username, encrypted_maven_external_registry_password) = 2))),
    CONSTRAINT check_353c7ecafd CHECK ((octet_length(encrypted_maven_external_registry_username) <= 1020)),
    CONSTRAINT check_48643112c8 CHECK ((octet_length(encrypted_npm_external_registry_auth_token) <= 1020)),
    CONSTRAINT check_54126e21c1 CHECK ((octet_length(encrypted_npm_external_registry_basic_auth) <= 1020)),
    CONSTRAINT check_7fafb5606e CHECK ((octet_length(encrypted_npm_external_registry_basic_auth_iv) <= 1020)),
    CONSTRAINT check_93afb1690f CHECK ((num_nulls(encrypted_npm_external_registry_basic_auth, encrypted_npm_external_registry_auth_token) > 0)),
    CONSTRAINT check_ac55c514a5 CHECK ((char_length(maven_external_registry_url) <= 255)),
    CONSTRAINT check_c6f700648d CHECK ((octet_length(encrypted_maven_external_registry_password) <= 1020)),
    CONSTRAINT check_c8613a3d35 CHECK ((octet_length(encrypted_npm_external_registry_auth_token_iv) <= 1020)),
    CONSTRAINT check_cdf5f9a434 CHECK ((octet_length(encrypted_maven_external_registry_password_iv) <= 1020)),
    CONSTRAINT check_fd5def68ba CHECK ((octet_length(encrypted_maven_external_registry_username_iv) <= 1020))
);

CREATE TABLE deploy_keys_projects (
    id bigint NOT NULL,
    deploy_key_id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    can_push boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE deploy_keys_projects_id_seq OWNED BY deploy_keys_projects.id;

CREATE TABLE deploy_tokens (
    id bigint NOT NULL,
    revoked boolean DEFAULT false,
    read_repository boolean DEFAULT false NOT NULL,
    read_registry boolean DEFAULT false NOT NULL,
    expires_at timestamp with time zone NOT NULL,
    created_at timestamp with time zone NOT NULL,
    name character varying NOT NULL,
    username character varying,
    token_encrypted character varying(255),
    deploy_token_type smallint DEFAULT 2 NOT NULL,
    write_registry boolean DEFAULT false NOT NULL,
    read_package_registry boolean DEFAULT false NOT NULL,
    write_package_registry boolean DEFAULT false NOT NULL,
    creator_id bigint,
    read_virtual_registry boolean DEFAULT false NOT NULL,
    project_id bigint,
    group_id bigint
);

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

ALTER SEQUENCE deploy_tokens_id_seq OWNED BY deploy_tokens.id;

CREATE TABLE deployment_approvals (
    id bigint NOT NULL,
    deployment_id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    status smallint NOT NULL,
    comment text,
    approval_rule_id bigint,
    project_id bigint,
    CONSTRAINT check_692c1d1b90 CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_e2eb6a17d8 CHECK ((char_length(comment) <= 255))
);

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

ALTER SEQUENCE deployment_approvals_id_seq OWNED BY deployment_approvals.id;

CREATE TABLE deployment_clusters (
    deployment_id bigint NOT NULL,
    cluster_id bigint NOT NULL,
    kubernetes_namespace character varying(255)
);

CREATE TABLE deployment_merge_requests (
    deployment_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    environment_id bigint
);

CREATE TABLE deployments (
    id bigint NOT NULL,
    iid integer NOT NULL,
    project_id bigint NOT NULL,
    environment_id bigint NOT NULL,
    ref character varying NOT NULL,
    tag boolean NOT NULL,
    sha character varying NOT NULL,
    user_id bigint,
    deployable_type character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    on_stop character varying,
    status smallint NOT NULL,
    finished_at timestamp with time zone,
    deployable_id bigint,
    archived boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE deployments_id_seq OWNED BY deployments.id;

CREATE TABLE description_versions (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    issue_id bigint,
    merge_request_id bigint,
    epic_id bigint,
    description text,
    deleted_at timestamp with time zone
);

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

ALTER SEQUENCE description_versions_id_seq OWNED BY description_versions.id;

CREATE TABLE design_management_designs (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    issue_id bigint,
    filename character varying NOT NULL,
    relative_position integer,
    iid integer,
    cached_markdown_version integer,
    description text,
    description_html text,
    imported_from smallint DEFAULT 0 NOT NULL,
    namespace_id bigint,
    CONSTRAINT check_07155e2715 CHECK ((char_length((filename)::text) <= 255)),
    CONSTRAINT check_aaf9fa6ae5 CHECK ((char_length(description) <= 1000000)),
    CONSTRAINT check_cfb92df01a CHECK ((iid IS NOT NULL))
);

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

ALTER SEQUENCE design_management_designs_id_seq OWNED BY design_management_designs.id;

CREATE TABLE design_management_designs_versions (
    id bigint NOT NULL,
    design_id bigint NOT NULL,
    version_id bigint NOT NULL,
    event smallint DEFAULT 0 NOT NULL,
    image_v432x230 character varying(255)
);

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

ALTER SEQUENCE design_management_designs_versions_id_seq OWNED BY design_management_designs_versions.id;

CREATE TABLE design_management_repositories (
    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,
    namespace_id bigint
);

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

ALTER SEQUENCE design_management_repositories_id_seq OWNED BY design_management_repositories.id;

CREATE TABLE design_management_repository_states (
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    design_management_repository_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint DEFAULT 0 NOT NULL,
    verification_checksum bytea,
    verification_failure text,
    CONSTRAINT check_bf1387c28b CHECK ((char_length(verification_failure) <= 255))
);

CREATE TABLE design_management_versions (
    id bigint NOT NULL,
    sha bytea NOT NULL,
    issue_id bigint,
    created_at timestamp with time zone NOT NULL,
    author_id bigint,
    namespace_id bigint
);

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

ALTER SEQUENCE design_management_versions_id_seq OWNED BY design_management_versions.id;

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

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

ALTER SEQUENCE design_user_mentions_id_seq OWNED BY design_user_mentions.id;

CREATE TABLE detached_partitions (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    drop_after timestamp with time zone NOT NULL,
    table_name text NOT NULL,
    CONSTRAINT check_aecee24ba3 CHECK ((char_length(table_name) <= 63))
);

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

ALTER SEQUENCE detached_partitions_id_seq OWNED BY detached_partitions.id;

CREATE TABLE diff_note_positions (
    id bigint NOT NULL,
    note_id bigint NOT NULL,
    old_line integer,
    new_line integer,
    diff_content_type smallint NOT NULL,
    diff_type smallint NOT NULL,
    line_code character varying(255) NOT NULL,
    base_sha bytea NOT NULL,
    start_sha bytea NOT NULL,
    head_sha bytea NOT NULL,
    old_path text NOT NULL,
    new_path text NOT NULL
);

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

ALTER SEQUENCE diff_note_positions_id_seq OWNED BY diff_note_positions.id;

CREATE TABLE dingtalk_tracker_data (
    id bigint NOT NULL,
    integration_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    corpid text,
    CONSTRAINT check_d3fe332e6a CHECK ((char_length(corpid) <= 255))
);

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

COMMENT ON COLUMN dingtalk_tracker_data.integration_id IS 'JiHu-specific column';

COMMENT ON COLUMN dingtalk_tracker_data.corpid IS 'JiHu-specific column';

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

ALTER SEQUENCE dingtalk_tracker_data_id_seq OWNED BY dingtalk_tracker_data.id;

CREATE TABLE dora_configurations (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    branches_for_lead_time_for_changes text[] DEFAULT '{}'::text[] NOT NULL
);

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

ALTER SEQUENCE dora_configurations_id_seq OWNED BY dora_configurations.id;

CREATE TABLE dora_daily_metrics (
    id bigint NOT NULL,
    environment_id bigint NOT NULL,
    date date NOT NULL,
    deployment_frequency integer,
    lead_time_for_changes_in_seconds integer,
    time_to_restore_service_in_seconds integer,
    incidents_count integer,
    project_id bigint,
    CONSTRAINT dora_daily_metrics_deployment_frequency_positive CHECK ((deployment_frequency >= 0)),
    CONSTRAINT dora_daily_metrics_lead_time_for_changes_in_seconds_positive CHECK ((lead_time_for_changes_in_seconds >= 0))
);

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

ALTER SEQUENCE dora_daily_metrics_id_seq OWNED BY dora_daily_metrics.id;

CREATE TABLE dora_performance_scores (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    date date NOT NULL,
    deployment_frequency smallint,
    lead_time_for_changes smallint,
    time_to_restore_service smallint,
    change_failure_rate smallint
);

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

ALTER SEQUENCE dora_performance_scores_id_seq OWNED BY dora_performance_scores.id;

CREATE TABLE draft_notes (
    id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    author_id bigint NOT NULL,
    resolve_discussion boolean DEFAULT false NOT NULL,
    discussion_id character varying,
    note text NOT NULL,
    "position" text,
    original_position text,
    change_position text,
    commit_id bytea,
    line_code text,
    internal boolean DEFAULT false NOT NULL,
    note_type smallint,
    project_id bigint,
    CONSTRAINT check_c497a94a0e CHECK ((char_length(line_code) <= 255))
);

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

ALTER SEQUENCE draft_notes_id_seq OWNED BY draft_notes.id;

CREATE TABLE duo_workflows_checkpoints (
    id bigint NOT NULL,
    workflow_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,
    thread_ts text NOT NULL,
    parent_ts text,
    checkpoint jsonb NOT NULL,
    metadata jsonb NOT NULL,
    CONSTRAINT check_3dcc551d16 CHECK ((char_length(parent_ts) <= 255)),
    CONSTRAINT check_5d3139b983 CHECK ((char_length(thread_ts) <= 255))
);

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

ALTER SEQUENCE duo_workflows_checkpoints_id_seq OWNED BY duo_workflows_checkpoints.id;

CREATE TABLE duo_workflows_events (
    id bigint NOT NULL,
    workflow_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,
    event_type smallint NOT NULL,
    event_status smallint NOT NULL,
    message text,
    CONSTRAINT check_d96965e118 CHECK ((char_length(message) <= 255))
);

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

ALTER SEQUENCE duo_workflows_events_id_seq OWNED BY duo_workflows_events.id;

CREATE TABLE duo_workflows_workflows (
    id bigint NOT NULL,
    user_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 0 NOT NULL,
    goal text,
    agent_privileges smallint[] DEFAULT '{1,2}'::smallint[] NOT NULL,
    CONSTRAINT check_5aedde451d CHECK ((char_length(goal) <= 4096))
);

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

ALTER SEQUENCE duo_workflows_workflows_id_seq OWNED BY duo_workflows_workflows.id;

CREATE TABLE early_access_program_tracking_events (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    event_name text NOT NULL,
    event_label text,
    category text,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    CONSTRAINT check_4faf711d09 CHECK ((char_length(event_label) <= 255)),
    CONSTRAINT check_573cf46c14 CHECK ((char_length(event_name) <= 255)),
    CONSTRAINT check_e631e07806 CHECK ((char_length(category) <= 255))
);

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

ALTER SEQUENCE early_access_program_tracking_events_id_seq OWNED BY early_access_program_tracking_events.id;

CREATE TABLE elastic_group_index_statuses (
    namespace_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    wiki_indexed_at timestamp with time zone,
    last_wiki_commit bytea
);

CREATE TABLE elastic_index_settings (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    number_of_replicas smallint DEFAULT 1 NOT NULL,
    number_of_shards smallint DEFAULT 5 NOT NULL,
    alias_name text NOT NULL,
    CONSTRAINT check_c30005c325 CHECK ((char_length(alias_name) <= 255))
);

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

ALTER SEQUENCE elastic_index_settings_id_seq OWNED BY elastic_index_settings.id;

CREATE TABLE elastic_reindexing_slices (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    elastic_reindexing_subtask_id bigint NOT NULL,
    elastic_slice smallint DEFAULT 0 NOT NULL,
    elastic_max_slice smallint DEFAULT 0 NOT NULL,
    retry_attempt smallint DEFAULT 0 NOT NULL,
    elastic_task text,
    CONSTRAINT check_ca30e1396e CHECK ((char_length(elastic_task) <= 255))
);

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

ALTER SEQUENCE elastic_reindexing_slices_id_seq OWNED BY elastic_reindexing_slices.id;

CREATE TABLE elastic_reindexing_subtasks (
    id bigint NOT NULL,
    elastic_reindexing_task_id bigint NOT NULL,
    alias_name text NOT NULL,
    index_name_from text NOT NULL,
    index_name_to text NOT NULL,
    elastic_task text,
    documents_count_target integer,
    documents_count integer,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    CONSTRAINT check_4910adc798 CHECK ((char_length(elastic_task) <= 255)),
    CONSTRAINT check_88f56216a4 CHECK ((char_length(alias_name) <= 255)),
    CONSTRAINT check_a1fbd9faa9 CHECK ((char_length(index_name_from) <= 255)),
    CONSTRAINT check_f456494bd8 CHECK ((char_length(index_name_to) <= 255))
);

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

ALTER SEQUENCE elastic_reindexing_subtasks_id_seq OWNED BY elastic_reindexing_subtasks.id;

CREATE TABLE elastic_reindexing_tasks (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    state smallint DEFAULT 0 NOT NULL,
    in_progress boolean DEFAULT true NOT NULL,
    error_message text,
    delete_original_index_at timestamp with time zone,
    max_slices_running smallint DEFAULT 60 NOT NULL,
    slice_multiplier smallint DEFAULT 2 NOT NULL,
    targets text[],
    options jsonb DEFAULT '{}'::jsonb NOT NULL,
    CONSTRAINT check_7f64acda8e CHECK ((char_length(error_message) <= 255))
);

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

ALTER SEQUENCE elastic_reindexing_tasks_id_seq OWNED BY elastic_reindexing_tasks.id;

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

CREATE TABLE elasticsearch_indexed_projects (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL
);

CREATE TABLE emails (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    email character varying NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    confirmation_token character varying,
    confirmed_at timestamp without time zone,
    confirmation_sent_at timestamp without time zone,
    detumbled_email text,
    CONSTRAINT check_319f6999dc CHECK ((char_length(detumbled_email) <= 255))
);

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

ALTER SEQUENCE emails_id_seq OWNED BY emails.id;

CREATE TABLE environments (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    name character varying NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    external_url character varying,
    environment_type character varying,
    state character varying DEFAULT 'available'::character varying NOT NULL,
    slug character varying NOT NULL,
    auto_stop_at timestamp with time zone,
    auto_delete_at timestamp with time zone,
    tier smallint,
    merge_request_id bigint,
    cluster_agent_id bigint,
    kubernetes_namespace text,
    flux_resource_path text,
    description text,
    description_html text,
    cached_markdown_version integer,
    CONSTRAINT check_23b1eb18a2 CHECK ((char_length(flux_resource_path) <= 255)),
    CONSTRAINT check_ad5e1ed5e1 CHECK ((char_length(description) <= 10000)),
    CONSTRAINT check_b5373a1804 CHECK ((char_length(kubernetes_namespace) <= 63)),
    CONSTRAINT check_d26221226f CHECK ((char_length(description_html) <= 50000))
);

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

ALTER SEQUENCE environments_id_seq OWNED BY environments.id;

CREATE TABLE epic_issues (
    id bigint NOT NULL,
    epic_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    relative_position integer,
    namespace_id bigint,
    work_item_parent_link_id bigint
);

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

ALTER SEQUENCE epic_issues_id_seq OWNED BY epic_issues.id;

CREATE TABLE epic_metrics (
    id bigint NOT NULL,
    epic_id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE epic_metrics_id_seq OWNED BY epic_metrics.id;

CREATE TABLE epic_user_mentions (
    id bigint NOT NULL,
    epic_id bigint NOT NULL,
    mentioned_users_ids bigint[],
    mentioned_projects_ids bigint[],
    mentioned_groups_ids bigint[],
    note_id bigint,
    group_id bigint
);

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

ALTER SEQUENCE epic_user_mentions_id_seq OWNED BY epic_user_mentions.id;

CREATE TABLE epics (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    author_id bigint NOT NULL,
    assignee_id bigint,
    iid integer NOT NULL,
    cached_markdown_version integer,
    updated_by_id bigint,
    last_edited_by_id bigint,
    lock_version integer DEFAULT 0,
    start_date date,
    end_date date,
    last_edited_at timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    title character varying NOT NULL,
    title_html character varying NOT NULL,
    description text,
    description_html text,
    start_date_sourcing_milestone_id bigint,
    due_date_sourcing_milestone_id bigint,
    start_date_fixed date,
    due_date_fixed date,
    start_date_is_fixed boolean,
    due_date_is_fixed boolean,
    closed_by_id bigint,
    closed_at timestamp without time zone,
    parent_id bigint,
    relative_position integer,
    state_id smallint DEFAULT 1 NOT NULL,
    start_date_sourcing_epic_id bigint,
    due_date_sourcing_epic_id bigint,
    confidential boolean DEFAULT false NOT NULL,
    external_key character varying(255),
    color text DEFAULT '#1068bf'::text,
    total_opened_issue_weight integer DEFAULT 0 NOT NULL,
    total_closed_issue_weight integer DEFAULT 0 NOT NULL,
    total_opened_issue_count integer DEFAULT 0 NOT NULL,
    total_closed_issue_count integer DEFAULT 0 NOT NULL,
    issue_id bigint,
    imported smallint DEFAULT 0 NOT NULL,
    imported_from smallint DEFAULT 0 NOT NULL,
    work_item_parent_link_id bigint,
    CONSTRAINT check_450724d1bb CHECK ((issue_id IS NOT NULL)),
    CONSTRAINT check_ca608c40b3 CHECK ((char_length(color) <= 7)),
    CONSTRAINT check_fcfb4a93ff CHECK ((lock_version IS NOT NULL))
);

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

ALTER SEQUENCE epics_id_seq OWNED BY epics.id;

CREATE TABLE error_tracking_client_keys (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    active boolean DEFAULT true NOT NULL,
    public_key text NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    CONSTRAINT check_840b719790 CHECK ((char_length(public_key) <= 255))
);

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

ALTER SEQUENCE error_tracking_client_keys_id_seq OWNED BY error_tracking_client_keys.id;

CREATE TABLE error_tracking_error_events (
    id bigint NOT NULL,
    error_id bigint NOT NULL,
    description text NOT NULL,
    environment text,
    level text,
    occurred_at timestamp with time zone NOT NULL,
    payload jsonb DEFAULT '{}'::jsonb NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint,
    CONSTRAINT check_92ecc3077b CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_c67d5b8007 CHECK ((char_length(level) <= 255)),
    CONSTRAINT check_f4b52474ad CHECK ((char_length(environment) <= 255))
);

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

ALTER SEQUENCE error_tracking_error_events_id_seq OWNED BY error_tracking_error_events.id;

CREATE TABLE error_tracking_errors (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    name text NOT NULL,
    description text NOT NULL,
    actor text NOT NULL,
    first_seen_at timestamp with time zone DEFAULT now() NOT NULL,
    last_seen_at timestamp with time zone DEFAULT now() NOT NULL,
    platform text,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    events_count bigint DEFAULT 0 NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    CONSTRAINT check_18a758e537 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_b5cb4d3888 CHECK ((char_length(actor) <= 255)),
    CONSTRAINT check_c739788b12 CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_fe99886883 CHECK ((char_length(platform) <= 255))
);

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

ALTER SEQUENCE error_tracking_errors_id_seq OWNED BY error_tracking_errors.id;

CREATE TABLE events (
    project_id bigint,
    author_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    action smallint NOT NULL,
    target_type character varying,
    group_id bigint,
    fingerprint bytea,
    id bigint NOT NULL,
    target_id bigint,
    imported_from smallint DEFAULT 0 NOT NULL,
    personal_namespace_id bigint,
    CONSTRAINT check_97e06e05ad CHECK ((octet_length(fingerprint) <= 128))
);

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

ALTER SEQUENCE events_id_seq OWNED BY events.id;

CREATE TABLE evidences (
    id bigint NOT NULL,
    release_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    summary_sha bytea,
    summary jsonb DEFAULT '{}'::jsonb NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE evidences_id_seq OWNED BY evidences.id;

CREATE TABLE external_approval_rules (
    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,
    external_url text NOT NULL,
    name text NOT NULL,
    CONSTRAINT check_1c64b53ea5 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_b634ca168d CHECK ((char_length(external_url) <= 255))
);

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

ALTER SEQUENCE external_approval_rules_id_seq OWNED BY external_approval_rules.id;

CREATE TABLE external_pull_requests (
    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,
    pull_request_iid integer NOT NULL,
    status smallint NOT NULL,
    source_branch character varying(255) NOT NULL,
    target_branch character varying(255) NOT NULL,
    source_repository character varying(255) NOT NULL,
    target_repository character varying(255) NOT NULL,
    source_sha bytea NOT NULL,
    target_sha bytea NOT NULL
);

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

ALTER SEQUENCE external_pull_requests_id_seq OWNED BY external_pull_requests.id;

CREATE TABLE external_status_checks (
    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,
    external_url text NOT NULL,
    name text NOT NULL,
    encrypted_shared_secret bytea,
    encrypted_shared_secret_iv bytea,
    CONSTRAINT check_7e3b9eb41a CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_ae0dec3f61 CHECK ((char_length(external_url) <= 255))
);

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

ALTER SEQUENCE external_status_checks_id_seq OWNED BY external_status_checks.id;

CREATE TABLE external_status_checks_protected_branches (
    id bigint NOT NULL,
    external_status_check_id bigint NOT NULL,
    protected_branch_id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE external_status_checks_protected_branches_id_seq OWNED BY external_status_checks_protected_branches.id;

CREATE TABLE feature_gates (
    id bigint NOT NULL,
    feature_key character varying NOT NULL,
    key character varying NOT NULL,
    value character varying,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE feature_gates_id_seq OWNED BY feature_gates.id;

CREATE TABLE features (
    id bigint NOT NULL,
    key character varying NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE features_id_seq OWNED BY features.id;

CREATE TABLE fork_network_members (
    id bigint NOT NULL,
    fork_network_id bigint NOT NULL,
    project_id bigint NOT NULL,
    forked_from_project_id bigint
);

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

ALTER SEQUENCE fork_network_members_id_seq OWNED BY fork_network_members.id;

CREATE TABLE fork_networks (
    id bigint NOT NULL,
    root_project_id bigint,
    deleted_root_project_name character varying
);

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

ALTER SEQUENCE fork_networks_id_seq OWNED BY fork_networks.id;

CREATE TABLE geo_cache_invalidation_events (
    id bigint NOT NULL,
    key character varying NOT NULL
);

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

ALTER SEQUENCE geo_cache_invalidation_events_id_seq OWNED BY geo_cache_invalidation_events.id;

CREATE TABLE geo_event_log (
    id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    repositories_changed_event_id bigint,
    cache_invalidation_event_id bigint,
    geo_event_id_convert_to_bigint integer,
    geo_event_id bigint
);

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

ALTER SEQUENCE geo_event_log_id_seq OWNED BY geo_event_log.id;

CREATE TABLE geo_events (
    id bigint NOT NULL,
    replicable_name character varying(255) NOT NULL,
    event_name character varying(255) NOT NULL,
    payload jsonb DEFAULT '{}'::jsonb NOT NULL,
    created_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE geo_events_id_seq OWNED BY geo_events.id;

CREATE TABLE geo_node_namespace_links (
    id bigint NOT NULL,
    geo_node_id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE geo_node_namespace_links_id_seq OWNED BY geo_node_namespace_links.id;

CREATE TABLE geo_node_statuses (
    id bigint NOT NULL,
    geo_node_id bigint NOT NULL,
    db_replication_lag_seconds integer,
    last_event_id bigint,
    last_event_date timestamp without time zone,
    cursor_last_event_id bigint,
    cursor_last_event_date timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    last_successful_status_check_at timestamp without time zone,
    status_message character varying,
    replication_slots_count integer,
    replication_slots_used_count integer,
    replication_slots_max_retained_wal_bytes bigint,
    version character varying,
    revision character varying,
    storage_configuration_digest bytea,
    projects_count integer,
    status jsonb DEFAULT '{}'::jsonb NOT NULL
);

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

ALTER SEQUENCE geo_node_statuses_id_seq OWNED BY geo_node_statuses.id;

CREATE TABLE geo_nodes (
    id bigint NOT NULL,
    "primary" boolean DEFAULT false NOT NULL,
    oauth_application_id bigint,
    enabled boolean DEFAULT true NOT NULL,
    access_key character varying,
    encrypted_secret_access_key character varying,
    encrypted_secret_access_key_iv character varying,
    clone_url_prefix character varying,
    files_max_capacity integer DEFAULT 10 NOT NULL,
    repos_max_capacity integer DEFAULT 25 NOT NULL,
    url character varying NOT NULL,
    selective_sync_type character varying,
    selective_sync_shards text,
    verification_max_capacity integer DEFAULT 100 NOT NULL,
    minimum_reverification_interval integer DEFAULT 7 NOT NULL,
    internal_url character varying,
    name character varying NOT NULL,
    container_repositories_max_capacity integer DEFAULT 10 NOT NULL,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    sync_object_storage boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE geo_nodes_id_seq OWNED BY geo_nodes.id;

CREATE TABLE ghost_user_migrations (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    initiator_user_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    hard_delete boolean DEFAULT false NOT NULL,
    consume_after timestamp with time zone DEFAULT now() NOT NULL
);

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

ALTER SEQUENCE ghost_user_migrations_id_seq OWNED BY ghost_user_migrations.id;

CREATE TABLE gitlab_subscription_histories (
    id bigint NOT NULL,
    gitlab_subscription_created_at timestamp with time zone,
    gitlab_subscription_updated_at timestamp with time zone,
    start_date date,
    end_date date,
    trial_ends_on date,
    namespace_id bigint,
    hosted_plan_id bigint,
    max_seats_used integer,
    seats integer,
    trial boolean,
    change_type smallint,
    gitlab_subscription_id bigint NOT NULL,
    created_at timestamp with time zone,
    trial_starts_on date,
    auto_renew boolean,
    trial_extension_type smallint,
    seats_in_use integer,
    CONSTRAINT check_6d5f27a106 CHECK ((namespace_id IS NOT NULL))
);

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

ALTER SEQUENCE gitlab_subscription_histories_id_seq OWNED BY gitlab_subscription_histories.id;

CREATE TABLE gitlab_subscriptions (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    start_date date,
    end_date date,
    trial_ends_on date,
    namespace_id bigint,
    hosted_plan_id bigint,
    max_seats_used integer DEFAULT 0,
    seats integer DEFAULT 0,
    trial boolean DEFAULT false,
    trial_starts_on date,
    auto_renew boolean,
    seats_in_use integer DEFAULT 0 NOT NULL,
    seats_owed integer DEFAULT 0 NOT NULL,
    trial_extension_type smallint,
    max_seats_used_changed_at timestamp with time zone,
    last_seat_refresh_at timestamp with time zone,
    CONSTRAINT check_77fea3f0e7 CHECK ((namespace_id IS NOT NULL))
);

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

ALTER SEQUENCE gitlab_subscriptions_id_seq OWNED BY gitlab_subscriptions.id;

CREATE TABLE gpg_key_subkeys (
    id bigint NOT NULL,
    gpg_key_id bigint NOT NULL,
    keyid bytea,
    fingerprint bytea
);

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

ALTER SEQUENCE gpg_key_subkeys_id_seq OWNED BY gpg_key_subkeys.id;

CREATE TABLE gpg_keys (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    user_id bigint,
    primary_keyid bytea,
    fingerprint bytea,
    key text,
    externally_verified boolean DEFAULT false NOT NULL,
    externally_verified_at timestamp with time zone
);

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

ALTER SEQUENCE gpg_keys_id_seq OWNED BY gpg_keys.id;

CREATE TABLE gpg_signatures (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint,
    gpg_key_id bigint,
    commit_sha bytea,
    gpg_key_primary_keyid bytea,
    gpg_key_user_name text,
    gpg_key_user_email text,
    verification_status smallint DEFAULT 0 NOT NULL,
    gpg_key_subkey_id bigint
);

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

ALTER SEQUENCE gpg_signatures_id_seq OWNED BY gpg_signatures.id;

CREATE TABLE grafana_integrations (
    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,
    encrypted_token character varying(255) NOT NULL,
    encrypted_token_iv character varying(255) NOT NULL,
    grafana_url character varying(1024) NOT NULL,
    enabled boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE grafana_integrations_id_seq OWNED BY grafana_integrations.id;

CREATE TABLE group_crm_settings (
    group_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    enabled boolean DEFAULT true NOT NULL,
    source_group_id bigint
);

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

ALTER SEQUENCE group_crm_settings_group_id_seq OWNED BY group_crm_settings.group_id;

CREATE TABLE group_custom_attributes (
    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,
    key character varying NOT NULL,
    value character varying NOT NULL
);

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

ALTER SEQUENCE group_custom_attributes_id_seq OWNED BY group_custom_attributes.id;

CREATE TABLE group_deletion_schedules (
    group_id bigint NOT NULL,
    user_id bigint NOT NULL,
    marked_for_deletion_on date NOT NULL
);

CREATE TABLE group_deploy_keys (
    id bigint NOT NULL,
    user_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    last_used_at timestamp with time zone,
    expires_at timestamp with time zone,
    key text NOT NULL,
    title text,
    fingerprint text,
    fingerprint_sha256 bytea,
    CONSTRAINT check_cc0365908d CHECK ((char_length(title) <= 255)),
    CONSTRAINT check_e4526dcf91 CHECK ((char_length(fingerprint) <= 255)),
    CONSTRAINT check_f58fa0a0f7 CHECK ((char_length(key) <= 4096))
);

CREATE TABLE group_deploy_keys_groups (
    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,
    group_deploy_key_id bigint NOT NULL,
    can_push boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE group_deploy_keys_groups_id_seq OWNED BY group_deploy_keys_groups.id;

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

ALTER SEQUENCE group_deploy_keys_id_seq OWNED BY group_deploy_keys.id;

CREATE TABLE group_deploy_tokens (
    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,
    deploy_token_id bigint NOT NULL
);

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

ALTER SEQUENCE group_deploy_tokens_id_seq OWNED BY group_deploy_tokens.id;

CREATE TABLE group_features (
    group_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    wiki_access_level smallint DEFAULT 20 NOT NULL
);

CREATE TABLE group_group_links (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    shared_group_id bigint NOT NULL,
    shared_with_group_id bigint NOT NULL,
    expires_at date,
    group_access smallint DEFAULT 30 NOT NULL,
    member_role_id bigint
);

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

ALTER SEQUENCE group_group_links_id_seq OWNED BY group_group_links.id;

CREATE TABLE group_import_states (
    group_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,
    jid text,
    last_error text,
    user_id bigint,
    CONSTRAINT check_87b58f6b30 CHECK ((char_length(last_error) <= 255)),
    CONSTRAINT check_96558fff96 CHECK ((char_length(jid) <= 100))
);

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

ALTER SEQUENCE group_import_states_group_id_seq OWNED BY group_import_states.group_id;

CREATE TABLE group_merge_request_approval_settings (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    group_id bigint NOT NULL,
    allow_author_approval boolean DEFAULT false NOT NULL,
    allow_committer_approval boolean DEFAULT false NOT NULL,
    allow_overrides_to_approver_list_per_merge_request boolean DEFAULT false NOT NULL,
    retain_approvals_on_push boolean DEFAULT false NOT NULL,
    require_password_to_approve boolean DEFAULT false NOT NULL,
    require_saml_auth_to_approve boolean DEFAULT false NOT NULL,
    require_reauthentication_to_approve boolean DEFAULT false NOT NULL
);

CREATE TABLE group_repository_storage_moves (
    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,
    state smallint DEFAULT 1 NOT NULL,
    source_storage_name text NOT NULL,
    destination_storage_name text NOT NULL,
    error_message text,
    CONSTRAINT check_266d0cf596 CHECK ((char_length(error_message) <= 256)),
    CONSTRAINT group_repository_storage_moves_destination_storage_name CHECK ((char_length(destination_storage_name) <= 255)),
    CONSTRAINT group_repository_storage_moves_source_storage_name CHECK ((char_length(source_storage_name) <= 255))
);

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

ALTER SEQUENCE group_repository_storage_moves_id_seq OWNED BY group_repository_storage_moves.id;

CREATE TABLE group_saved_replies (
    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,
    name text NOT NULL,
    content text NOT NULL,
    CONSTRAINT check_13510378d3 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_4a96378d43 CHECK ((char_length(content) <= 10000))
);

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

ALTER SEQUENCE group_saved_replies_id_seq OWNED BY group_saved_replies.id;

CREATE TABLE group_scim_auth_access_tokens (
    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,
    temp_source_id bigint,
    token_encrypted bytea NOT NULL
);

COMMENT ON COLUMN group_scim_auth_access_tokens.temp_source_id IS 'Temporary column to store scim_tokens id';

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

ALTER SEQUENCE group_scim_auth_access_tokens_id_seq OWNED BY group_scim_auth_access_tokens.id;

CREATE TABLE group_scim_identities (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    temp_source_id bigint,
    active boolean DEFAULT false,
    extern_uid text NOT NULL,
    CONSTRAINT check_53de3ba272 CHECK ((char_length(extern_uid) <= 255))
);

COMMENT ON COLUMN group_scim_identities.temp_source_id IS 'Temporary column to store scim_idenity id';

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

ALTER SEQUENCE group_scim_identities_id_seq OWNED BY group_scim_identities.id;

CREATE TABLE group_security_exclusions (
    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,
    scanner smallint NOT NULL,
    type smallint NOT NULL,
    active boolean DEFAULT true NOT NULL,
    description text,
    value text NOT NULL,
    CONSTRAINT check_12e9b59302 CHECK ((char_length(description) <= 255)),
    CONSTRAINT check_45d9a8e422 CHECK ((char_length(value) <= 255))
);

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

ALTER SEQUENCE group_security_exclusions_id_seq OWNED BY group_security_exclusions.id;

CREATE TABLE group_ssh_certificates (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    fingerprint bytea NOT NULL,
    title text NOT NULL,
    key text NOT NULL,
    CONSTRAINT check_480296705f CHECK ((char_length(title) <= 256)),
    CONSTRAINT check_6c1d920167 CHECK ((char_length(key) <= 524288))
);

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

ALTER SEQUENCE group_ssh_certificates_id_seq OWNED BY group_ssh_certificates.id;

CREATE TABLE group_type_ci_runner_machines_687967fa8a (
    id bigint NOT NULL,
    runner_id bigint NOT NULL,
    sharding_key_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    contacted_at timestamp with time zone,
    creation_state smallint DEFAULT 0 NOT NULL,
    executor_type smallint,
    runner_type smallint NOT NULL,
    config jsonb DEFAULT '{}'::jsonb NOT NULL,
    system_xid text NOT NULL,
    platform text,
    architecture text,
    revision text,
    ip_address text,
    version text,
    CONSTRAINT check_3d8736b3af CHECK ((char_length(system_xid) <= 64)),
    CONSTRAINT check_5bad2a6944 CHECK ((char_length(revision) <= 255)),
    CONSTRAINT check_7dc4eee8a5 CHECK ((char_length(version) <= 2048)),
    CONSTRAINT check_b1e456641b CHECK ((char_length(ip_address) <= 1024)),
    CONSTRAINT check_c788f4b18a CHECK ((char_length(platform) <= 255)),
    CONSTRAINT check_f3d25ab844 CHECK ((char_length(architecture) <= 255)),
    CONSTRAINT check_sharding_key_id_nullness CHECK ((sharding_key_id IS NOT NULL))
);

CREATE TABLE group_type_ci_runners_e59bb2812d (
    id bigint NOT NULL,
    creator_id bigint,
    sharding_key_id bigint,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    contacted_at timestamp with time zone,
    token_expires_at timestamp with time zone,
    public_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    access_level integer DEFAULT 0 NOT NULL,
    maximum_timeout integer,
    runner_type smallint NOT NULL,
    registration_type smallint DEFAULT 0 NOT NULL,
    creation_state smallint DEFAULT 0 NOT NULL,
    active boolean DEFAULT true NOT NULL,
    run_untagged boolean DEFAULT true NOT NULL,
    locked boolean DEFAULT false NOT NULL,
    name text,
    token_encrypted text,
    token text,
    description text,
    maintainer_note text,
    allowed_plans text[] DEFAULT '{}'::text[] NOT NULL,
    allowed_plan_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL,
    CONSTRAINT check_1f8618ab23 CHECK ((char_length(name) <= 256)),
    CONSTRAINT check_24b281f5bf CHECK ((char_length(maintainer_note) <= 1024)),
    CONSTRAINT check_31c16b2a99 CHECK ((char_length(token_encrypted) <= 128)),
    CONSTRAINT check_5db8ae9d30 CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_af25130d5a CHECK ((char_length(token) <= 128)),
    CONSTRAINT check_sharding_key_id_nullness CHECK ((sharding_key_id IS NOT NULL))
);

CREATE TABLE group_wiki_repositories (
    shard_id bigint NOT NULL,
    group_id bigint NOT NULL,
    disk_path text NOT NULL,
    CONSTRAINT check_07f1c81806 CHECK ((char_length(disk_path) <= 80))
);

CREATE TABLE group_wiki_repository_states (
    id bigint NOT NULL,
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    group_wiki_repository_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint DEFAULT 0 NOT NULL,
    verification_checksum bytea,
    verification_failure text,
    CONSTRAINT check_14d288436d CHECK ((char_length(verification_failure) <= 255))
);

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

ALTER SEQUENCE group_wiki_repository_states_id_seq OWNED BY group_wiki_repository_states.id;

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

ALTER SEQUENCE groups_visits_id_seq OWNED BY groups_visits.id;

CREATE TABLE historical_data (
    id bigint NOT NULL,
    date date,
    active_user_count integer,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    recorded_at timestamp with time zone,
    CONSTRAINT check_640e8cf66c CHECK ((recorded_at IS NOT NULL))
);

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

ALTER SEQUENCE historical_data_id_seq OWNED BY historical_data.id;

CREATE TABLE identities (
    id bigint NOT NULL,
    extern_uid character varying,
    provider character varying,
    user_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    secondary_extern_uid character varying,
    saml_provider_id bigint,
    trusted_extern_uid boolean DEFAULT true
);

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

ALTER SEQUENCE identities_id_seq OWNED BY identities.id;

CREATE TABLE import_export_uploads (
    id bigint NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint,
    import_file text,
    export_file text,
    group_id bigint,
    remote_import_url text,
    user_id bigint,
    CONSTRAINT check_58f0d37481 CHECK ((char_length(remote_import_url) <= 2048)),
    CONSTRAINT check_e54579866d CHECK ((num_nonnulls(group_id, project_id) = 1))
);

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

ALTER SEQUENCE import_export_uploads_id_seq OWNED BY import_export_uploads.id;

CREATE TABLE import_failures (
    id bigint NOT NULL,
    relation_index integer,
    project_id bigint,
    created_at timestamp with time zone NOT NULL,
    relation_key character varying(64),
    exception_class character varying(128),
    correlation_id_value character varying(128),
    exception_message character varying(255),
    retry_count integer,
    group_id bigint,
    source character varying(128),
    external_identifiers jsonb DEFAULT '{}'::jsonb NOT NULL,
    user_id bigint
);

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

ALTER SEQUENCE import_failures_id_seq OWNED BY import_failures.id;

CREATE TABLE import_placeholder_memberships (
    id bigint NOT NULL,
    source_user_id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    group_id bigint,
    project_id bigint,
    created_at timestamp with time zone NOT NULL,
    expires_at date,
    access_level smallint NOT NULL
);

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

ALTER SEQUENCE import_placeholder_memberships_id_seq OWNED BY import_placeholder_memberships.id;

CREATE TABLE import_source_user_placeholder_references (
    id bigint NOT NULL,
    source_user_id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    numeric_key bigint,
    created_at timestamp with time zone NOT NULL,
    model text NOT NULL,
    user_reference_column text NOT NULL,
    composite_key jsonb,
    alias_version smallint NOT NULL,
    CONSTRAINT check_782140eb9d CHECK ((char_length(user_reference_column) <= 50)),
    CONSTRAINT check_d17bd9dd4d CHECK ((char_length(model) <= 150))
);

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

ALTER SEQUENCE import_source_user_placeholder_references_id_seq OWNED BY import_source_user_placeholder_references.id;

CREATE TABLE import_source_users (
    id bigint NOT NULL,
    placeholder_user_id bigint,
    reassign_to_user_id bigint,
    namespace_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,
    source_username text,
    source_name text,
    source_user_identifier text NOT NULL,
    source_hostname text NOT NULL,
    import_type text NOT NULL,
    reassigned_by_user_id bigint,
    reassignment_error text,
    reassignment_token text,
    CONSTRAINT check_05708218cd CHECK ((char_length(reassignment_error) <= 255)),
    CONSTRAINT check_0d7295a307 CHECK ((char_length(import_type) <= 255)),
    CONSTRAINT check_199c28ec54 CHECK ((char_length(source_username) <= 255)),
    CONSTRAINT check_562655155f CHECK ((char_length(source_name) <= 255)),
    CONSTRAINT check_cc9d4093b5 CHECK ((char_length(source_user_identifier) <= 255)),
    CONSTRAINT check_cd2edb9334 CHECK ((char_length(reassignment_token) <= 32)),
    CONSTRAINT check_e2039840c5 CHECK ((char_length(source_hostname) <= 255))
);

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

ALTER SEQUENCE import_source_users_id_seq OWNED BY import_source_users.id;

CREATE TABLE incident_management_escalation_policies (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    name text NOT NULL,
    description text,
    CONSTRAINT check_510b2a5258 CHECK ((char_length(description) <= 160)),
    CONSTRAINT check_9a26365850 CHECK ((char_length(name) <= 72))
);

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

ALTER SEQUENCE incident_management_escalation_policies_id_seq OWNED BY incident_management_escalation_policies.id;

CREATE TABLE incident_management_escalation_rules (
    id bigint NOT NULL,
    policy_id bigint NOT NULL,
    oncall_schedule_id bigint,
    status smallint NOT NULL,
    elapsed_time_seconds integer NOT NULL,
    is_removed boolean DEFAULT false NOT NULL,
    user_id bigint,
    project_id bigint,
    CONSTRAINT escalation_rules_one_of_oncall_schedule_or_user CHECK ((num_nonnulls(oncall_schedule_id, user_id) = 1))
);

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

ALTER SEQUENCE incident_management_escalation_rules_id_seq OWNED BY incident_management_escalation_rules.id;

CREATE TABLE incident_management_issuable_escalation_statuses (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    issue_id bigint NOT NULL,
    policy_id bigint,
    escalations_started_at timestamp with time zone,
    resolved_at timestamp with time zone,
    status smallint DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE incident_management_issuable_escalation_statuses_id_seq OWNED BY incident_management_issuable_escalation_statuses.id;

CREATE TABLE incident_management_oncall_participants (
    id bigint NOT NULL,
    oncall_rotation_id bigint NOT NULL,
    user_id bigint NOT NULL,
    color_palette smallint NOT NULL,
    color_weight smallint NOT NULL,
    is_removed boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE incident_management_oncall_participants_id_seq OWNED BY incident_management_oncall_participants.id;

CREATE TABLE incident_management_oncall_rotations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    oncall_schedule_id bigint NOT NULL,
    length integer NOT NULL,
    length_unit smallint NOT NULL,
    starts_at timestamp with time zone NOT NULL,
    name text NOT NULL,
    ends_at timestamp with time zone,
    active_period_start time without time zone,
    active_period_end time without time zone,
    project_id bigint,
    CONSTRAINT check_5209fb5d02 CHECK ((char_length(name) <= 200))
);

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

ALTER SEQUENCE incident_management_oncall_rotations_id_seq OWNED BY incident_management_oncall_rotations.id;

CREATE TABLE incident_management_oncall_schedules (
    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,
    iid integer NOT NULL,
    name text NOT NULL,
    description text,
    timezone text,
    CONSTRAINT check_7ed1fd5aa7 CHECK ((char_length(description) <= 1000)),
    CONSTRAINT check_cc77cbb103 CHECK ((char_length(timezone) <= 100)),
    CONSTRAINT check_e6ef43a664 CHECK ((char_length(name) <= 200))
);

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

ALTER SEQUENCE incident_management_oncall_schedules_id_seq OWNED BY incident_management_oncall_schedules.id;

CREATE TABLE incident_management_oncall_shifts (
    id bigint NOT NULL,
    rotation_id bigint NOT NULL,
    participant_id bigint NOT NULL,
    starts_at timestamp with time zone NOT NULL,
    ends_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE incident_management_oncall_shifts_id_seq OWNED BY incident_management_oncall_shifts.id;

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

ALTER SEQUENCE incident_management_pending_alert_escalations_id_seq OWNED BY incident_management_pending_alert_escalations.id;

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

ALTER SEQUENCE incident_management_pending_issue_escalations_id_seq OWNED BY incident_management_pending_issue_escalations.id;

CREATE TABLE incident_management_timeline_event_tag_links (
    id bigint NOT NULL,
    timeline_event_id bigint NOT NULL,
    timeline_event_tag_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE incident_management_timeline_event_tag_links_id_seq OWNED BY incident_management_timeline_event_tag_links.id;

CREATE TABLE incident_management_timeline_event_tags (
    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_8717184e2c CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE incident_management_timeline_event_tags_id_seq OWNED BY incident_management_timeline_event_tags.id;

CREATE TABLE incident_management_timeline_events (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    occurred_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    author_id bigint,
    issue_id bigint NOT NULL,
    updated_by_user_id bigint,
    promoted_from_note_id bigint,
    cached_markdown_version integer,
    editable boolean DEFAULT false NOT NULL,
    note text NOT NULL,
    note_html text NOT NULL,
    action text NOT NULL,
    CONSTRAINT check_18fd072206 CHECK ((char_length(action) <= 128)),
    CONSTRAINT check_3875ed0aac CHECK ((char_length(note) <= 10000)),
    CONSTRAINT check_94a235d6a4 CHECK ((char_length(note_html) <= 10000))
);

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

ALTER SEQUENCE incident_management_timeline_events_id_seq OWNED BY incident_management_timeline_events.id;

CREATE TABLE index_statuses (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    indexed_at timestamp without time zone,
    note text,
    last_commit character varying,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    last_wiki_commit bytea,
    wiki_indexed_at timestamp with time zone
);

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

ALTER SEQUENCE index_statuses_id_seq OWNED BY index_statuses.id;

CREATE TABLE insights (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    project_id bigint NOT NULL
);

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

ALTER SEQUENCE insights_id_seq OWNED BY insights.id;

CREATE TABLE instance_audit_events_streaming_headers (
    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,
    key text NOT NULL,
    value text NOT NULL,
    active boolean DEFAULT true NOT NULL,
    CONSTRAINT check_d52adbbabb CHECK ((char_length(value) <= 255)),
    CONSTRAINT check_e92010d531 CHECK ((char_length(key) <= 255))
);

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

ALTER SEQUENCE instance_audit_events_streaming_headers_id_seq OWNED BY instance_audit_events_streaming_headers.id;

CREATE TABLE instance_integrations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    comment_detail integer,
    active boolean DEFAULT false NOT NULL,
    push_events boolean DEFAULT true,
    issues_events boolean DEFAULT true,
    merge_requests_events boolean DEFAULT true,
    tag_push_events boolean DEFAULT true,
    note_events boolean DEFAULT true NOT NULL,
    wiki_page_events boolean DEFAULT true,
    pipeline_events boolean DEFAULT false NOT NULL,
    confidential_issues_events boolean DEFAULT true NOT NULL,
    commit_events boolean DEFAULT true NOT NULL,
    job_events boolean DEFAULT false NOT NULL,
    confidential_note_events boolean DEFAULT true,
    deployment_events boolean DEFAULT false NOT NULL,
    comment_on_event_enabled boolean DEFAULT true NOT NULL,
    alert_events boolean,
    vulnerability_events boolean DEFAULT false NOT NULL,
    archive_trace_events boolean DEFAULT false NOT NULL,
    incident_events boolean DEFAULT false NOT NULL,
    group_mention_events boolean DEFAULT false NOT NULL,
    group_confidential_mention_events boolean DEFAULT false NOT NULL,
    category text DEFAULT 'common'::text,
    encrypted_properties bytea,
    encrypted_properties_iv bytea,
    project_id bigint,
    group_id bigint,
    inherit_from_id bigint,
    instance boolean DEFAULT true,
    type_new text,
    CONSTRAINT check_2f305455fe CHECK ((char_length(type_new) <= 255)),
    CONSTRAINT check_611836812c CHECK ((char_length(category) <= 255)),
    CONSTRAINT group_id_null_constraint CHECK ((group_id IS NULL)),
    CONSTRAINT inherit_from_id_null_constraint CHECK ((inherit_from_id IS NULL)),
    CONSTRAINT instance_is_true_constraint CHECK ((instance = true)),
    CONSTRAINT project_id_null_constraint CHECK ((project_id IS NULL))
);

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

ALTER SEQUENCE instance_integrations_id_seq OWNED BY instance_integrations.id;

CREATE TABLE instance_type_ci_runner_machines_687967fa8a (
    id bigint NOT NULL,
    runner_id bigint NOT NULL,
    sharding_key_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    contacted_at timestamp with time zone,
    creation_state smallint DEFAULT 0 NOT NULL,
    executor_type smallint,
    runner_type smallint NOT NULL,
    config jsonb DEFAULT '{}'::jsonb NOT NULL,
    system_xid text NOT NULL,
    platform text,
    architecture text,
    revision text,
    ip_address text,
    version text,
    CONSTRAINT check_3d8736b3af CHECK ((char_length(system_xid) <= 64)),
    CONSTRAINT check_5bad2a6944 CHECK ((char_length(revision) <= 255)),
    CONSTRAINT check_7dc4eee8a5 CHECK ((char_length(version) <= 2048)),
    CONSTRAINT check_b1e456641b CHECK ((char_length(ip_address) <= 1024)),
    CONSTRAINT check_c788f4b18a CHECK ((char_length(platform) <= 255)),
    CONSTRAINT check_f3d25ab844 CHECK ((char_length(architecture) <= 255)),
    CONSTRAINT check_sharding_key_id_nullness CHECK ((sharding_key_id IS NULL))
);

CREATE TABLE instance_type_ci_runners_e59bb2812d (
    id bigint NOT NULL,
    creator_id bigint,
    sharding_key_id bigint,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    contacted_at timestamp with time zone,
    token_expires_at timestamp with time zone,
    public_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL,
    access_level integer DEFAULT 0 NOT NULL,
    maximum_timeout integer,
    runner_type smallint NOT NULL,
    registration_type smallint DEFAULT 0 NOT NULL,
    creation_state smallint DEFAULT 0 NOT NULL,
    active boolean DEFAULT true NOT NULL,
    run_untagged boolean DEFAULT true NOT NULL,
    locked boolean DEFAULT false NOT NULL,
    name text,
    token_encrypted text,
    token text,
    description text,
    maintainer_note text,
    allowed_plans text[] DEFAULT '{}'::text[] NOT NULL,
    allowed_plan_ids bigint[] DEFAULT '{}'::bigint[] NOT NULL,
    CONSTRAINT check_1f8618ab23 CHECK ((char_length(name) <= 256)),
    CONSTRAINT check_24b281f5bf CHECK ((char_length(maintainer_note) <= 1024)),
    CONSTRAINT check_31c16b2a99 CHECK ((char_length(token_encrypted) <= 128)),
    CONSTRAINT check_5db8ae9d30 CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_af25130d5a CHECK ((char_length(token) <= 128)),
    CONSTRAINT check_sharding_key_id_nullness CHECK ((sharding_key_id IS NULL))
);

CREATE TABLE integrations (
    id bigint NOT NULL,
    project_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    active boolean DEFAULT false NOT NULL,
    push_events boolean DEFAULT true,
    issues_events boolean DEFAULT true,
    merge_requests_events boolean DEFAULT true,
    tag_push_events boolean DEFAULT true,
    note_events boolean DEFAULT true NOT NULL,
    category character varying DEFAULT 'common'::character varying NOT NULL,
    wiki_page_events boolean DEFAULT true,
    pipeline_events boolean DEFAULT false NOT NULL,
    confidential_issues_events boolean DEFAULT true NOT NULL,
    commit_events boolean DEFAULT true NOT NULL,
    job_events boolean DEFAULT false NOT NULL,
    confidential_note_events boolean DEFAULT true,
    deployment_events boolean DEFAULT false NOT NULL,
    comment_on_event_enabled boolean DEFAULT true NOT NULL,
    instance boolean DEFAULT false NOT NULL,
    comment_detail smallint,
    inherit_from_id bigint,
    alert_events boolean,
    group_id bigint,
    type_new text,
    vulnerability_events boolean DEFAULT false NOT NULL,
    archive_trace_events boolean DEFAULT false NOT NULL,
    encrypted_properties bytea,
    encrypted_properties_iv bytea,
    incident_events boolean DEFAULT false NOT NULL,
    group_mention_events boolean DEFAULT false NOT NULL,
    group_confidential_mention_events boolean DEFAULT false NOT NULL,
    CONSTRAINT check_a948a0aa7e CHECK ((char_length(type_new) <= 255))
);

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

ALTER SEQUENCE integrations_id_seq OWNED BY integrations.id;

CREATE TABLE internal_ids (
    id bigint NOT NULL,
    project_id bigint,
    usage integer NOT NULL,
    last_value integer NOT NULL,
    namespace_id bigint
);

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

ALTER SEQUENCE internal_ids_id_seq OWNED BY internal_ids.id;

CREATE TABLE ip_restrictions (
    id bigint NOT NULL,
    group_id bigint NOT NULL,
    range character varying NOT NULL
);

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

ALTER SEQUENCE ip_restrictions_id_seq OWNED BY ip_restrictions.id;

CREATE TABLE issuable_metric_images (
    id bigint NOT NULL,
    issue_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,
    CONSTRAINT check_3bc6d47661 CHECK ((char_length(url_text) <= 128)),
    CONSTRAINT check_5b3011e234 CHECK ((char_length(url) <= 255)),
    CONSTRAINT check_7ed527062f CHECK ((char_length(file) <= 255))
);

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

ALTER SEQUENCE issuable_metric_images_id_seq OWNED BY issuable_metric_images.id;

CREATE TABLE issuable_resource_links (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    link_text text,
    link text NOT NULL,
    link_type smallint DEFAULT 0 NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    is_unique boolean,
    CONSTRAINT check_67be6729db CHECK ((char_length(link) <= 2200)),
    CONSTRAINT check_b137147e0b CHECK ((char_length(link_text) <= 255))
);

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

ALTER SEQUENCE issuable_resource_links_id_seq OWNED BY issuable_resource_links.id;

CREATE TABLE issuable_severities (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    severity smallint DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE issuable_severities_id_seq OWNED BY issuable_severities.id;

CREATE TABLE issuable_slas (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    due_at timestamp with time zone NOT NULL,
    label_applied boolean DEFAULT false NOT NULL,
    issuable_closed boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE issuable_slas_id_seq OWNED BY issuable_slas.id;

CREATE TABLE issue_assignees (
    user_id bigint NOT NULL,
    issue_id bigint NOT NULL
);

CREATE TABLE issue_assignment_events (
    id bigint NOT NULL,
    user_id bigint,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    action smallint DEFAULT 1 NOT NULL
);

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

ALTER SEQUENCE issue_assignment_events_id_seq OWNED BY issue_assignment_events.id;

CREATE TABLE issue_customer_relations_contacts (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    contact_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE issue_customer_relations_contacts_id_seq OWNED BY issue_customer_relations_contacts.id;

CREATE TABLE issue_email_participants (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    email text NOT NULL,
    CONSTRAINT check_2c321d408d CHECK ((char_length(email) <= 255))
);

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

ALTER SEQUENCE issue_email_participants_id_seq OWNED BY issue_email_participants.id;

CREATE TABLE issue_emails (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    email_message_id text NOT NULL,
    CONSTRAINT check_5abf3e6aea CHECK ((char_length(email_message_id) <= 1000))
);

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

ALTER SEQUENCE issue_emails_id_seq OWNED BY issue_emails.id;

CREATE TABLE issue_links (
    id bigint NOT NULL,
    source_id bigint NOT NULL,
    target_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    link_type smallint DEFAULT 0 NOT NULL,
    namespace_id bigint
);

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

ALTER SEQUENCE issue_links_id_seq OWNED BY issue_links.id;

CREATE TABLE issue_metrics (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    first_mentioned_in_commit_at timestamp without time zone,
    first_associated_with_milestone_at timestamp without time zone,
    first_added_to_board_at timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE issue_metrics_id_seq OWNED BY issue_metrics.id;

CREATE TABLE issue_tracker_data (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    encrypted_project_url character varying,
    encrypted_project_url_iv character varying,
    encrypted_issues_url character varying,
    encrypted_issues_url_iv character varying,
    encrypted_new_issue_url character varying,
    encrypted_new_issue_url_iv character varying,
    integration_id bigint,
    CONSTRAINT check_7ca00cd891 CHECK ((integration_id IS NOT NULL))
);

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

ALTER SEQUENCE issue_tracker_data_id_seq OWNED BY issue_tracker_data.id;

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

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

ALTER SEQUENCE issue_user_mentions_id_seq OWNED BY issue_user_mentions.id;

CREATE TABLE issues (
    id bigint NOT NULL,
    title character varying,
    author_id bigint,
    project_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    description text,
    milestone_id bigint,
    iid integer,
    updated_by_id bigint,
    weight integer,
    confidential boolean DEFAULT false NOT NULL,
    due_date date,
    moved_to_id bigint,
    lock_version integer DEFAULT 0,
    title_html text,
    description_html text,
    time_estimate integer DEFAULT 0,
    relative_position integer,
    service_desk_reply_to character varying,
    cached_markdown_version integer,
    last_edited_at timestamp without time zone,
    last_edited_by_id bigint,
    discussion_locked boolean,
    closed_at timestamp with time zone,
    closed_by_id bigint,
    state_id smallint DEFAULT 1 NOT NULL,
    duplicated_to_id bigint,
    promoted_to_epic_id bigint,
    health_status smallint,
    external_key character varying(255),
    sprint_id bigint,
    blocking_issues_count integer DEFAULT 0 NOT NULL,
    upvotes_count integer DEFAULT 0 NOT NULL,
    work_item_type_id bigint,
    namespace_id bigint,
    start_date date,
    tmp_epic_id bigint,
    imported_from smallint DEFAULT 0 NOT NULL,
    correct_work_item_type_id bigint DEFAULT 0 NOT NULL,
    author_id_convert_to_bigint bigint,
    closed_by_id_convert_to_bigint bigint,
    duplicated_to_id_convert_to_bigint bigint,
    id_convert_to_bigint bigint DEFAULT 0 NOT NULL,
    last_edited_by_id_convert_to_bigint bigint,
    milestone_id_convert_to_bigint bigint,
    moved_to_id_convert_to_bigint bigint,
    project_id_convert_to_bigint bigint,
    promoted_to_epic_id_convert_to_bigint bigint,
    updated_by_id_convert_to_bigint bigint,
    CONSTRAINT check_2addf801cd CHECK ((work_item_type_id IS NOT NULL)),
    CONSTRAINT check_c33362cd43 CHECK ((namespace_id IS NOT NULL)),
    CONSTRAINT check_fba63f706d CHECK ((lock_version IS NOT NULL))
);

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

ALTER SEQUENCE issues_id_seq OWNED BY issues.id;

CREATE TABLE iterations_cadences (
    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,
    start_date date,
    duration_in_weeks integer,
    iterations_in_advance integer,
    active boolean DEFAULT true NOT NULL,
    automatic boolean DEFAULT true NOT NULL,
    title text NOT NULL,
    roll_over boolean DEFAULT false NOT NULL,
    description text,
    next_run_date date,
    CONSTRAINT check_5c5d2b44bd CHECK ((char_length(description) <= 5000)),
    CONSTRAINT check_fedff82d3b CHECK ((char_length(title) <= 255))
);

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

ALTER SEQUENCE iterations_cadences_id_seq OWNED BY iterations_cadences.id;

CREATE TABLE jira_connect_installations (
    id bigint NOT NULL,
    client_key character varying,
    encrypted_shared_secret character varying,
    encrypted_shared_secret_iv character varying,
    base_url character varying,
    instance_url text,
    CONSTRAINT check_4c6abed669 CHECK ((char_length(instance_url) <= 255))
);

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

ALTER SEQUENCE jira_connect_installations_id_seq OWNED BY jira_connect_installations.id;

CREATE TABLE jira_connect_subscriptions (
    id bigint NOT NULL,
    jira_connect_installation_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
);

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

ALTER SEQUENCE jira_connect_subscriptions_id_seq OWNED BY jira_connect_subscriptions.id;

CREATE TABLE jira_imports (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    user_id bigint,
    label_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    finished_at timestamp with time zone,
    jira_project_xid bigint NOT NULL,
    total_issue_count integer DEFAULT 0 NOT NULL,
    imported_issues_count integer DEFAULT 0 NOT NULL,
    failed_to_import_count integer DEFAULT 0 NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    jid character varying(255),
    jira_project_key character varying(255) NOT NULL,
    jira_project_name character varying(255) NOT NULL,
    scheduled_at timestamp with time zone,
    error_message text,
    CONSTRAINT check_9ed451c5b1 CHECK ((char_length(error_message) <= 1000))
);

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

ALTER SEQUENCE jira_imports_id_seq OWNED BY jira_imports.id;

CREATE TABLE jira_tracker_data (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    encrypted_url character varying,
    encrypted_url_iv character varying,
    encrypted_api_url character varying,
    encrypted_api_url_iv character varying,
    encrypted_username character varying,
    encrypted_username_iv character varying,
    encrypted_password character varying,
    encrypted_password_iv character varying,
    jira_issue_transition_id character varying,
    project_key text,
    issues_enabled boolean DEFAULT false NOT NULL,
    deployment_type smallint DEFAULT 0 NOT NULL,
    vulnerabilities_issuetype text,
    vulnerabilities_enabled boolean DEFAULT false NOT NULL,
    jira_issue_transition_automatic boolean DEFAULT false NOT NULL,
    integration_id bigint,
    jira_issue_prefix text,
    jira_issue_regex text,
    jira_auth_type smallint DEFAULT 0 NOT NULL,
    project_keys text[] DEFAULT '{}'::text[] NOT NULL,
    customize_jira_issue_enabled boolean DEFAULT false,
    CONSTRAINT check_0bf84b76e9 CHECK ((char_length(vulnerabilities_issuetype) <= 255)),
    CONSTRAINT check_0fbd71d9f2 CHECK ((integration_id IS NOT NULL)),
    CONSTRAINT check_214cf6a48b CHECK ((char_length(project_key) <= 255)),
    CONSTRAINT check_4cc5bbc801 CHECK ((char_length(jira_issue_prefix) <= 255)),
    CONSTRAINT check_9863a0a5fd CHECK ((char_length(jira_issue_regex) <= 255))
);

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

ALTER SEQUENCE jira_tracker_data_id_seq OWNED BY jira_tracker_data.id;

CREATE TABLE keys (
    id bigint NOT NULL,
    user_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    key text,
    title character varying,
    type character varying,
    fingerprint character varying,
    public boolean DEFAULT false NOT NULL,
    last_used_at timestamp without time zone,
    fingerprint_sha256 bytea,
    expires_at timestamp with time zone,
    expiry_notification_delivered_at timestamp with time zone,
    before_expiry_notification_delivered_at timestamp with time zone,
    usage_type smallint DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE keys_id_seq OWNED BY keys.id;

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

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

ALTER SEQUENCE label_links_id_seq OWNED BY label_links.id;

CREATE TABLE label_priorities (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    label_id bigint NOT NULL,
    priority integer NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);

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

ALTER SEQUENCE label_priorities_id_seq OWNED BY label_priorities.id;

CREATE TABLE labels (
    id bigint NOT NULL,
    title character varying,
    color character varying,
    project_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    template boolean DEFAULT false,
    description character varying,
    description_html text,
    type character varying,
    group_id bigint,
    cached_markdown_version integer,
    lock_on_merge boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE labels_id_seq OWNED BY labels.id;

CREATE TABLE ldap_group_links (
    id bigint NOT NULL,
    cn character varying,
    group_access integer NOT NULL,
    group_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    provider character varying,
    filter character varying,
    member_role_id bigint
);

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

ALTER SEQUENCE ldap_group_links_id_seq OWNED BY ldap_group_links.id;

CREATE TABLE lfs_file_locks (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    path character varying(511)
);

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

ALTER SEQUENCE lfs_file_locks_id_seq OWNED BY lfs_file_locks.id;

CREATE TABLE lfs_object_states (
    verification_started_at timestamp with time zone,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    lfs_object_id bigint NOT NULL,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_retry_count smallint,
    verification_checksum bytea,
    verification_failure text,
    CONSTRAINT check_efe45a8ab3 CHECK ((char_length(verification_failure) <= 255))
);

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

ALTER SEQUENCE lfs_object_states_lfs_object_id_seq OWNED BY lfs_object_states.lfs_object_id;

CREATE TABLE lfs_objects (
    id bigint NOT NULL,
    oid character varying NOT NULL,
    size bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    file character varying,
    file_store integer DEFAULT 1,
    CONSTRAINT check_eecfc5717d CHECK ((file_store IS NOT NULL))
);

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

ALTER SEQUENCE lfs_objects_id_seq OWNED BY lfs_objects.id;

CREATE TABLE lfs_objects_projects (
    id bigint NOT NULL,
    lfs_object_id bigint NOT NULL,
    project_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    repository_type smallint
);

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

ALTER SEQUENCE lfs_objects_projects_id_seq OWNED BY lfs_objects_projects.id;

CREATE TABLE licenses (
    id bigint NOT NULL,
    data text NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    cloud boolean DEFAULT false,
    last_synced_at timestamp with time zone
);

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

ALTER SEQUENCE licenses_id_seq OWNED BY licenses.id;

CREATE TABLE list_user_preferences (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    list_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    collapsed boolean
);

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

ALTER SEQUENCE list_user_preferences_id_seq OWNED BY list_user_preferences.id;

CREATE TABLE lists (
    id bigint NOT NULL,
    board_id bigint NOT NULL,
    label_id bigint,
    list_type integer DEFAULT 1 NOT NULL,
    "position" integer,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    user_id bigint,
    milestone_id bigint,
    max_issue_count integer DEFAULT 0 NOT NULL,
    max_issue_weight integer DEFAULT 0 NOT NULL,
    limit_metric character varying(20),
    iteration_id bigint
);

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

ALTER SEQUENCE lists_id_seq OWNED BY lists.id;

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

ALTER SEQUENCE loose_foreign_keys_deleted_records_id_seq OWNED BY loose_foreign_keys_deleted_records.id;

CREATE TABLE member_approvals (
    id bigint NOT NULL,
    reviewed_at timestamp with time zone,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    member_id bigint,
    member_namespace_id bigint NOT NULL,
    requested_by_id bigint,
    reviewed_by_id bigint,
    new_access_level integer NOT NULL,
    old_access_level integer,
    status smallint DEFAULT 0 NOT NULL,
    user_id bigint NOT NULL,
    member_role_id bigint,
    metadata jsonb DEFAULT '{}'::jsonb NOT NULL
);

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

ALTER SEQUENCE member_approvals_id_seq OWNED BY member_approvals.id;

CREATE TABLE member_roles (
    id bigint NOT NULL,
    namespace_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    base_access_level integer,
    name text DEFAULT 'Custom'::text NOT NULL,
    description text,
    occupies_seat boolean DEFAULT false NOT NULL,
    permissions jsonb DEFAULT '{}'::jsonb NOT NULL,
    CONSTRAINT check_4364846f58 CHECK ((char_length(description) <= 255)),
    CONSTRAINT check_9907916995 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE member_roles_id_seq OWNED BY member_roles.id;

CREATE TABLE members (
    id bigint NOT NULL,
    access_level integer NOT NULL,
    source_id bigint NOT NULL,
    source_type character varying NOT NULL,
    user_id bigint,
    notification_level integer NOT NULL,
    type character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    created_by_id bigint,
    invite_email character varying,
    invite_token character varying,
    invite_accepted_at timestamp without time zone,
    requested_at timestamp without time zone,
    expires_at date,
    ldap boolean DEFAULT false NOT NULL,
    override boolean DEFAULT false NOT NULL,
    state smallint DEFAULT 0,
    invite_email_success boolean DEFAULT true NOT NULL,
    member_namespace_id bigint,
    member_role_id bigint,
    expiry_notified_at timestamp with time zone,
    request_accepted_at timestamp with time zone,
    last_activity_on date DEFAULT now(),
    CONSTRAINT check_508774aac0 CHECK ((member_namespace_id IS NOT NULL))
);

CREATE TABLE members_deletion_schedules (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    user_id bigint NOT NULL,
    scheduled_by_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE members_deletion_schedules_id_seq OWNED BY members_deletion_schedules.id;

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

ALTER SEQUENCE members_id_seq OWNED BY members.id;

CREATE TABLE merge_request_assignees (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    created_at timestamp with time zone,
    project_id bigint
);

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

ALTER SEQUENCE merge_request_assignees_id_seq OWNED BY merge_request_assignees.id;

CREATE TABLE merge_request_assignment_events (
    id bigint NOT NULL,
    user_id bigint,
    merge_request_id bigint NOT NULL,
    created_at timestamp with time zone DEFAULT now() NOT NULL,
    action smallint DEFAULT 1 NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE merge_request_assignment_events_id_seq OWNED BY merge_request_assignment_events.id;

CREATE TABLE merge_request_blocks (
    id bigint NOT NULL,
    blocking_merge_request_id bigint NOT NULL,
    blocked_merge_request_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE merge_request_blocks_id_seq OWNED BY merge_request_blocks.id;

CREATE TABLE merge_request_cleanup_schedules (
    merge_request_id bigint NOT NULL,
    scheduled_at timestamp with time zone NOT NULL,
    completed_at timestamp with time zone,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    failed_count integer DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE merge_request_cleanup_schedules_merge_request_id_seq OWNED BY merge_request_cleanup_schedules.merge_request_id;

CREATE TABLE merge_request_context_commit_diff_files (
    sha bytea NOT NULL,
    relative_order integer NOT NULL,
    new_file boolean NOT NULL,
    renamed_file boolean NOT NULL,
    deleted_file boolean NOT NULL,
    too_large boolean NOT NULL,
    a_mode character varying(255) NOT NULL,
    b_mode character varying(255) NOT NULL,
    new_path text NOT NULL,
    old_path text NOT NULL,
    diff text,
    "binary" boolean,
    merge_request_context_commit_id bigint NOT NULL,
    generated boolean,
    encoded_file_path boolean DEFAULT false NOT NULL
);

CREATE TABLE merge_request_context_commits (
    id bigint NOT NULL,
    authored_date timestamp with time zone,
    committed_date timestamp with time zone,
    relative_order integer NOT NULL,
    sha bytea NOT NULL,
    author_name text,
    author_email text,
    committer_name text,
    committer_email text,
    message text,
    merge_request_id bigint,
    trailers jsonb DEFAULT '{}'::jsonb NOT NULL,
    project_id bigint,
    CONSTRAINT check_1dc6b5f2ac CHECK ((merge_request_id IS NOT NULL))
);

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

ALTER SEQUENCE merge_request_context_commits_id_seq OWNED BY merge_request_context_commits.id;

CREATE TABLE merge_request_diff_commit_users (
    id bigint NOT NULL,
    name text,
    email text,
    CONSTRAINT check_147358fc42 CHECK ((char_length(name) <= 512)),
    CONSTRAINT check_f5fa206cf7 CHECK ((char_length(email) <= 512)),
    CONSTRAINT merge_request_diff_commit_users_name_or_email_existence CHECK (((COALESCE(name, ''::text) <> ''::text) OR (COALESCE(email, ''::text) <> ''::text)))
);

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

ALTER SEQUENCE merge_request_diff_commit_users_id_seq OWNED BY merge_request_diff_commit_users.id;

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

CREATE TABLE merge_request_diff_details (
    merge_request_diff_id bigint NOT NULL,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    verification_retry_count smallint,
    verification_checksum bytea,
    verification_failure text,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_started_at timestamp with time zone,
    CONSTRAINT check_81429e3622 CHECK ((char_length(verification_failure) <= 255))
);

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

ALTER SEQUENCE merge_request_diff_details_merge_request_diff_id_seq OWNED BY merge_request_diff_details.merge_request_diff_id;

CREATE TABLE merge_request_diff_files (
    merge_request_diff_id bigint NOT NULL,
    relative_order integer NOT NULL,
    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,
    encoded_file_path boolean DEFAULT false NOT NULL
);

CREATE TABLE merge_request_diffs (
    id bigint NOT NULL,
    state character varying,
    merge_request_id bigint NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    base_commit_sha character varying,
    real_size character varying,
    head_commit_sha character varying,
    start_commit_sha character varying,
    commits_count integer,
    external_diff character varying,
    external_diff_store integer DEFAULT 1,
    stored_externally boolean,
    files_count smallint,
    sorted boolean DEFAULT false NOT NULL,
    diff_type smallint DEFAULT 1 NOT NULL,
    patch_id_sha bytea,
    project_id bigint,
    CONSTRAINT check_11c5f029ad CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_93ee616ac9 CHECK ((external_diff_store IS NOT NULL))
);

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

ALTER SEQUENCE merge_request_diffs_id_seq OWNED BY merge_request_diffs.id;

CREATE TABLE merge_request_merge_schedules (
    id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    merge_after timestamp with time zone,
    project_id bigint NOT NULL
);

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

ALTER SEQUENCE merge_request_merge_schedules_id_seq OWNED BY merge_request_merge_schedules.id;

CREATE TABLE merge_request_metrics (
    merge_request_id bigint NOT NULL,
    latest_build_started_at timestamp without time zone,
    latest_build_finished_at timestamp without time zone,
    first_deployed_to_production_at timestamp without time zone,
    merged_at timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    merged_by_id bigint,
    latest_closed_by_id bigint,
    latest_closed_at timestamp with time zone,
    first_comment_at timestamp with time zone,
    first_commit_at timestamp with time zone,
    last_commit_at timestamp with time zone,
    diff_size integer,
    modified_paths_size integer,
    commits_count integer,
    first_approved_at timestamp with time zone,
    first_reassigned_at timestamp with time zone,
    added_lines integer,
    removed_lines integer,
    target_project_id bigint,
    id bigint NOT NULL,
    first_contribution boolean DEFAULT false NOT NULL,
    pipeline_id bigint,
    reviewer_first_assigned_at timestamp with time zone,
    CONSTRAINT check_e03d0900bf CHECK ((target_project_id IS NOT NULL))
);

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

ALTER SEQUENCE merge_request_metrics_id_seq OWNED BY merge_request_metrics.id;

CREATE TABLE merge_request_predictions (
    merge_request_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    suggested_reviewers jsonb DEFAULT '{}'::jsonb NOT NULL,
    accepted_reviewers jsonb DEFAULT '{}'::jsonb NOT NULL
);

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

ALTER SEQUENCE merge_request_predictions_merge_request_id_seq OWNED BY merge_request_predictions.merge_request_id;

CREATE TABLE merge_request_requested_changes (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    user_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE merge_request_requested_changes_id_seq OWNED BY merge_request_requested_changes.id;

CREATE TABLE merge_request_reviewers (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    state smallint DEFAULT 0 NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE merge_request_reviewers_id_seq OWNED BY merge_request_reviewers.id;

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

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

ALTER SEQUENCE merge_request_user_mentions_id_seq OWNED BY merge_request_user_mentions.id;

CREATE TABLE merge_requests (
    id bigint NOT NULL,
    target_branch character varying NOT NULL,
    source_branch character varying NOT NULL,
    source_project_id bigint,
    author_id bigint,
    assignee_id bigint,
    title character varying,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    milestone_id bigint,
    merge_status character varying DEFAULT 'unchecked'::character varying NOT NULL,
    target_project_id bigint NOT NULL,
    iid integer,
    description text,
    updated_by_id bigint,
    merge_error text,
    merge_params text,
    merge_when_pipeline_succeeds boolean DEFAULT false NOT NULL,
    merge_user_id bigint,
    merge_commit_sha character varying,
    approvals_before_merge integer,
    rebase_commit_sha character varying,
    in_progress_merge_commit_sha character varying,
    lock_version integer DEFAULT 0,
    title_html text,
    description_html text,
    time_estimate integer DEFAULT 0,
    squash boolean DEFAULT false NOT NULL,
    cached_markdown_version integer,
    last_edited_at timestamp without time zone,
    last_edited_by_id bigint,
    merge_jid character varying,
    discussion_locked boolean,
    latest_merge_request_diff_id bigint,
    allow_maintainer_to_push boolean DEFAULT true,
    state_id smallint DEFAULT 1 NOT NULL,
    rebase_jid character varying,
    squash_commit_sha bytea,
    sprint_id bigint,
    merge_ref_sha bytea,
    draft boolean DEFAULT false NOT NULL,
    prepared_at timestamp with time zone,
    merged_commit_sha bytea,
    override_requested_changes boolean DEFAULT false NOT NULL,
    head_pipeline_id bigint,
    imported_from smallint DEFAULT 0 NOT NULL,
    retargeted boolean DEFAULT false NOT NULL,
    CONSTRAINT check_970d272570 CHECK ((lock_version IS NOT NULL))
);

CREATE TABLE merge_requests_closing_issues (
    id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    from_mr_description boolean DEFAULT true NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE merge_requests_closing_issues_id_seq OWNED BY merge_requests_closing_issues.id;

CREATE TABLE merge_requests_compliance_violations (
    id bigint NOT NULL,
    violating_user_id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    reason smallint NOT NULL,
    severity_level smallint DEFAULT 0 NOT NULL,
    merged_at timestamp with time zone,
    target_project_id bigint,
    title text,
    target_branch text
);

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

ALTER SEQUENCE merge_requests_compliance_violations_id_seq OWNED BY merge_requests_compliance_violations.id;

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

ALTER SEQUENCE merge_requests_id_seq OWNED BY merge_requests.id;

CREATE TABLE merge_trains (
    id bigint NOT NULL,
    merge_request_id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    target_project_id bigint NOT NULL,
    target_branch text NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    merged_at timestamp with time zone,
    duration integer,
    pipeline_id bigint
);

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

ALTER SEQUENCE merge_trains_id_seq OWNED BY merge_trains.id;

CREATE TABLE metrics_dashboard_annotations (
    id bigint NOT NULL,
    starting_at timestamp with time zone NOT NULL,
    ending_at timestamp with time zone,
    environment_id bigint,
    cluster_id bigint,
    dashboard_path character varying(255) NOT NULL,
    panel_xid character varying(255),
    description text NOT NULL
);

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

ALTER SEQUENCE metrics_dashboard_annotations_id_seq OWNED BY metrics_dashboard_annotations.id;

CREATE TABLE metrics_users_starred_dashboards (
    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,
    user_id bigint NOT NULL,
    dashboard_path text NOT NULL,
    CONSTRAINT check_79a84a0f57 CHECK ((char_length(dashboard_path) <= 255))
);

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

ALTER SEQUENCE metrics_users_starred_dashboards_id_seq OWNED BY metrics_users_starred_dashboards.id;

CREATE TABLE milestone_releases (
    milestone_id bigint NOT NULL,
    release_id bigint NOT NULL,
    project_id bigint
);

CREATE TABLE milestones (
    id bigint NOT NULL,
    title character varying NOT NULL,
    project_id bigint,
    description text,
    due_date date,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    state character varying,
    iid integer,
    title_html text,
    description_html text,
    start_date date,
    cached_markdown_version integer,
    group_id bigint,
    lock_version integer DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE milestones_id_seq OWNED BY milestones.id;

CREATE TABLE ml_candidate_metadata (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    candidate_id bigint NOT NULL,
    name text NOT NULL,
    value text NOT NULL,
    project_id bigint,
    CONSTRAINT check_6b38a286a5 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_9453f4a8e9 CHECK ((char_length(value) <= 5000))
);

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

ALTER SEQUENCE ml_candidate_metadata_id_seq OWNED BY ml_candidate_metadata.id;

CREATE TABLE ml_candidate_metrics (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    candidate_id bigint,
    value double precision,
    step integer,
    is_nan bytea,
    name text NOT NULL,
    tracked_at bigint,
    project_id bigint,
    CONSTRAINT check_3bb4a3fbd9 CHECK ((char_length(name) <= 250)),
    CONSTRAINT check_d7dfd3de26 CHECK ((candidate_id IS NOT NULL))
);

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

ALTER SEQUENCE ml_candidate_metrics_id_seq OWNED BY ml_candidate_metrics.id;

CREATE TABLE ml_candidate_params (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    candidate_id bigint,
    name text NOT NULL,
    value text NOT NULL,
    project_id bigint,
    CONSTRAINT check_093034d049 CHECK ((char_length(name) <= 250)),
    CONSTRAINT check_28a3c29e43 CHECK ((char_length(value) <= 250)),
    CONSTRAINT check_7a0505ca91 CHECK ((candidate_id IS NOT NULL))
);

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

ALTER SEQUENCE ml_candidate_params_id_seq OWNED BY ml_candidate_params.id;

CREATE TABLE ml_candidates (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    experiment_id bigint NOT NULL,
    user_id bigint,
    start_time bigint,
    end_time bigint,
    status smallint DEFAULT 0 NOT NULL,
    name text,
    package_id bigint,
    eid uuid,
    project_id bigint,
    internal_id bigint,
    ci_build_id bigint,
    model_version_id bigint,
    CONSTRAINT check_01584ca6db CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_25e6c65051 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_cd160587d4 CHECK ((eid IS NOT NULL))
);

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

ALTER SEQUENCE ml_candidates_id_seq OWNED BY ml_candidates.id;

CREATE TABLE ml_experiment_metadata (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    experiment_id bigint NOT NULL,
    name text NOT NULL,
    value text NOT NULL,
    project_id bigint,
    CONSTRAINT check_112fe5002d CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_a91c633d68 CHECK ((char_length(value) <= 5000))
);

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

ALTER SEQUENCE ml_experiment_metadata_id_seq OWNED BY ml_experiment_metadata.id;

CREATE TABLE ml_experiments (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    iid bigint NOT NULL,
    project_id bigint NOT NULL,
    user_id bigint,
    name text NOT NULL,
    deleted_on timestamp with time zone,
    model_id bigint,
    CONSTRAINT check_ee07a0be2c CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE ml_experiments_id_seq OWNED BY ml_experiments.id;

CREATE TABLE ml_model_metadata (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    model_id bigint NOT NULL,
    name text NOT NULL,
    value text NOT NULL,
    project_id bigint,
    CONSTRAINT check_26d3322153 CHECK ((char_length(value) <= 5000)),
    CONSTRAINT check_36240c80a7 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE ml_model_metadata_id_seq OWNED BY ml_model_metadata.id;

CREATE TABLE ml_model_version_metadata (
    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,
    model_version_id bigint NOT NULL,
    name text NOT NULL,
    value text NOT NULL,
    CONSTRAINT check_09a0e5cb5b CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_21c444e039 CHECK ((char_length(value) <= 5000))
);

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

ALTER SEQUENCE ml_model_version_metadata_id_seq OWNED BY ml_model_version_metadata.id;

CREATE TABLE ml_model_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,
    model_id bigint NOT NULL,
    package_id bigint,
    version text NOT NULL,
    description text,
    semver_major integer,
    semver_minor integer,
    semver_patch integer,
    semver_prerelease text,
    cached_markdown_version integer,
    description_html text,
    CONSTRAINT check_246f5048b5 CHECK ((char_length(semver_prerelease) <= 255)),
    CONSTRAINT check_28b2d892c8 CHECK ((char_length(version) <= 255)),
    CONSTRAINT check_4d50116294 CHECK ((char_length(description_html) <= 50000)),
    CONSTRAINT check_f1545d8a9e CHECK ((char_length(description) <= 10000))
);

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

ALTER SEQUENCE ml_model_versions_id_seq OWNED BY ml_model_versions.id;

CREATE TABLE ml_models (
    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,
    description text,
    user_id bigint,
    cached_markdown_version integer,
    description_html text,
    CONSTRAINT check_1fd2cc7d93 CHECK ((char_length(name) <= 255)),
    CONSTRAINT check_51a38acdaa CHECK ((char_length(description_html) <= 50000)),
    CONSTRAINT check_f8df2fefc5 CHECK ((char_length(description) <= 10000))
);

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

ALTER SEQUENCE ml_models_id_seq OWNED BY ml_models.id;

CREATE TABLE namespace_admin_notes (
    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,
    note text,
    CONSTRAINT check_e9d2e71b5d CHECK ((char_length(note) <= 1000))
);

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

ALTER SEQUENCE namespace_admin_notes_id_seq OWNED BY namespace_admin_notes.id;

CREATE TABLE namespace_aggregation_schedules (
    namespace_id bigint NOT NULL
);

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

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

ALTER SEQUENCE namespace_bans_id_seq OWNED BY namespace_bans.id;

CREATE TABLE namespace_ci_cd_settings (
    namespace_id bigint NOT NULL,
    allow_stale_runner_pruning boolean DEFAULT false NOT NULL
);

CREATE TABLE namespace_commit_emails (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    email_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);

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

ALTER SEQUENCE namespace_commit_emails_id_seq OWNED BY namespace_commit_emails.id;

CREATE TABLE namespace_details (
    namespace_id bigint NOT NULL,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    cached_markdown_version integer,
    description text,
    description_html text,
    creator_id bigint,
    pending_delete boolean DEFAULT false NOT NULL,
    deleted_at timestamp with time zone
);

CREATE TABLE namespace_import_users (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    namespace_id bigint NOT NULL
);

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

ALTER SEQUENCE namespace_import_users_id_seq OWNED BY namespace_import_users.id;

CREATE TABLE namespace_ldap_settings (
    namespace_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    sync_last_start_at timestamp with time zone,
    sync_last_update_at timestamp with time zone,
    sync_last_successful_at timestamp with time zone,
    sync_status smallint DEFAULT 0 NOT NULL,
    sync_error text,
    CONSTRAINT check_51a03d26b6 CHECK ((char_length(sync_error) <= 255))
);

CREATE TABLE namespace_limits (
    additional_purchased_storage_size bigint DEFAULT 0 NOT NULL,
    additional_purchased_storage_ends_on date,
    namespace_id bigint NOT NULL,
    temporary_storage_increase_ends_on date,
    pre_enforcement_notification_at timestamp with time zone,
    first_enforced_at timestamp with time zone,
    last_enforced_at timestamp with time zone,
    last_seat_all_used_seats_notification_at timestamp with time zone,
    max_number_of_vulnerabilities_per_project integer
);

CREATE TABLE namespace_package_settings (
    namespace_id bigint NOT NULL,
    maven_duplicates_allowed boolean DEFAULT true NOT NULL,
    maven_duplicate_exception_regex text DEFAULT ''::text NOT NULL,
    generic_duplicates_allowed boolean DEFAULT true NOT NULL,
    generic_duplicate_exception_regex text DEFAULT ''::text NOT NULL,
    maven_package_requests_forwarding boolean,
    lock_maven_package_requests_forwarding boolean DEFAULT false NOT NULL,
    pypi_package_requests_forwarding boolean,
    lock_pypi_package_requests_forwarding boolean DEFAULT false NOT NULL,
    npm_package_requests_forwarding boolean,
    lock_npm_package_requests_forwarding boolean DEFAULT false NOT NULL,
    nuget_duplicates_allowed boolean DEFAULT true NOT NULL,
    nuget_duplicate_exception_regex text DEFAULT ''::text NOT NULL,
    nuget_symbol_server_enabled boolean DEFAULT false NOT NULL,
    terraform_module_duplicates_allowed boolean DEFAULT false NOT NULL,
    terraform_module_duplicate_exception_regex text DEFAULT ''::text NOT NULL,
    CONSTRAINT check_31340211b1 CHECK ((char_length(generic_duplicate_exception_regex) <= 255)),
    CONSTRAINT check_d63274b2b6 CHECK ((char_length(maven_duplicate_exception_regex) <= 255)),
    CONSTRAINT check_eedcf85c48 CHECK ((char_length(nuget_duplicate_exception_regex) <= 255)),
    CONSTRAINT check_f10503f1ad CHECK ((char_length(terraform_module_duplicate_exception_regex) <= 255))
);

CREATE TABLE namespace_root_storage_statistics (
    namespace_id bigint NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    repository_size bigint DEFAULT 0 NOT NULL,
    lfs_objects_size bigint DEFAULT 0 NOT NULL,
    wiki_size bigint DEFAULT 0 NOT NULL,
    build_artifacts_size bigint DEFAULT 0 NOT NULL,
    storage_size bigint DEFAULT 0 NOT NULL,
    packages_size bigint DEFAULT 0 NOT NULL,
    snippets_size bigint DEFAULT 0 NOT NULL,
    pipeline_artifacts_size bigint DEFAULT 0 NOT NULL,
    uploads_size bigint DEFAULT 0 NOT NULL,
    dependency_proxy_size bigint DEFAULT 0 NOT NULL,
    notification_level smallint DEFAULT 100 NOT NULL,
    container_registry_size bigint DEFAULT 0 NOT NULL,
    registry_size_estimated boolean DEFAULT false NOT NULL,
    public_forks_storage_size bigint DEFAULT 0 NOT NULL,
    internal_forks_storage_size bigint DEFAULT 0 NOT NULL,
    private_forks_storage_size bigint DEFAULT 0 NOT NULL
);

CREATE TABLE namespace_settings (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    namespace_id bigint NOT NULL,
    prevent_forking_outside_group boolean DEFAULT false NOT NULL,
    allow_mfa_for_subgroups boolean DEFAULT true NOT NULL,
    default_branch_name text,
    repository_read_only boolean DEFAULT false NOT NULL,
    resource_access_token_creation_allowed boolean DEFAULT true NOT NULL,
    prevent_sharing_groups_outside_hierarchy boolean DEFAULT false NOT NULL,
    new_user_signups_cap integer,
    setup_for_company boolean,
    jobs_to_be_done smallint,
    runner_token_expiration_interval integer,
    subgroup_runner_token_expiration_interval integer,
    project_runner_token_expiration_interval integer,
    show_diff_preview_in_email boolean DEFAULT true NOT NULL,
    enabled_git_access_protocol smallint DEFAULT 0 NOT NULL,
    unique_project_download_limit smallint DEFAULT 0 NOT NULL,
    unique_project_download_limit_interval_in_seconds integer DEFAULT 0 NOT NULL,
    unique_project_download_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL,
    auto_ban_user_on_excessive_projects_download boolean DEFAULT false NOT NULL,
    only_allow_merge_if_pipeline_succeeds boolean DEFAULT false NOT NULL,
    allow_merge_on_skipped_pipeline boolean DEFAULT false NOT NULL,
    only_allow_merge_if_all_discussions_are_resolved boolean DEFAULT false NOT NULL,
    default_compliance_framework_id bigint,
    runner_registration_enabled boolean DEFAULT true,
    allow_runner_registration_token boolean DEFAULT true NOT NULL,
    unique_project_download_limit_alertlist integer[] DEFAULT '{}'::integer[] NOT NULL,
    emails_enabled boolean DEFAULT true NOT NULL,
    experiment_features_enabled boolean DEFAULT false NOT NULL,
    default_branch_protection_defaults jsonb DEFAULT '{}'::jsonb NOT NULL,
    service_access_tokens_expiration_enforced boolean DEFAULT true NOT NULL,
    product_analytics_enabled boolean DEFAULT false NOT NULL,
    allow_merge_without_pipeline boolean DEFAULT false NOT NULL,
    enforce_ssh_certificates boolean DEFAULT false NOT NULL,
    math_rendering_limits_enabled boolean,
    lock_math_rendering_limits_enabled boolean DEFAULT false NOT NULL,
    duo_features_enabled boolean,
    lock_duo_features_enabled boolean DEFAULT false NOT NULL,
    disable_personal_access_tokens boolean DEFAULT false NOT NULL,
    enable_auto_assign_gitlab_duo_pro_seats boolean DEFAULT false NOT NULL,
    early_access_program_participant boolean DEFAULT false NOT NULL,
    remove_dormant_members boolean DEFAULT false NOT NULL,
    remove_dormant_members_period integer DEFAULT 90 NOT NULL,
    early_access_program_joined_by_id bigint,
    seat_control smallint DEFAULT 0 NOT NULL,
    last_dormant_member_review_at timestamp with time zone,
    enterprise_users_extensions_marketplace_opt_in_status smallint DEFAULT 0 NOT NULL,
    spp_repository_pipeline_access boolean,
    lock_spp_repository_pipeline_access boolean DEFAULT false NOT NULL,
    archived boolean DEFAULT false NOT NULL,
    token_expiry_notify_inherited boolean DEFAULT true NOT NULL,
    CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255)),
    CONSTRAINT namespace_settings_unique_project_download_limit_alertlist_size CHECK ((cardinality(unique_project_download_limit_alertlist) <= 100)),
    CONSTRAINT namespace_settings_unique_project_download_limit_allowlist_size CHECK ((cardinality(unique_project_download_limit_allowlist) <= 100))
);

CREATE TABLE namespace_statistics (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    shared_runners_seconds integer DEFAULT 0 NOT NULL,
    shared_runners_seconds_last_reset timestamp without time zone,
    storage_size bigint DEFAULT 0 NOT NULL,
    wiki_size bigint DEFAULT 0 NOT NULL,
    dependency_proxy_size bigint DEFAULT 0 NOT NULL
);

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

ALTER SEQUENCE namespace_statistics_id_seq OWNED BY namespace_statistics.id;

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

ALTER SEQUENCE namespaces_id_seq OWNED BY namespaces.id;

CREATE TABLE namespaces_storage_limit_exclusions (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL,
    reason text NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    CONSTRAINT check_81640b2ee2 CHECK ((char_length(reason) <= 255))
);

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

ALTER SEQUENCE namespaces_storage_limit_exclusions_id_seq OWNED BY namespaces_storage_limit_exclusions.id;

CREATE TABLE namespaces_sync_events (
    id bigint NOT NULL,
    namespace_id bigint NOT NULL
);

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

ALTER SEQUENCE namespaces_sync_events_id_seq OWNED BY namespaces_sync_events.id;

CREATE TABLE note_diff_files (
    id bigint NOT NULL,
    diff text NOT NULL,
    new_file boolean NOT NULL,
    renamed_file boolean NOT NULL,
    deleted_file 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_note_id bigint NOT NULL
);

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

ALTER SEQUENCE note_diff_files_id_seq OWNED BY note_diff_files.id;

CREATE TABLE note_metadata (
    note_id bigint NOT NULL,
    email_participant text,
    created_at timestamp with time zone,
    updated_at timestamp with time zone,
    CONSTRAINT check_40aa5ff1c6 CHECK ((char_length(email_participant) <= 255))
);

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

ALTER SEQUENCE note_metadata_note_id_seq OWNED BY note_metadata.note_id;

CREATE TABLE notes (
    note text,
    noteable_type character varying,
    author_id bigint,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    project_id bigint,
    attachment character varying,
    line_code character varying,
    commit_id character varying,
    noteable_id bigint,
    system boolean DEFAULT false NOT NULL,
    st_diff text,
    updated_by_id bigint,
    type character varying,
    "position" text,
    original_position text,
    resolved_at timestamp without time zone,
    resolved_by_id bigint,
    discussion_id character varying,
    note_html text,
    cached_markdown_version integer,
    change_position text,
    resolved_by_push boolean,
    review_id bigint,
    confidential boolean,
    last_edited_at timestamp with time zone,
    internal boolean DEFAULT false NOT NULL,
    id bigint NOT NULL,
    namespace_id bigint,
    imported_from smallint DEFAULT 0 NOT NULL,
    CONSTRAINT check_1244cbd7d0 CHECK ((noteable_type IS NOT NULL))
);

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

ALTER SEQUENCE notes_id_seq OWNED BY notes.id;

CREATE TABLE notification_settings (
    id bigint NOT NULL,
    user_id bigint NOT NULL,
    source_id bigint,
    source_type character varying,
    level integer DEFAULT 0 NOT NULL,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    new_note boolean,
    new_issue boolean,
    reopen_issue boolean,
    close_issue boolean,
    reassign_issue boolean,
    new_merge_request boolean,
    reopen_merge_request boolean,
    close_merge_request boolean,
    reassign_merge_request boolean,
    merge_merge_request boolean,
    failed_pipeline boolean,
    success_pipeline boolean,
    push_to_merge_request boolean,
    issue_due boolean,
    new_epic boolean,
    notification_email character varying,
    fixed_pipeline boolean,
    new_release boolean,
    moved_project boolean DEFAULT true NOT NULL,
    change_reviewer_merge_request boolean,
    merge_when_pipeline_succeeds boolean DEFAULT false NOT NULL,
    approver boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE notification_settings_id_seq OWNED BY notification_settings.id;

CREATE TABLE oauth_access_grants (
    id bigint NOT NULL,
    resource_owner_id bigint NOT NULL,
    application_id bigint NOT NULL,
    token character varying NOT NULL,
    expires_in integer NOT NULL,
    redirect_uri text NOT NULL,
    created_at timestamp without time zone NOT NULL,
    revoked_at timestamp without time zone,
    scopes character varying,
    code_challenge text,
    code_challenge_method text,
    organization_id bigint DEFAULT 1 NOT NULL,
    CONSTRAINT oauth_access_grants_code_challenge CHECK ((char_length(code_challenge) <= 128)),
    CONSTRAINT oauth_access_grants_code_challenge_method CHECK ((char_length(code_challenge_method) <= 5))
);

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

ALTER SEQUENCE oauth_access_grants_id_seq OWNED BY oauth_access_grants.id;

CREATE TABLE oauth_access_tokens (
    id bigint NOT NULL,
    resource_owner_id bigint,
    application_id bigint,
    token character varying NOT NULL,
    refresh_token character varying,
    expires_in integer DEFAULT 7200,
    revoked_at timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    scopes character varying,
    organization_id bigint DEFAULT 1 NOT NULL,
    CONSTRAINT check_70f294ef54 CHECK ((expires_in IS NOT NULL))
);

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

ALTER SEQUENCE oauth_access_tokens_id_seq OWNED BY oauth_access_tokens.id;

CREATE TABLE oauth_applications (
    id bigint NOT NULL,
    name character varying NOT NULL,
    uid character varying NOT NULL,
    secret character varying NOT NULL,
    redirect_uri text NOT NULL,
    scopes character varying DEFAULT ''::character varying NOT NULL,
    created_at timestamp without time zone,
    updated_at timestamp without time zone,
    owner_id bigint,
    owner_type character varying,
    trusted boolean DEFAULT false NOT NULL,
    confidential boolean DEFAULT true NOT NULL,
    expire_access_tokens boolean DEFAULT false NOT NULL
);

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

ALTER SEQUENCE oauth_applications_id_seq OWNED BY oauth_applications.id;

CREATE TABLE oauth_device_grants (
    id bigint NOT NULL,
    resource_owner_id bigint,
    application_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    last_polling_at timestamp with time zone,
    expires_in integer NOT NULL,
    scopes text DEFAULT ''::text NOT NULL,
    device_code text NOT NULL,
    user_code text,
    organization_id bigint DEFAULT 1 NOT NULL,
    CONSTRAINT check_a6271f2c07 CHECK ((char_length(device_code) <= 255)),
    CONSTRAINT check_b0459113c7 CHECK ((char_length(scopes) <= 255)),
    CONSTRAINT check_b36370c6df CHECK ((char_length(user_code) <= 255))
);

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

ALTER SEQUENCE oauth_device_grants_id_seq OWNED BY oauth_device_grants.id;

CREATE TABLE oauth_openid_requests (
    id bigint NOT NULL,
    access_grant_id bigint NOT NULL,
    nonce character varying NOT NULL,
    organization_id bigint DEFAULT 1 NOT NULL
);

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

ALTER SEQUENCE oauth_openid_requests_id_seq OWNED BY oauth_openid_requests.id;

CREATE TABLE observability_logs_issues_connections (
    id bigint NOT NULL,
    issue_id bigint NOT NULL,
    project_id bigint NOT NULL,
    log_timestamp timestamp with time zone NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    severity_number smallint NOT NULL,
    service_name text NOT NULL,
    trace_identifier text NOT NULL,
    log_fingerprint text NOT NULL,
    CONSTRAINT check_80945187b6 CHECK ((char_length(trace_identifier) <= 128)),
    CONSTRAINT check_ab38275544 CHECK ((char_length(log_fingerprint) <= 128)),
    CONSTRAINT check_d86a20d56b CHECK ((char_length(service_name) <= 500))
);

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

ALTER SEQUENCE observability_logs_issues_connections_id_seq OWNED BY observability_logs_issues_connections.id;

CREATE TABLE observability_metrics_issues_connections (
    id bigint NOT NULL,
    issue_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,
    metric_type smallint NOT NULL,
    metric_name text NOT NULL,
    project_id bigint,
    CONSTRAINT check_3c743c1262 CHECK ((char_length(metric_name) <= 500))
);

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

ALTER SEQUENCE observability_metrics_issues_connections_id_seq OWNED BY observability_metrics_issues_connections.id;

CREATE TABLE observability_traces_issues_connections (
    id bigint NOT NULL,
    issue_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,
    trace_identifier text NOT NULL,
    CONSTRAINT check_5b51f9ea15 CHECK ((char_length(trace_identifier) <= 128))
);

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

ALTER SEQUENCE observability_traces_issues_connections_id_seq OWNED BY observability_traces_issues_connections.id;

CREATE TABLE onboarding_progresses (
    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,
    git_write_at timestamp with time zone,
    merge_request_created_at timestamp with time zone,
    pipeline_created_at timestamp with time zone,
    user_added_at timestamp with time zone,
    trial_started_at timestamp with time zone,
    required_mr_approvals_enabled_at timestamp with time zone,
    code_owners_enabled_at timestamp with time zone,
    issue_created_at timestamp with time zone,
    secure_dependency_scanning_run_at timestamp with time zone,
    secure_dast_run_at timestamp with time zone,
    license_scanning_run_at timestamp with time zone,
    code_added_at timestamp with time zone,
    ended_at timestamp with time zone
);

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

ALTER SEQUENCE onboarding_progresses_id_seq OWNED BY onboarding_progresses.id;

CREATE TABLE operations_feature_flag_scopes (
    id bigint NOT NULL,
    feature_flag_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    active boolean NOT NULL,
    environment_scope character varying DEFAULT '*'::character varying NOT NULL,
    strategies jsonb DEFAULT '[{"name": "default", "parameters": {}}]'::jsonb NOT NULL
);

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

ALTER SEQUENCE operations_feature_flag_scopes_id_seq OWNED BY operations_feature_flag_scopes.id;

CREATE TABLE operations_feature_flags (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    active boolean NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    name character varying NOT NULL,
    description text,
    iid integer NOT NULL,
    version smallint DEFAULT 1 NOT NULL
);

CREATE TABLE operations_feature_flags_clients (
    id bigint NOT NULL,
    project_id bigint NOT NULL,
    token_encrypted character varying,
    last_feature_flag_updated_at timestamp with time zone
);

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

ALTER SEQUENCE operations_feature_flags_clients_id_seq OWNED BY operations_feature_flags_clients.id;

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

ALTER SEQUENCE operations_feature_flags_id_seq OWNED BY operations_feature_flags.id;

CREATE TABLE operations_feature_flags_issues (
    id bigint NOT NULL,
    feature_flag_id bigint NOT NULL,
    issue_id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE operations_feature_flags_issues_id_seq OWNED BY operations_feature_flags_issues.id;

CREATE TABLE operations_scopes (
    id bigint NOT NULL,
    strategy_id bigint NOT NULL,
    environment_scope character varying(255) NOT NULL
);

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

ALTER SEQUENCE operations_scopes_id_seq OWNED BY operations_scopes.id;

CREATE TABLE operations_strategies (
    id bigint NOT NULL,
    feature_flag_id bigint NOT NULL,
    name character varying(255) NOT NULL,
    parameters jsonb DEFAULT '{}'::jsonb NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE operations_strategies_id_seq OWNED BY operations_strategies.id;

CREATE TABLE operations_strategies_user_lists (
    id bigint NOT NULL,
    strategy_id bigint NOT NULL,
    user_list_id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE operations_strategies_user_lists_id_seq OWNED BY operations_strategies_user_lists.id;

CREATE TABLE operations_user_lists (
    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,
    iid integer NOT NULL,
    name character varying(255) NOT NULL,
    user_xids text DEFAULT ''::text NOT NULL
);

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

ALTER SEQUENCE operations_user_lists_id_seq OWNED BY operations_user_lists.id;

CREATE TABLE organization_details (
    organization_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    cached_markdown_version integer,
    description text,
    description_html text,
    avatar text,
    CONSTRAINT check_71dfb7807f CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_9fbd483b51 CHECK ((char_length(avatar) <= 255))
);

CREATE TABLE organization_settings (
    organization_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    settings jsonb DEFAULT '{}'::jsonb NOT NULL
);

CREATE TABLE organization_users (
    id bigint NOT NULL,
    organization_id bigint NOT NULL,
    user_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    access_level smallint DEFAULT 10 NOT NULL
);

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

ALTER SEQUENCE organization_users_id_seq OWNED BY organization_users.id;

CREATE TABLE organizations (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    name text DEFAULT ''::text NOT NULL,
    path text NOT NULL,
    visibility_level smallint DEFAULT 0 NOT NULL,
    CONSTRAINT check_0b4296b5ea CHECK ((char_length(path) <= 255)),
    CONSTRAINT check_d130d769e0 CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE organizations_id_seq OWNED BY organizations.id;

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

ALTER SEQUENCE p_batched_git_ref_updates_deletions_id_seq OWNED BY p_batched_git_ref_updates_deletions.id;

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

ALTER SEQUENCE p_catalog_resource_component_usages_id_seq OWNED BY p_catalog_resource_component_usages.id;

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

ALTER SEQUENCE p_catalog_resource_sync_events_id_seq OWNED BY p_catalog_resource_sync_events.id;

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

ALTER SEQUENCE p_ci_build_tags_id_seq OWNED BY p_ci_build_tags.id;

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

ALTER SEQUENCE p_ci_builds_execution_configs_id_seq OWNED BY p_ci_builds_execution_configs.id;

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

ALTER SEQUENCE p_ci_job_annotations_id_seq OWNED BY p_ci_job_annotations.id;

CREATE TABLE packages_build_infos (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    pipeline_id bigint,
    project_id bigint
);

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

ALTER SEQUENCE packages_build_infos_id_seq OWNED BY packages_build_infos.id;

CREATE TABLE packages_cleanup_policies (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    project_id bigint NOT NULL,
    next_run_at timestamp with time zone,
    keep_n_duplicated_package_files text DEFAULT 'all'::text NOT NULL,
    CONSTRAINT check_e53f35ab7b CHECK ((char_length(keep_n_duplicated_package_files) <= 255))
);

CREATE TABLE packages_composer_metadata (
    package_id bigint NOT NULL,
    target_sha bytea NOT NULL,
    composer_json jsonb DEFAULT '{}'::jsonb NOT NULL,
    version_cache_sha bytea,
    project_id bigint
);

CREATE TABLE packages_conan_file_metadata (
    id bigint NOT NULL,
    package_file_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    recipe_revision character varying(255) DEFAULT '0'::character varying NOT NULL,
    package_revision character varying(255),
    conan_package_reference character varying(255),
    conan_file_type smallint NOT NULL,
    recipe_revision_id bigint,
    package_revision_id bigint,
    package_reference_id bigint
);

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

ALTER SEQUENCE packages_conan_file_metadata_id_seq OWNED BY packages_conan_file_metadata.id;

CREATE TABLE packages_conan_metadata (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    package_username character varying(255) NOT NULL,
    package_channel character varying(255) NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE packages_conan_metadata_id_seq OWNED BY packages_conan_metadata.id;

CREATE TABLE packages_conan_package_references (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    project_id bigint NOT NULL,
    recipe_revision_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    reference bytea NOT NULL,
    info jsonb DEFAULT '{}'::jsonb NOT NULL,
    CONSTRAINT chk_conan_references_info_length CHECK ((char_length((info)::text) <= 20000))
);

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

ALTER SEQUENCE packages_conan_package_references_id_seq OWNED BY packages_conan_package_references.id;

CREATE TABLE packages_conan_package_revisions (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    project_id bigint NOT NULL,
    package_reference_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    revision bytea NOT NULL
);

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

ALTER SEQUENCE packages_conan_package_revisions_id_seq OWNED BY packages_conan_package_revisions.id;

CREATE TABLE packages_conan_recipe_revisions (
    id bigint NOT NULL,
    package_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,
    revision bytea NOT NULL
);

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

ALTER SEQUENCE packages_conan_recipe_revisions_id_seq OWNED BY packages_conan_recipe_revisions.id;

CREATE TABLE packages_debian_file_metadata (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    package_file_id bigint NOT NULL,
    file_type smallint NOT NULL,
    component text,
    architecture text,
    fields jsonb,
    CONSTRAINT check_2ebedda4b6 CHECK ((char_length(component) <= 255)),
    CONSTRAINT check_e6e1fffcca CHECK ((char_length(architecture) <= 255))
);

CREATE TABLE packages_debian_group_architectures (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    distribution_id bigint NOT NULL,
    name text NOT NULL,
    group_id bigint,
    CONSTRAINT check_ddb220164a CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE packages_debian_group_architectures_id_seq OWNED BY packages_debian_group_architectures.id;

CREATE TABLE packages_debian_group_component_files (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    component_id bigint NOT NULL,
    architecture_id bigint,
    size integer NOT NULL,
    file_type smallint NOT NULL,
    compression_type smallint,
    file_store smallint DEFAULT 1 NOT NULL,
    file text NOT NULL,
    file_sha256 bytea NOT NULL,
    CONSTRAINT check_839e1685bc CHECK ((char_length(file) <= 255))
);

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

ALTER SEQUENCE packages_debian_group_component_files_id_seq OWNED BY packages_debian_group_component_files.id;

CREATE TABLE packages_debian_group_components (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    distribution_id bigint NOT NULL,
    name text NOT NULL,
    group_id bigint,
    CONSTRAINT check_a9bc7d85be CHECK ((char_length(name) <= 255))
);

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

ALTER SEQUENCE packages_debian_group_components_id_seq OWNED BY packages_debian_group_components.id;

CREATE TABLE packages_debian_group_distribution_keys (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    distribution_id bigint NOT NULL,
    encrypted_private_key text NOT NULL,
    encrypted_private_key_iv text NOT NULL,
    encrypted_passphrase text NOT NULL,
    encrypted_passphrase_iv text NOT NULL,
    public_key text NOT NULL,
    fingerprint text NOT NULL,
    group_id bigint,
    CONSTRAINT check_bc95dc3fbe CHECK ((char_length(fingerprint) <= 255)),
    CONSTRAINT check_f708183491 CHECK ((char_length(public_key) <= 524288))
);

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

ALTER SEQUENCE packages_debian_group_distribution_keys_id_seq OWNED BY packages_debian_group_distribution_keys.id;

CREATE TABLE packages_debian_group_distributions (
    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,
    creator_id bigint,
    valid_time_duration_seconds integer,
    file_store smallint DEFAULT 1 NOT NULL,
    automatic boolean DEFAULT true NOT NULL,
    automatic_upgrades boolean DEFAULT false NOT NULL,
    codename text NOT NULL,
    suite text,
    origin text,
    label text,
    version text,
    description text,
    file text,
    file_signature text,
    signed_file text,
    signed_file_store smallint DEFAULT 1 NOT NULL,
    CONSTRAINT check_0007e0bf61 CHECK ((char_length(signed_file) <= 255)),
    CONSTRAINT check_310ac457b8 CHECK ((char_length(description) <= 255)),
    CONSTRAINT check_3d6f87fc31 CHECK ((char_length(file_signature) <= 4096)),
    CONSTRAINT check_3fdadf4a0c CHECK ((char_length(version) <= 255)),
    CONSTRAINT check_590e18405a CHECK ((char_length(codename) <= 255)),
    CONSTRAINT check_b057cd840a CHECK ((char_length(origin) <= 255)),
    CONSTRAINT check_be5ed8d307 CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_d3244bfc0b CHECK ((char_length(label) <= 255)),
    CONSTRAINT check_e7c928a24b CHECK ((char_length(suite) <= 255))
);

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

ALTER SEQUENCE packages_debian_group_distributions_id_seq OWNED BY packages_debian_group_distributions.id;

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

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

ALTER SEQUENCE packages_debian_project_architectures_id_seq OWNED BY packages_debian_project_architectures.id;

CREATE TABLE packages_debian_project_component_files (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    component_id bigint NOT NULL,
    architecture_id bigint,
    size integer NOT NULL,
    file_type smallint NOT NULL,
    compression_type smallint,
    file_store smallint DEFAULT 1 NOT NULL,
    file text NOT NULL,
    file_sha256 bytea NOT NULL,
    CONSTRAINT check_e5af03fa2d CHECK ((char_length(file) <= 255))
);

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

ALTER SEQUENCE packages_debian_project_component_files_id_seq OWNED BY packages_debian_project_component_files.id;

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

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

ALTER SEQUENCE packages_debian_project_components_id_seq OWNED BY packages_debian_project_components.id;

CREATE TABLE packages_debian_project_distribution_keys (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    distribution_id bigint NOT NULL,
    encrypted_private_key text NOT NULL,
    encrypted_private_key_iv text NOT NULL,
    encrypted_passphrase text NOT NULL,
    encrypted_passphrase_iv text NOT NULL,
    public_key text NOT NULL,
    fingerprint text NOT NULL,
    project_id bigint,
    CONSTRAINT check_9e8a5eef0a CHECK ((char_length(fingerprint) <= 255)),
    CONSTRAINT check_d188f6547f CHECK ((char_length(public_key) <= 524288))
);

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

ALTER SEQUENCE packages_debian_project_distribution_keys_id_seq OWNED BY packages_debian_project_distribution_keys.id;

CREATE TABLE packages_debian_project_distributions (
    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,
    creator_id bigint,
    valid_time_duration_seconds integer,
    file_store smallint DEFAULT 1 NOT NULL,
    automatic boolean DEFAULT true NOT NULL,
    automatic_upgrades boolean DEFAULT false NOT NULL,
    codename text NOT NULL,
    suite text,
    origin text,
    label text,
    version text,
    description text,
    file text,
    file_signature text,
    signed_file text,
    signed_file_store smallint DEFAULT 1 NOT NULL,
    CONSTRAINT check_6177ccd4a6 CHECK ((char_length(origin) <= 255)),
    CONSTRAINT check_6f6b55a4c4 CHECK ((char_length(label) <= 255)),
    CONSTRAINT check_834dabadb6 CHECK ((char_length(codename) <= 255)),
    CONSTRAINT check_96965792c2 CHECK ((char_length(version) <= 255)),
    CONSTRAINT check_9e5e22b7ff CHECK ((char_length(signed_file) <= 255)),
    CONSTRAINT check_a56ae58a17 CHECK ((char_length(suite) <= 255)),
    CONSTRAINT check_a5a2ac6af2 CHECK ((char_length(file_signature) <= 4096)),
    CONSTRAINT check_b93154339f CHECK ((char_length(description) <= 255)),
    CONSTRAINT check_cb4ac9599e CHECK ((char_length(file) <= 255))
);

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

ALTER SEQUENCE packages_debian_project_distributions_id_seq OWNED BY packages_debian_project_distributions.id;

CREATE TABLE packages_debian_publications (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    distribution_id bigint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE packages_debian_publications_id_seq OWNED BY packages_debian_publications.id;

CREATE TABLE packages_dependencies (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    version_pattern character varying(255) NOT NULL,
    project_id bigint,
    CONSTRAINT check_83faf1f5e7 CHECK ((project_id IS NOT NULL))
);

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

ALTER SEQUENCE packages_dependencies_id_seq OWNED BY packages_dependencies.id;

CREATE TABLE packages_dependency_links (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    dependency_id bigint NOT NULL,
    dependency_type smallint NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE packages_dependency_links_id_seq OWNED BY packages_dependency_links.id;

CREATE TABLE packages_helm_file_metadata (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    package_file_id bigint NOT NULL,
    channel text NOT NULL,
    metadata jsonb,
    CONSTRAINT check_06e8d100af CHECK ((char_length(channel) <= 255))
);

CREATE TABLE packages_maven_metadata (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    app_group character varying NOT NULL,
    app_name character varying NOT NULL,
    app_version character varying,
    path character varying(512) NOT NULL,
    project_id bigint
);

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

ALTER SEQUENCE packages_maven_metadata_id_seq OWNED BY packages_maven_metadata.id;

CREATE TABLE packages_npm_metadata (
    package_id bigint NOT NULL,
    package_json jsonb DEFAULT '{}'::jsonb NOT NULL,
    project_id bigint,
    CONSTRAINT chk_rails_e5cbc301ae CHECK ((char_length((package_json)::text) < 20000))
);

CREATE TABLE packages_npm_metadata_caches (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    last_downloaded_at timestamp with time zone,
    project_id bigint,
    file_store integer DEFAULT 1,
    size integer NOT NULL,
    file text NOT NULL,
    package_name text NOT NULL,
    object_storage_key text NOT NULL,
    status smallint DEFAULT 0 NOT NULL,
    CONSTRAINT check_57aa07a4b2 CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_734454a615 CHECK ((project_id IS NOT NULL)),
    CONSTRAINT check_f97c15aa60 CHECK ((char_length(object_storage_key) <= 255))
);

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

ALTER SEQUENCE packages_npm_metadata_caches_id_seq OWNED BY packages_npm_metadata_caches.id;

CREATE TABLE packages_nuget_dependency_link_metadata (
    dependency_link_id bigint NOT NULL,
    target_framework text NOT NULL,
    CONSTRAINT packages_nuget_dependency_link_metadata_target_framework_constr CHECK ((char_length(target_framework) <= 255))
);

CREATE TABLE packages_nuget_metadata (
    package_id bigint NOT NULL,
    license_url text,
    project_url text,
    icon_url text,
    authors text,
    description text,
    normalized_version text,
    project_id bigint,
    CONSTRAINT check_9973c0cc33 CHECK ((char_length(normalized_version) <= 255)),
    CONSTRAINT check_d39a5fe9ee CHECK ((char_length(description) <= 4000)),
    CONSTRAINT check_e2fc129ebd CHECK ((char_length(authors) <= 255)),
    CONSTRAINT packages_nuget_metadata_icon_url_constraint CHECK ((char_length(icon_url) <= 255)),
    CONSTRAINT packages_nuget_metadata_license_url_constraint CHECK ((char_length(license_url) <= 255)),
    CONSTRAINT packages_nuget_metadata_project_url_constraint CHECK ((char_length(project_url) <= 255))
);

CREATE TABLE packages_nuget_symbols (
    id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    package_id bigint,
    size integer NOT NULL,
    file_store smallint DEFAULT 1,
    file text NOT NULL,
    file_path text NOT NULL,
    signature text NOT NULL,
    object_storage_key text NOT NULL,
    file_sha256 bytea,
    status smallint DEFAULT 0 NOT NULL,
    project_id bigint,
    CONSTRAINT check_0e93ca58b7 CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_28b82b08fa CHECK ((char_length(object_storage_key) <= 255)),
    CONSTRAINT check_30b0ef2ca2 CHECK ((char_length(file_path) <= 255)),
    CONSTRAINT check_8dc7152679 CHECK ((char_length(signature) <= 255))
);

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

ALTER SEQUENCE packages_nuget_symbols_id_seq OWNED BY packages_nuget_symbols.id;

CREATE TABLE packages_package_file_build_infos (
    id bigint NOT NULL,
    package_file_id bigint NOT NULL,
    pipeline_id bigint
);

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

ALTER SEQUENCE packages_package_file_build_infos_id_seq OWNED BY packages_package_file_build_infos.id;

CREATE TABLE packages_package_files (
    id bigint NOT NULL,
    package_id bigint NOT NULL,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    size bigint,
    file_store integer DEFAULT 1,
    file_md5 bytea,
    file_sha1 bytea,
    file_name character varying NOT NULL,
    file text NOT NULL,
    file_sha256 bytea,
    verification_retry_at timestamp with time zone,
    verified_at timestamp with time zone,
    verification_failure character varying(255),
    verification_retry_count integer,
    verification_checksum bytea,
    verification_state smallint DEFAULT 0 NOT NULL,
    verification_started_at timestamp with time zone,
    status smallint DEFAULT 0 NOT NULL,
    file_final_path text,
    project_id bigint,
    CONSTRAINT check_0f29938b18 CHECK ((char_length(file_final_path) <= 1024)),
    CONSTRAINT check_4c5e6bb0b3 CHECK ((file_store IS NOT NULL))
);

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

ALTER SEQUENCE packages_package_files_id_seq OWNED BY packages_package_files.id;

CREATE TABLE packages_packages (
    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,
    name character varying NOT NULL,
    version character varying,
    package_type smallint NOT NULL,
    creator_id bigint,
    status smallint DEFAULT 0 NOT NULL,
    last_downloaded_at timestamp with time zone,
    status_message text
);

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

ALTER SEQUENCE packages_packages_id_seq OWNED BY packages_packages.id;

CREATE TABLE packages_protection_rules (
    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,
    package_type smallint NOT NULL,
    package_name_pattern text NOT NULL,
    minimum_access_level_for_push smallint,
    CONSTRAINT check_12e13c202a CHECK ((minimum_access_level_for_push IS NOT NULL)),
    CONSTRAINT check_d2d75d206d CHECK ((char_length(package_name_pattern) <= 255))
);

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

ALTER SEQUENCE packages_protection_rules_id_seq OWNED BY packages_protection_rules.id;

CREATE TABLE packages_pypi_metadata (
    package_id bigint NOT NULL,
    required_python text DEFAULT ''::text,
    metadata_version text,
    summary text,
    keywords text,
    author_email text,
    description text,
    description_content_type text,
    project_id bigint,
    CONSTRAINT check_0d9aed55b2 CHECK ((required_python IS NOT NULL)),
    CONSTRAINT check_222e4f5b58 CHECK ((char_length(keywords) <= 1024)),
    CONSTRAINT check_2d3ed32225 CHECK ((char_length(metadata_version) <= 16)),
    CONSTRAINT check_379019d5da CHECK ((char_length(required_python) <= 255)),
    CONSTRAINT check_65d8dbbd9f CHECK ((char_length(author_email) <= 2048)),
    CONSTRAINT check_76afb6d4f3 CHECK ((char_length(summary) <= 255)),
    CONSTRAINT check_80308aa9bd CHECK ((char_length(description) <= 4000)),
    CONSTRAINT check_b1f32be96c CHECK ((char_length(description_content_type) <= 128))
);

CREATE TABLE packages_rpm_metadata (
    package_id bigint NOT NULL,
    release text DEFAULT '1'::text NOT NULL,
    summary text DEFAULT ''::text NOT NULL,
    description text DEFAULT ''::text NOT NULL,
    arch text DEFAULT ''::text NOT NULL,
    license text,
    url text,
    epoch integer DEFAULT 0 NOT NULL,
    project_id bigint,
    CONSTRAINT check_3798bae3d6 CHECK ((char_length(arch) <= 255)),
    CONSTRAINT check_5d29ba59ac CHECK ((char_length(description) <= 5000)),
    CONSTRAINT check_6e8cbd536d CHECK ((char_length(url) <= 1000)),
    CONSTRAINT check_845ba4d7d0 CHECK ((char_length(license) <= 1000)),
    CONSTRAINT check_b010bf4870 CHECK ((char_length(summary) <= 1000)),
    CONSTRAINT check_c3e2fc2e89 CHECK ((char_length(release) <= 128))
);

CREATE TABLE packages_rpm_repository_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,
    file_store integer DEFAULT 1,
    status smallint DEFAULT 0 NOT NULL,
    size integer,
    file_md5 bytea,
    file_sha1 bytea,
    file_sha256 bytea,
    file text NOT NULL,
    file_name text NOT NULL,
    CONSTRAINT check_a9fef187f5 CHECK ((char_length(file) <= 255)),
    CONSTRAINT check_b6b721b275 CHECK ((char_length(file_name) <= 255))
);

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

ALTER SEQUENCE packages_rpm_repository_files_id_seq OWNED BY packages_rpm_repository_files.id;

CREATE TABLE packages_rubygems_metadata (
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    package_id bigint NOT NULL,
    authors text,
    files text,
    summary text,
    description text,
    email text,
    homepage text,
    licenses text,
    metadata text,
    author text,
    bindir text,
    cert_chain text,
    executables text,
    extensions text,
    extra_rdoc_files text,
    platform text,
    post_install_message text,
    rdoc_options text,
    require_paths text,
    required_ruby_version text,
    required_rubygems_version text,
    requirements text,
    rubygems_version text,
    signing_key text,
    project_id bigint,
    CONSTRAINT check_0154a18c82 CHECK ((char_length(description) <= 1024)),
    CONSTRAINT check_22814c771b CHECK ((char_length(email) <= 255)),
    CONSTRAINT check_242293030e CHECK ((char_length(extensions) <= 255)),
    CONSTRAINT check_27619a7922 CHECK ((char_length(rubygems_version) <= 255)),
    CONSTRAINT check_3d1b6f3a39 CHECK ((char_length(post_install_message) <= 255)),
    CONSTRAINT check_545f7606f9 CHECK ((char_length(required_rubygems_version) <= 255)),
    CONSTRAINT check_5988451714 CHECK ((char_length(executables) <= 255)),
    CONSTRAINT check_5f9c84ea17 CHECK ((char_length(platform) <= 255)),
    CONSTRAINT check_64f1cecf05 CHECK ((char_length(requirements) <= 255)),
    CONSTRAINT check_6ac7043c50 CHECK ((char_length(extra_rdoc_files) <= 255)),
    CONSTRAINT check_6ff3abe325 CHECK ((char_length(cert_chain) <= 255)),
    CONSTRAINT check_7cb01436df CHECK ((char_length(licenses) <= 255)),
    CONSTRAINT check_8be21d92e7 CHECK ((char_length(summary) <= 1024)),
    CONSTRAINT check_946cb96acb CHECK ((char_length(homepage) <= 255)),
    CONSTRAINT check_9824fc9efc CHECK ((char_length(bindir) <= 255)),
    CONSTRAINT check_994b68eb64 CHECK ((char_length(authors) <= 255)),
    CONSTRAINT check_9d42fa48ae CHECK ((char_length(signing_key) <= 255)),
    CONSTRAINT check_b0f4f8c853 CHECK ((char_length(files) <= 255)),
    CONSTRAINT check_b7b296b420 CHECK ((char_length(author) <= 255)),
    CONSTRAINT check_bf16b21a47 CHECK ((char_length(rdoc_options) <= 255)),
    CONSTRAINT check_ca641a3354 CHECK ((char_length(required_ruby_version) <= 255)),
    CONSTRAINT check_ea02f4800f CHECK ((char_length(metadata) <= 30000)),
    CONSTRAINT check_f76bad1a9a CHECK ((char_length(require_paths) <= 255))
);

