diff options
author | Sean McGivern <sean@gitlab.com> | 2017-07-03 15:48:59 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-07-05 13:12:09 +0100 |
commit | 3729adfe3d5e0184f8bd43451fc78221101dfb56 (patch) | |
tree | e6399b9169ce0cbf697349d67396d69bb8e053d2 /db | |
parent | 657bf16b959beefff58acdc546d5afde60708e6e (diff) | |
download | gitlab-ce-merge-request-commits-table.tar.gz |
Migrate MR commits and diffs to new tablesmerge-request-commits-table
Previously, we stored these as serialised fields - `st_{commits,diffs}` - on the
`merge_request_diffs` table. These now have their own tables -
`merge_request_diff_{commits,diffs}` - with a column for each attribute of the
serialised data.
Add a background migration to go through the existing MR diffs and migrate them
to the new format. Ignore any contents that cannot be displayed.
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb | 24 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb new file mode 100644 index 00000000000..ae53e3e1ab3 --- /dev/null +++ b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb @@ -0,0 +1,24 @@ +class ScheduleMergeRequestDiffMigrations < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + class MergeRequestDiff < ActiveRecord::Base + self.table_name = 'merge_request_diffs' + end + + def up + MergeRequestDiff.all.in_batches do |relation| + jobs = relation.pluck(:id).map do |id| + ['DeserializeMergeRequestDiffsAndCommits', [id]] + end + + BackgroundMigrationWorker.perform_bulk(*jobs) + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 4937f290d3e..b51e4942750 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170623080805) do +ActiveRecord::Schema.define(version: 20170703130158) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |