diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-11-06 13:44:30 -0800 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-12-01 15:26:40 -0800 |
commit | d6435b68c4fc4e0325ec6a3deb807d0e3dd4dec4 (patch) | |
tree | cdbd6798a03c9912089b5a9a23d385e47b4e5d97 /db | |
parent | e0f84130567dc34edf1ae75fcf595e24991d2fa9 (diff) | |
download | gitlab-ce-d6435b68c4fc4e0325ec6a3deb807d0e3dd4dec4.tar.gz |
Add TrackUntrackedUploads post-deploy migration
To create the table, and schedule the background migration that begins the work.
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20171103140253_track_untracked_uploads.rb | 37 | ||||
-rw-r--r-- | db/schema.rb | 10 |
2 files changed, 47 insertions, 0 deletions
diff --git a/db/post_migrate/20171103140253_track_untracked_uploads.rb b/db/post_migrate/20171103140253_track_untracked_uploads.rb new file mode 100644 index 00000000000..90d530d4011 --- /dev/null +++ b/db/post_migrate/20171103140253_track_untracked_uploads.rb @@ -0,0 +1,37 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class TrackUntrackedUploads < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + DOWNTIME = false + MIGRATION = 'PrepareUnhashedUploads' + + def up + unless table_exists?(:unhashed_upload_files) + create_table :unhashed_upload_files do |t| + t.string :path, null: false + t.boolean :tracked, default: false, null: false + t.timestamps_with_timezone null: false + end + end + + unless index_exists?(:unhashed_upload_files, :path) + add_index :unhashed_upload_files, :path, unique: true + end + + unless index_exists?(:unhashed_upload_files, :tracked) + add_index :unhashed_upload_files, :tracked + end + + BackgroundMigrationWorker.perform_async(MIGRATION) + end + + def down + if table_exists?(:unhashed_upload_files) + drop_table :unhashed_upload_files + end + end +end diff --git a/db/schema.rb b/db/schema.rb index effb2604af2..2b7e12b45f1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1719,6 +1719,16 @@ ActiveRecord::Schema.define(version: 20171124150326) do add_index "u2f_registrations", ["key_handle"], name: "index_u2f_registrations_on_key_handle", using: :btree add_index "u2f_registrations", ["user_id"], name: "index_u2f_registrations_on_user_id", using: :btree + create_table "unhashed_upload_files", force: :cascade do |t| + t.string "path", null: false + t.boolean "tracked", default: false, null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + end + + add_index "unhashed_upload_files", ["path"], name: "index_unhashed_upload_files_on_path", unique: true, using: :btree + add_index "unhashed_upload_files", ["tracked"], name: "index_unhashed_upload_files_on_tracked", using: :btree + create_table "uploads", force: :cascade do |t| t.integer "size", limit: 8, null: false t.string "path", null: false |