Commit f7f872fc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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

Add mysql_compatible_index_length to migration helpers (EE)

See merge request gitlab-org/gitlab-ee!7448
parents 913b57f3 0cc7d124
class CreateGpgKeys < ActiveRecord::Migration class CreateGpgKeys < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -12,8 +14,8 @@ class CreateGpgKeys < ActiveRecord::Migration ...@@ -12,8 +14,8 @@ class CreateGpgKeys < ActiveRecord::Migration
t.text :key t.text :key
t.index :primary_keyid, 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: Gitlab::Database.mysql? ? 20 : nil t.index :fingerprint, unique: true, length: mysql_compatible_index_length
end end
end end
end end
class CreateGpgSignatures < ActiveRecord::Migration class CreateGpgSignatures < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -16,8 +18,8 @@ class CreateGpgSignatures < ActiveRecord::Migration ...@@ -16,8 +18,8 @@ class CreateGpgSignatures < ActiveRecord::Migration
t.text :gpg_key_user_name t.text :gpg_key_user_name
t.text :gpg_key_user_email t.text :gpg_key_user_email
t.index :commit_sha, unique: true, length: Gitlab::Database.mysql? ? 20 : nil t.index :commit_sha, unique: true, length: mysql_compatible_index_length
t.index :gpg_key_primary_keyid, length: Gitlab::Database.mysql? ? 20 : nil t.index :gpg_key_primary_keyid, length: mysql_compatible_index_length
end end
end end
end end
...@@ -8,7 +8,7 @@ class AddIndexOnMergeRequestDiffCommitSha < ActiveRecord::Migration ...@@ -8,7 +8,7 @@ class AddIndexOnMergeRequestDiffCommitSha < ActiveRecord::Migration
disable_ddl_transaction! disable_ddl_transaction!
def up 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 end
def down def down
......
class CreateGpgKeySubkeys < ActiveRecord::Migration class CreateGpgKeySubkeys < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
def up def up
...@@ -8,8 +10,8 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration ...@@ -8,8 +10,8 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration
t.binary :keyid t.binary :keyid
t.binary :fingerprint t.binary :fingerprint
t.index :keyid, unique: true, length: Gitlab::Database.mysql? ? 20 : nil t.index :keyid, unique: true, length: mysql_compatible_index_length
t.index :fingerprint, unique: true, length: Gitlab::Database.mysql? ? 20 : nil t.index :fingerprint, unique: true, length: mysql_compatible_index_length
end end
add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify } add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify }
......
...@@ -11,7 +11,7 @@ class AddPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi ...@@ -11,7 +11,7 @@ class AddPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi
add_concurrent_index(:project_repository_states, add_concurrent_index(:project_repository_states,
[:repository_verification_checksum, :wiki_verification_checksum], [:repository_verification_checksum, :wiki_verification_checksum],
name: INDEX_NAME, name: INDEX_NAME,
length: Gitlab::Database.mysql? ? 20 : nil, length: mysql_compatible_index_length,
where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL' where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL'
) )
end end
......
...@@ -9,11 +9,11 @@ class AddPartialIndexToProjectRepositoryStatesVerificationColumns < ActiveRecord ...@@ -9,11 +9,11 @@ class AddPartialIndexToProjectRepositoryStatesVerificationColumns < ActiveRecord
def up def up
unless index_exists?(:project_repository_states, :last_repository_verification_failure, name: REPOSITORY_INDEX_NAME) unless index_exists?(:project_repository_states, :last_repository_verification_failure, name: REPOSITORY_INDEX_NAME)
add_concurrent_index(:project_repository_states, :last_repository_verification_failure, name: REPOSITORY_INDEX_NAME, length: Gitlab::Database.mysql? ? 20 : nil, where: 'last_repository_verification_failure IS NOT NULL') add_concurrent_index(:project_repository_states, :last_repository_verification_failure, name: REPOSITORY_INDEX_NAME, length: mysql_compatible_index_length, where: 'last_repository_verification_failure IS NOT NULL')
end end
unless index_exists?(:project_repository_states, :last_wiki_verification_failure, name: WIKI_INDEX_NAME) unless index_exists?(:project_repository_states, :last_wiki_verification_failure, name: WIKI_INDEX_NAME)
add_concurrent_index(:project_repository_states, :last_wiki_verification_failure, name: WIKI_INDEX_NAME, length: Gitlab::Database.mysql? ? 20 : nil, where: 'last_wiki_verification_failure IS NOT NULL') add_concurrent_index(:project_repository_states, :last_wiki_verification_failure, name: WIKI_INDEX_NAME, length: mysql_compatible_index_length, where: 'last_wiki_verification_failure IS NOT NULL')
end end
end end
......
...@@ -23,7 +23,7 @@ class FixPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi ...@@ -23,7 +23,7 @@ class FixPartialIndexToProjectRepositoryStatesChecksumColumns < ActiveRecord::Mi
add_concurrent_index(:project_repository_states, add_concurrent_index(:project_repository_states,
[:repository_verification_checksum, :wiki_verification_checksum], [:repository_verification_checksum, :wiki_verification_checksum],
name: OLD_INDEX_NAME, name: OLD_INDEX_NAME,
length: Gitlab::Database.mysql? ? 20 : nil, length: mysql_compatible_index_length,
where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL' where: 'repository_verification_checksum IS NULL OR wiki_verification_checksum IS NULL'
) )
end end
......
...@@ -1073,6 +1073,10 @@ into similar problems in the future (e.g. when new tables are created). ...@@ -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 connection.select_value(index_sql).to_i > 0
end end
def mysql_compatible_index_length
Gitlab::Database.mysql? ? 20 : nil
end
end end
end 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