diff options
Diffstat (limited to 'db/migrate')
15 files changed, 310 insertions, 0 deletions
diff --git a/db/migrate/20201029144524_add_index_to_releases.rb b/db/migrate/20201029144524_add_index_to_releases.rb new file mode 100644 index 00000000000..fbffa1453af --- /dev/null +++ b/db/migrate/20201029144524_add_index_to_releases.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexToReleases < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_releases_on_released_at' + + disable_ddl_transaction! + + def up + add_concurrent_index :releases, :released_at, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :releases, INDEX_NAME + end +end diff --git a/db/migrate/20201103045515_add_issuable_metric_images.rb b/db/migrate/20201103045515_add_issuable_metric_images.rb new file mode 100644 index 00000000000..c598bb468a1 --- /dev/null +++ b/db/migrate/20201103045515_add_issuable_metric_images.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class AddIssuableMetricImages < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless table_exists?(:issuable_metric_images) + with_lock_retries do + create_table :issuable_metric_images do |t| + t.references :issue, null: false, index: true, foreign_key: { on_delete: :cascade } + t.timestamps_with_timezone + t.integer :file_store, limit: 2 + t.text :file, null: false + t.text :url + end + end + end + + add_text_limit(:issuable_metric_images, :url, 255) + add_text_limit(:issuable_metric_images, :file, 255) + end + + def down + with_lock_retries do + drop_table :issuable_metric_images + end + end +end diff --git a/db/migrate/20201109080645_create_vulnerability_remediations_table.rb b/db/migrate/20201109080645_create_vulnerability_remediations_table.rb new file mode 100644 index 00000000000..b00ce797c7d --- /dev/null +++ b/db/migrate/20201109080645_create_vulnerability_remediations_table.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class CreateVulnerabilityRemediationsTable < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + create_table :vulnerability_remediations, if_not_exists: true do |t| + t.timestamps_with_timezone + + t.integer :file_store, limit: 2 + t.text :summary, null: false + t.text :file, null: false + end + + add_text_limit :vulnerability_remediations, :summary, 200 + add_text_limit :vulnerability_remediations, :file, 255 + end + + def down + drop_table :vulnerability_remediations + end +end diff --git a/db/migrate/20201109080646_create_vulnerability_findings_remediations_join_table.rb b/db/migrate/20201109080646_create_vulnerability_findings_remediations_join_table.rb new file mode 100644 index 00000000000..157f0de0821 --- /dev/null +++ b/db/migrate/20201109080646_create_vulnerability_findings_remediations_join_table.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CreateVulnerabilityFindingsRemediationsJoinTable < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + create_table :vulnerability_findings_remediations do |t| + t.references :vulnerability_occurrence, index: false, foreign_key: { on_delete: :cascade } + t.references :vulnerability_remediation, index: { name: 'index_vulnerability_findings_remediations_on_remediation_id' }, foreign_key: { on_delete: :cascade } + + t.timestamps_with_timezone + + t.index [:vulnerability_occurrence_id, :vulnerability_remediation_id], unique: true, name: 'index_vulnerability_findings_remediations_on_unique_keys' + end + end +end diff --git a/db/migrate/20201111115414_create_incident_management_oncall_schedules.rb b/db/migrate/20201111115414_create_incident_management_oncall_schedules.rb new file mode 100644 index 00000000000..dbb7d1c0808 --- /dev/null +++ b/db/migrate/20201111115414_create_incident_management_oncall_schedules.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class CreateIncidentManagementOncallSchedules < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + unless table_exists?(:incident_management_oncall_schedules) + create_table :incident_management_oncall_schedules do |t| + t.timestamps_with_timezone + t.references :project, index: true, null: false, foreign_key: { on_delete: :cascade } + t.integer :iid, null: false + t.text :name, null: false + t.text :description + t.text :timezone + + t.index %w(project_id iid), name: 'index_im_oncall_schedules_on_project_id_and_iid', unique: true, using: :btree + end + end + end + + add_text_limit :incident_management_oncall_schedules, :name, 200 + add_text_limit :incident_management_oncall_schedules, :description, 1000 + add_text_limit :incident_management_oncall_schedules, :timezone, 100 + end + + def down + with_lock_retries do + drop_table :incident_management_oncall_schedules + end + end +end diff --git a/db/migrate/20201112173532_add_verification_state_to_package_files.rb b/db/migrate/20201112173532_add_verification_state_to_package_files.rb new file mode 100644 index 00000000000..61f526bd77e --- /dev/null +++ b/db/migrate/20201112173532_add_verification_state_to_package_files.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddVerificationStateToPackageFiles < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :packages_package_files, :verification_state, :integer, default: 0, limit: 2, null: false + add_column :packages_package_files, :verification_started_at, :datetime_with_timezone + end +end diff --git a/db/migrate/20201112173911_add_index_on_verification_state_on_package_files.rb b/db/migrate/20201112173911_add_index_on_verification_state_on_package_files.rb new file mode 100644 index 00000000000..17e6b7d01f6 --- /dev/null +++ b/db/migrate/20201112173911_add_index_on_verification_state_on_package_files.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexOnVerificationStateOnPackageFiles < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_packages_package_files_on_verification_state' + + disable_ddl_transaction! + + def up + add_concurrent_index :packages_package_files, :verification_state, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :packages_package_files, INDEX_NAME + end +end diff --git a/db/migrate/20201112215028_add_partitioned_audit_event_indexes.rb b/db/migrate/20201112215028_add_partitioned_audit_event_indexes.rb new file mode 100644 index 00000000000..d8b2833474b --- /dev/null +++ b/db/migrate/20201112215028_add_partitioned_audit_event_indexes.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class AddPartitionedAuditEventIndexes < ActiveRecord::Migration[6.0] + include Gitlab::Database::PartitioningMigrationHelpers + + DOWNTIME = false + + CREATED_AT_AUTHOR_ID_INDEX_NAME = 'analytics_index_audit_events_part_on_created_at_and_author_id' + ENTITY_ID_DESC_INDEX_NAME = 'idx_audit_events_part_on_entity_id_desc_author_id_created_at' + + disable_ddl_transaction! + + def up + add_concurrent_partitioned_index :audit_events_part_5fc467ac26, + [:created_at, :author_id], + name: CREATED_AT_AUTHOR_ID_INDEX_NAME + + add_concurrent_partitioned_index :audit_events_part_5fc467ac26, + [:entity_id, :entity_type, :id, :author_id, :created_at], + order: { id: :desc }, + name: ENTITY_ID_DESC_INDEX_NAME + end + + def down + remove_concurrent_partitioned_index_by_name :audit_events_part_5fc467ac26, ENTITY_ID_DESC_INDEX_NAME + + remove_concurrent_partitioned_index_by_name :audit_events_part_5fc467ac26, CREATED_AT_AUTHOR_ID_INDEX_NAME + end +end diff --git a/db/migrate/20201116211829_create_user_permission_export_uploads.rb b/db/migrate/20201116211829_create_user_permission_export_uploads.rb new file mode 100644 index 00000000000..d6207fe0c2c --- /dev/null +++ b/db/migrate/20201116211829_create_user_permission_export_uploads.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class CreateUserPermissionExportUploads < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + with_lock_retries do + unless table_exists?(:user_permission_export_uploads) + create_table :user_permission_export_uploads do |t| + t.timestamps_with_timezone null: false + t.references :user, foreign_key: { on_delete: :cascade }, index: false, null: false + t.integer :file_store + t.integer :status, limit: 2, null: false, default: 0 + t.text :file + + t.index [:user_id, :status] + end + end + end + + add_text_limit :user_permission_export_uploads, :file, 255 + end + + def down + with_lock_retries do + drop_table :user_permission_export_uploads + end + end +end diff --git a/db/migrate/20201117054609_add_cloud_license_enabled_to_settings.rb b/db/migrate/20201117054609_add_cloud_license_enabled_to_settings.rb new file mode 100644 index 00000000000..4488aa376a1 --- /dev/null +++ b/db/migrate/20201117054609_add_cloud_license_enabled_to_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddCloudLicenseEnabledToSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :cloud_license_enabled, :boolean, null: false, default: false + end +end diff --git a/db/migrate/20201117075742_change_webauthn_xid_length.rb b/db/migrate/20201117075742_change_webauthn_xid_length.rb new file mode 100644 index 00000000000..2d836662e01 --- /dev/null +++ b/db/migrate/20201117075742_change_webauthn_xid_length.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class ChangeWebauthnXidLength < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_text_limit :webauthn_registrations, :credential_xid, 340, constraint_name: check_constraint_name(:webauthn_registrations, :credential_xid, 'max_length_v2') + remove_text_limit :webauthn_registrations, :credential_xid, constraint_name: check_constraint_name(:webauthn_registrations, :credential_xid, 'max_length') + end + + def down + # no-op: Danger of failling if there are records with length(credential_xid) > 255 + end +end diff --git a/db/migrate/20201118093135_create_namespace_onboarding_actions.rb b/db/migrate/20201118093135_create_namespace_onboarding_actions.rb new file mode 100644 index 00000000000..6b38a0dddca --- /dev/null +++ b/db/migrate/20201118093135_create_namespace_onboarding_actions.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class CreateNamespaceOnboardingActions < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + create_table :namespace_onboarding_actions do |t| + t.references :namespace, index: true, null: false, foreign_key: { on_delete: :cascade } + t.datetime_with_timezone :created_at, null: false + t.integer :action, limit: 2, null: false + end + end + end + + def down + with_lock_retries do + drop_table :namespace_onboarding_actions + end + end +end diff --git a/db/migrate/20201119164605_add_checksum_into_vulnerability_remediations.rb b/db/migrate/20201119164605_add_checksum_into_vulnerability_remediations.rb new file mode 100644 index 00000000000..a9ac1ed0676 --- /dev/null +++ b/db/migrate/20201119164605_add_checksum_into_vulnerability_remediations.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddChecksumIntoVulnerabilityRemediations < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :vulnerability_remediations, :checksum, :binary, null: false, comment: 'Stores the SHA256 checksum of the attached diff file' # rubocop:disable Rails/NotNullColumn + + add_index :vulnerability_remediations, :checksum, unique: true # rubocop:disable Migration/AddIndex (Table is empty) + end +end diff --git a/db/migrate/20201119213406_change_terraform_versioning_enabled_default.rb b/db/migrate/20201119213406_change_terraform_versioning_enabled_default.rb new file mode 100644 index 00000000000..490fe481589 --- /dev/null +++ b/db/migrate/20201119213406_change_terraform_versioning_enabled_default.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class ChangeTerraformVersioningEnabledDefault < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + change_column_default :terraform_states, :versioning_enabled, from: false, to: true + end +end diff --git a/db/migrate/20201120125953_replace_unused_labels_index.rb b/db/migrate/20201120125953_replace_unused_labels_index.rb new file mode 100644 index 00000000000..afddbce618d --- /dev/null +++ b/db/migrate/20201120125953_replace_unused_labels_index.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class ReplaceUnusedLabelsIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + NEW_INDEX_NAME = 'index_labels_on_group_id_and_title_with_null_project_id' + OLD_INDEX_NAME = 'index_labels_on_group_id_and_title' + + def up + add_concurrent_index :labels, [:group_id, :title], where: 'project_id IS NULL', name: NEW_INDEX_NAME + remove_concurrent_index_by_name :labels, OLD_INDEX_NAME + end + + def down + add_concurrent_index :labels, [:group_id, :title], where: 'project_id = NULL::integer', name: OLD_INDEX_NAME + remove_concurrent_index_by_name :labels, NEW_INDEX_NAME + end +end |