Commit c4c44c6a authored by Alexis Reigel's avatar Alexis Reigel

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.
parent 57ccff8e
......@@ -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
......@@ -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
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment