diff --git a/db/migrate/20250923074051_add_default_value_to_workspace_desired_config_generator_version.rb b/db/migrate/20250923074051_add_default_value_to_workspace_desired_config_generator_version.rb new file mode 100644 index 0000000000000000000000000000000000000000..d1d29fce30a3041251b90c055f97338c09b7bd68 --- /dev/null +++ b/db/migrate/20250923074051_add_default_value_to_workspace_desired_config_generator_version.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddDefaultValueToWorkspaceDesiredConfigGeneratorVersion < Gitlab::Database::Migration[2.3] + milestone '18.5' + + def up + change_column_default :workspaces, :desired_config_generator_version, 3 + end + + def down + change_column_default :workspaces, :desired_config_generator_version, nil + end +end diff --git a/db/migrate/20251001180828_add_index_on_workspace_desired_config_generator_version.rb b/db/migrate/20251001180828_add_index_on_workspace_desired_config_generator_version.rb new file mode 100644 index 0000000000000000000000000000000000000000..2f5943e6679d78c17cfe0150e2d5ef19efd78b8d --- /dev/null +++ b/db/migrate/20251001180828_add_index_on_workspace_desired_config_generator_version.rb @@ -0,0 +1,22 @@ +# 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 AddIndexOnWorkspaceDesiredConfigGeneratorVersion < Gitlab::Database::Migration[2.3] + milestone '18.5' + disable_ddl_transaction! + + def up + add_concurrent_index( + :workspaces, + :id, + where: "desired_config_generator_version IS NULL", + name: "idx_workspaces_null_config_version_id" + ) + end + + def down + remove_concurrent_index_by_name :workspaces, name: "idx_workspaces_null_config_version_id" + end +end diff --git a/db/post_migrate/20251001180830_update_nil_desired_config_generator_version_workspace.rb b/db/post_migrate/20251001180830_update_nil_desired_config_generator_version_workspace.rb new file mode 100644 index 0000000000000000000000000000000000000000..fd5741415a19c09ae1de651600ce1c48b2cdf102 --- /dev/null +++ b/db/post_migrate/20251001180830_update_nil_desired_config_generator_version_workspace.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class UpdateNilDesiredConfigGeneratorVersionWorkspace < Gitlab::Database::Migration[2.3] + disable_ddl_transaction! + restrict_gitlab_migration gitlab_schema: :gitlab_main + milestone '18.5' + + def up + workspaces = define_batchable_model('workspaces') + + workspaces + .where(desired_config_generator_version: nil) + .each_batch(of: 50) do |batch| + batch.update_all(desired_config_generator_version: 3) + end + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20250923074051 b/db/schema_migrations/20250923074051 new file mode 100644 index 0000000000000000000000000000000000000000..7a6ba4c41a1361572889c301a266eb9a9feadce9 --- /dev/null +++ b/db/schema_migrations/20250923074051 @@ -0,0 +1 @@ +89070fe81a15bdc3f7a7918db13ca5ddf1cd585b196c21ca696173c3e18cf52e \ No newline at end of file diff --git a/db/schema_migrations/20251001180828 b/db/schema_migrations/20251001180828 new file mode 100644 index 0000000000000000000000000000000000000000..7baab5be2bd8b7141c08861ad34e861b0299fabd --- /dev/null +++ b/db/schema_migrations/20251001180828 @@ -0,0 +1 @@ +2aea40daf2bbc511b242523e9f42d1a87eea01d59dfcb1b36760dfad066a659e \ No newline at end of file diff --git a/db/schema_migrations/20251001180830 b/db/schema_migrations/20251001180830 new file mode 100644 index 0000000000000000000000000000000000000000..97ef1410f5952d5c3c490eccfdae768b7778a0ca --- /dev/null +++ b/db/schema_migrations/20251001180830 @@ -0,0 +1 @@ +8f8b2a331aa56032628eee28b07756bf83b1501a42665f99a82bdb5cd03338ad \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 211863b3de8a53014ad8a5c44f7a3f301a9b82a1..110754bdce941565b6f1f22787680c614e386dde 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -29315,7 +29315,7 @@ CREATE TABLE workspaces ( url_prefix text, url_query_string text, workspaces_agent_config_version integer NOT NULL, - desired_config_generator_version integer, + desired_config_generator_version integer DEFAULT 3, project_ref text, actual_state_updated_at timestamp with time zone NOT NULL, CONSTRAINT check_15543fb0fa CHECK ((char_length(name) <= 64)), @@ -38164,6 +38164,8 @@ CREATE INDEX idx_wi_type_custom_lifecycles_on_work_item_type_id ON work_item_typ CREATE INDEX idx_workflows_status_updated_at_id ON duo_workflows_workflows USING btree (status, updated_at, id); +CREATE INDEX idx_workspaces_null_config_version_id ON workspaces USING btree (id) WHERE (desired_config_generator_version IS NULL); + CREATE INDEX idx_zoekt_last_indexed_at_gt_used_storage_bytes_updated_at ON zoekt_indices USING btree (used_storage_bytes_updated_at) WHERE (last_indexed_at >= used_storage_bytes_updated_at); CREATE INDEX idx_zoekt_repositories_on_zoekt_index_id_and_size_bytes ON zoekt_repositories USING btree (zoekt_index_id, size_bytes);