Merge branch 'dz-migration-index-helper' into 'master'

Add mysql_compatible_index_length to migration helpers

Closes #50253

See merge request gitlab-org/gitlab-ce!21852
This commit is contained in:
Dmitriy Zaporozhets 2018-09-28 14:09:31 +00:00
commit ab6b448803
5 changed files with 17 additions and 7 deletions

View File

@ -1,4 +1,6 @@
class CreateGpgKeys < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
@ -12,8 +14,8 @@ class CreateGpgKeys < ActiveRecord::Migration
t.text :key
t.index :primary_keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil
t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil
t.index :primary_keyid, unique: true, length: mysql_compatible_index_length
t.index :fingerprint, unique: true, length: mysql_compatible_index_length
end
end
end

View File

@ -1,4 +1,6 @@
class CreateGpgSignatures < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
@ -16,8 +18,8 @@ class CreateGpgSignatures < ActiveRecord::Migration
t.text :gpg_key_user_name
t.text :gpg_key_user_email
t.index :commit_sha, unique: true, length: Gitlab::Database.mysql? ? 20 : nil
t.index :gpg_key_primary_keyid, length: Gitlab::Database.mysql? ? 20 : nil
t.index :commit_sha, unique: true, length: mysql_compatible_index_length
t.index :gpg_key_primary_keyid, length: mysql_compatible_index_length
end
end
end

View File

@ -8,7 +8,7 @@ class AddIndexOnMergeRequestDiffCommitSha < ActiveRecord::Migration
disable_ddl_transaction!
def up
add_concurrent_index :merge_request_diff_commits, :sha, length: Gitlab::Database.mysql? ? 20 : nil
add_concurrent_index :merge_request_diff_commits, :sha, length: mysql_compatible_index_length
end
def down

View File

@ -1,4 +1,6 @@
class CreateGpgKeySubkeys < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
@ -8,8 +10,8 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration
t.binary :keyid
t.binary :fingerprint
t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil
t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil
t.index :keyid, unique: true, length: mysql_compatible_index_length
t.index :fingerprint, unique: true, length: mysql_compatible_index_length
end
add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify }

View File

@ -1073,6 +1073,10 @@ into similar problems in the future (e.g. when new tables are created).
connection.select_value(index_sql).to_i > 0
end
def mysql_compatible_index_length
Gitlab::Database.mysql? ? 20 : nil
end
end
end
end