diff options
author | Stan Hu <stanhu@gmail.com> | 2017-12-07 05:34:58 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-12-07 05:34:58 +0300 |
commit | 29e39e55c3d4b5c6c34c6faec84b0dcd5a3efffa (patch) | |
tree | d6b3ca53d05fa47db768c8d0508fe51c81b0f6ac /db | |
parent | ba44a57f101a87ebb9155485d5bde1287f7892cf (diff) | |
parent | 24c348f0d1270fe27268aa23e034473651b0cdf9 (diff) |
Merge branch 'mk-add-old-attachments-to-uploads-table' into 'master'
Add old files to uploads table
See merge request gitlab-org/gitlab-ce!15270
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb | 25 | ||||
-rw-r--r-- | db/post_migrate/20171103140253_track_untracked_uploads.rb | 21 | ||||
-rw-r--r-- | db/schema.rb | 2 |
3 files changed, 47 insertions, 1 deletions
diff --git a/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb b/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb new file mode 100644 index 00000000000..1fbe505f804 --- /dev/null +++ b/db/migrate/20171103000000_set_uploads_path_size_for_mysql.rb @@ -0,0 +1,25 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class SetUploadsPathSizeForMysql < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + # We need at least 297 at the moment. For more detail on that number, see: + # https://gitlab.com/gitlab-org/gitlab-ce/issues/40168#what-is-the-expected-correct-behavior + # + # Rails + PostgreSQL `string` is equivalent to a `text` field, but + # Rails + MySQL `string` is `varchar(255)` by default. Also, note that we + # have an upper limit because with a unique index, MySQL has a max key + # length of 3072 bytes which seems to correspond to `varchar(1024)`. + change_column :uploads, :path, :string, limit: 511 + end + + def down + # It was unspecified, which is varchar(255) by default in Rails for MySQL. + change_column :uploads, :path, :string + end +end 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..548a94d2d38 --- /dev/null +++ b/db/post_migrate/20171103140253_track_untracked_uploads.rb @@ -0,0 +1,21 @@ +# 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 = 'PrepareUntrackedUploads' + + def up + BackgroundMigrationWorker.perform_async(MIGRATION) + end + + def down + if table_exists?(:untracked_files_for_uploads) + drop_table :untracked_files_for_uploads + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 0984ca6487f..2be1b745342 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1737,7 +1737,7 @@ ActiveRecord::Schema.define(version: 20171124150326) do create_table "uploads", force: :cascade do |t| t.integer "size", limit: 8, null: false - t.string "path", null: false + t.string "path", limit: 511, null: false t.string "checksum", limit: 64 t.integer "model_id" t.string "model_type" |