Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-26 21:10:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-26 21:10:52 +0300
commit4c47bc5ec6420ab3a4ef629010e89de45b2776b9 (patch)
tree941f43a86f23dc601a0778571a36f53dfb4c44c6 /db
parentede9464fd957582e4e0232f70113942b08ddfe78 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20210511165250_add_foreign_key_to_lfs_objects_projects.rb19
-rw-r--r--db/post_migrate/20210514063252_schedule_cleanup_orphaned_lfs_objects_projects.rb27
-rw-r--r--db/schema_migrations/202105111652501
-rw-r--r--db/schema_migrations/202105140632521
-rw-r--r--db/structure.sql6
5 files changed, 54 insertions, 0 deletions
diff --git a/db/migrate/20210511165250_add_foreign_key_to_lfs_objects_projects.rb b/db/migrate/20210511165250_add_foreign_key_to_lfs_objects_projects.rb
new file mode 100644
index 00000000000..4163499a553
--- /dev/null
+++ b/db/migrate/20210511165250_add_foreign_key_to_lfs_objects_projects.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddForeignKeyToLfsObjectsProjects < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :lfs_objects_projects, :lfs_objects, column: :lfs_object_id, on_delete: :restrict, validate: false
+ add_concurrent_foreign_key :lfs_objects_projects, :projects, column: :project_id, on_delete: :cascade, validate: false
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :lfs_objects_projects, column: :lfs_object_id
+ remove_foreign_key :lfs_objects_projects, column: :project_id
+ end
+ end
+end
diff --git a/db/post_migrate/20210514063252_schedule_cleanup_orphaned_lfs_objects_projects.rb b/db/post_migrate/20210514063252_schedule_cleanup_orphaned_lfs_objects_projects.rb
new file mode 100644
index 00000000000..76e4a0a95bb
--- /dev/null
+++ b/db/post_migrate/20210514063252_schedule_cleanup_orphaned_lfs_objects_projects.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class ScheduleCleanupOrphanedLfsObjectsProjects < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ MIGRATION = 'CleanupOrphanedLfsObjectsProjects'
+ DELAY_INTERVAL = 2.minutes
+ BATCH_SIZE = 50_000
+
+ disable_ddl_transaction!
+
+ class LfsObjectsProject < ActiveRecord::Base
+ self.table_name = 'lfs_objects_projects'
+
+ include ::EachBatch
+ end
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(LfsObjectsProject, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
+ end
+
+ def down
+ # NOOP
+ end
+end
diff --git a/db/schema_migrations/20210511165250 b/db/schema_migrations/20210511165250
new file mode 100644
index 00000000000..d68bd28d356
--- /dev/null
+++ b/db/schema_migrations/20210511165250
@@ -0,0 +1 @@
+8f746d7eb604ae31a5941840d6a078eae2e4fa59b7185bf8cc0db9c55b463c33 \ No newline at end of file
diff --git a/db/schema_migrations/20210514063252 b/db/schema_migrations/20210514063252
new file mode 100644
index 00000000000..848265418d2
--- /dev/null
+++ b/db/schema_migrations/20210514063252
@@ -0,0 +1 @@
+7e52f9ba8470fd8c2e149fea723c9b06b92ecde2dac4db4512534b3e23952c61 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 4f73435d562..5c5aeaf93a9 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -25459,6 +25459,9 @@ ALTER TABLE ONLY notes
ALTER TABLE ONLY members
ADD CONSTRAINT fk_2e88fb7ce9 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+ALTER TABLE ONLY lfs_objects_projects
+ ADD CONSTRAINT fk_2eb33f7a78 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE NOT VALID;
+
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_30f2a831f4 FOREIGN KEY (iteration_id) REFERENCES sprints(id) ON DELETE CASCADE;
@@ -25771,6 +25774,9 @@ ALTER TABLE ONLY bulk_import_entities
ALTER TABLE ONLY users
ADD CONSTRAINT fk_a4b8fefe3e FOREIGN KEY (managing_group_id) REFERENCES namespaces(id) ON DELETE SET NULL;
+ALTER TABLE ONLY lfs_objects_projects
+ ADD CONSTRAINT fk_a56e02279c FOREIGN KEY (lfs_object_id) REFERENCES lfs_objects(id) ON DELETE RESTRICT NOT VALID;
+
ALTER TABLE ONLY dast_profiles_pipelines
ADD CONSTRAINT fk_a60cad829d FOREIGN KEY (ci_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE;