From bfb5557b15d66fc1c22aeec5c345241946b103a3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 21 Feb 2023 03:12:30 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- db/docs/namespace_ldap_settings.yml | 10 +++++++ db/docs/p_ci_runner_machine_builds.yml | 4 +-- ...0230113164245_create_namespace_ldap_settings.rb | 16 +++++++++++ ...30113201308_backfill_namespace_ldap_settings.rb | 33 ++++++++++++++++++++++ db/schema_migrations/20230113164245 | 1 + db/schema_migrations/20230113201308 | 1 + db/structure.sql | 18 ++++++++++++ 7 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 db/docs/namespace_ldap_settings.yml create mode 100644 db/migrate/20230113164245_create_namespace_ldap_settings.rb create mode 100644 db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb create mode 100644 db/schema_migrations/20230113164245 create mode 100644 db/schema_migrations/20230113201308 (limited to 'db') diff --git a/db/docs/namespace_ldap_settings.yml b/db/docs/namespace_ldap_settings.yml new file mode 100644 index 00000000000..d30a835b55f --- /dev/null +++ b/db/docs/namespace_ldap_settings.yml @@ -0,0 +1,10 @@ +--- +table_name: namespace_ldap_settings +classes: + - Namespaces::LdapSetting +feature_categories: + - authentication_and_authorization +description: Used to store LDAP settings for namespaces +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/108908 +milestone: '15.10' +gitlab_schema: gitlab_main diff --git a/db/docs/p_ci_runner_machine_builds.yml b/db/docs/p_ci_runner_machine_builds.yml index 8ffac67fb94..f0e8ed26caf 100644 --- a/db/docs/p_ci_runner_machine_builds.yml +++ b/db/docs/p_ci_runner_machine_builds.yml @@ -1,6 +1,6 @@ +--- table_name: p_ci_runner_machine_builds -classes: -- Ci::RunnerMachineBuild +classes: [] feature_categories: - runner_fleet description: Relationships between builds and runner machines diff --git a/db/migrate/20230113164245_create_namespace_ldap_settings.rb b/db/migrate/20230113164245_create_namespace_ldap_settings.rb new file mode 100644 index 00000000000..5ad72c00b47 --- /dev/null +++ b/db/migrate/20230113164245_create_namespace_ldap_settings.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CreateNamespaceLdapSettings < Gitlab::Database::Migration[2.1] + def change + create_table :namespace_ldap_settings, if_not_exists: true, id: false do |t| + t.references :namespace, primary_key: true, default: nil, + type: :bigint, index: false, foreign_key: { on_delete: :cascade } + t.timestamps_with_timezone null: false + t.column :sync_last_start_at, :datetime_with_timezone + t.column :sync_last_update_at, :datetime_with_timezone + t.column :sync_last_successful_at, :datetime_with_timezone + t.integer :sync_status, null: false, default: 0, limit: 2 + t.text :sync_error, limit: 255 + end + end +end diff --git a/db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb b/db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb new file mode 100644 index 00000000000..19020fecad5 --- /dev/null +++ b/db/post_migrate/20230113201308_backfill_namespace_ldap_settings.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class BackfillNamespaceLdapSettings < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + disable_ddl_transaction! + + DOWNTIME = false + MIGRATION = 'BackfillNamespaceLdapSettings' + TABLE_NAME = 'namespaces' + PRIMARY_KEY = :id + INTERVAL = 2.minutes + + def up + queue_batched_background_migration( + MIGRATION, + TABLE_NAME, + PRIMARY_KEY, + job_interval: INTERVAL + ) + end + + def down + delete_batched_background_migration( + MIGRATION, + TABLE_NAME, + PRIMARY_KEY, + [] + ) + end +end diff --git a/db/schema_migrations/20230113164245 b/db/schema_migrations/20230113164245 new file mode 100644 index 00000000000..2c8b04d4387 --- /dev/null +++ b/db/schema_migrations/20230113164245 @@ -0,0 +1 @@ +eb2dfc21c5645e1f8aec9118a380c270525ce261a86ce13f89de891a8c4fa3a9 \ No newline at end of file diff --git a/db/schema_migrations/20230113201308 b/db/schema_migrations/20230113201308 new file mode 100644 index 00000000000..df391813488 --- /dev/null +++ b/db/schema_migrations/20230113201308 @@ -0,0 +1 @@ +775842b84022cf30d685060ea956c1e52722587f2be517d44ae44ca57f954538 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index caddc2a4956..2eddcb57bdc 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -18405,6 +18405,18 @@ CREATE TABLE namespace_details ( next_over_limit_check_at timestamp with time zone ); +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, @@ -26963,6 +26975,9 @@ ALTER TABLE ONLY namespace_commit_emails ALTER TABLE ONLY namespace_details ADD CONSTRAINT namespace_details_pkey PRIMARY KEY (namespace_id); +ALTER TABLE ONLY namespace_ldap_settings + ADD CONSTRAINT namespace_ldap_settings_pkey PRIMARY KEY (namespace_id); + ALTER TABLE ONLY namespace_limits ADD CONSTRAINT namespace_limits_pkey PRIMARY KEY (namespace_id); @@ -35660,6 +35675,9 @@ ALTER TABLE ONLY approval_merge_request_rules_users ALTER TABLE ONLY required_code_owners_sections ADD CONSTRAINT fk_rails_817708cf2d FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE; +ALTER TABLE ONLY namespace_ldap_settings + ADD CONSTRAINT fk_rails_82cd0ad4bb FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY cluster_enabled_grants ADD CONSTRAINT fk_rails_8336ce35af FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; -- cgit v1.2.1