diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-20 22:07:04 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 15:46:03 +0200 |
commit | c4c44c6a1bb892dc17989cef3cc9b6c23fecb2c8 (patch) | |
tree | 8f6617baf9e2582d20281acd2de5429fb6ac2886 /db | |
parent | 57ccff8ea41aa2366f40b29187d3b8d1217264e0 (diff) | |
download | gitlab-ce-c4c44c6a1bb892dc17989cef3cc9b6c23fecb2c8.tar.gz |
length constrain on the index, not on the column
we actually don't need a limit on the column itself for MySQL to work.
we need to set a length on the index.
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20170222111732_create_gpg_keys.rb | 6 | ||||
-rw-r--r-- | db/migrate/20170613154149_create_gpg_signatures.rb | 8 | ||||
-rw-r--r-- | db/migrate/limits_to_mysql.rb | 17 |
3 files changed, 20 insertions, 11 deletions
diff --git a/db/migrate/20170222111732_create_gpg_keys.rb b/db/migrate/20170222111732_create_gpg_keys.rb index 072c0819b2f..ec619394f6a 100644 --- a/db/migrate/20170222111732_create_gpg_keys.rb +++ b/db/migrate/20170222111732_create_gpg_keys.rb @@ -7,12 +7,12 @@ class CreateGpgKeys < ActiveRecord::Migration t.references :user, index: true, foreign_key: { on_delete: :cascade } - t.binary :primary_keyid, limit: Gitlab::Database.mysql? ? 20 : nil - t.binary :fingerprint, limit: Gitlab::Database.mysql? ? 20 : nil + t.binary :primary_keyid + t.binary :fingerprint t.text :key - t.index :primary_keyid + t.index :primary_keyid, length: Gitlab::Database.mysql? ? 20 : nil end end end diff --git a/db/migrate/20170613154149_create_gpg_signatures.rb b/db/migrate/20170613154149_create_gpg_signatures.rb index db86170776d..775a9463914 100644 --- a/db/migrate/20170613154149_create_gpg_signatures.rb +++ b/db/migrate/20170613154149_create_gpg_signatures.rb @@ -10,14 +10,14 @@ class CreateGpgSignatures < ActiveRecord::Migration t.boolean :valid_signature - t.binary :commit_sha, limit: Gitlab::Database.mysql? ? 20 : nil - t.binary :gpg_key_primary_keyid, limit: Gitlab::Database.mysql? ? 20 : nil + t.binary :commit_sha + t.binary :gpg_key_primary_keyid t.text :gpg_key_user_name t.text :gpg_key_user_email - t.index :commit_sha - t.index :gpg_key_primary_keyid + t.index :commit_sha, length: Gitlab::Database.mysql? ? 20 : nil + t.index :gpg_key_primary_keyid, length: Gitlab::Database.mysql? ? 20 : nil end end end diff --git a/db/migrate/limits_to_mysql.rb b/db/migrate/limits_to_mysql.rb index de1288e6410..69ada782abe 100644 --- a/db/migrate/limits_to_mysql.rb +++ b/db/migrate/limits_to_mysql.rb @@ -1,5 +1,9 @@ # rubocop:disable all +require Rails.root.join('lib/gitlab/database/migration_helpers.rb') + class LimitsToMysql < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + def up return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ @@ -8,9 +12,14 @@ class LimitsToMysql < ActiveRecord::Migration change_column :snippets, :content, :text, limit: 2147483647 change_column :notes, :st_diff, :text, limit: 2147483647 change_column :events, :data, :text, limit: 2147483647 - change_column :gpg_keys, :primary_keyid, :binary, limit: 20 - change_column :gpg_keys, :fingerprint, :binary, limit: 20 - change_column :gpg_signatures, :commit_sha, :binary, limit: 20 - change_column :gpg_signatures, :gpg_key_primary_keyid, :binary, limit: 20 + + [ + [:gpg_keys, :primary_keyid], + [:gpg_signatures, :commit_sha], + [:gpg_signatures, :gpg_key_primary_keyid] + ].each do |table_name, column_name| + remove_index table_name, column_name if index_exists?(table_name, column_name) + add_concurrent_index table_name, column_name, length: 20 + end end end |