Commit 875a45a6 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'jprovazn-versioned-migrations' into 'master'

Add rails version to all migrations

Closes #54098

See merge request gitlab-org/gitlab-ce!23057
parents 19e9438d 0fc9f9d3

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -26,6 +26,9 @@ class Application < Rails::Application
# setting disabled
require_dependency Rails.root.join('lib/mysql_zero_date')
# This can be removed when we drop support for rails 4
require_dependency Rails.root.join('lib/rails4_migration_version')
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
......
class InitSchema < ActiveRecord::Migration
class InitSchema < ActiveRecord::Migration[4.2]
DOWNTIME = true
# rubocop:disable Metrics/AbcSize
......
class FixNamespaces < ActiveRecord::Migration
class FixNamespaces < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
......
# rubocop:disable all
class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration
class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration[4.2]
def up
change_column :merge_request_diffs, :state, :string, null: true,
default: nil
......
# rubocop:disable all
class AddIndexOnIid < ActiveRecord::Migration
class AddIndexOnIid < ActiveRecord::Migration[4.2]
def change
RemoveDuplicateIid.clean(Issue)
RemoveDuplicateIid.clean(MergeRequest, 'target_project_id')
......
# rubocop:disable all
class IndexOnCurrentSignInAt < ActiveRecord::Migration
class IndexOnCurrentSignInAt < ActiveRecord::Migration[4.2]
def change
add_index :users, :current_sign_in_at
end
......
# rubocop:disable all
class AddNotesIndexUpdatedAt < ActiveRecord::Migration
class AddNotesIndexUpdatedAt < ActiveRecord::Migration[4.2]
def change
add_index :notes, :updated_at
end
......
# rubocop:disable all
class AddRepoSizeToDb < ActiveRecord::Migration
class AddRepoSizeToDb < ActiveRecord::Migration[4.2]
def change
add_column :projects, :repository_size, :float, default: 0
end
......
# rubocop:disable all
class MigrateRepoSize < ActiveRecord::Migration
class MigrateRepoSize < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
......
# rubocop:disable all
class AddPositionToMergeRequest < ActiveRecord::Migration
class AddPositionToMergeRequest < ActiveRecord::Migration[4.2]
def change
add_column :merge_requests, :position, :integer, default: 0
end
......
# rubocop:disable all
class CreateUsersStarProjects < ActiveRecord::Migration
class CreateUsersStarProjects < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
# rubocop:disable all
class CreateLabels < ActiveRecord::Migration
class CreateLabels < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
# rubocop:disable all
class CreateLabelLinks < ActiveRecord::Migration
class CreateLabelLinks < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
class MigrateProjectTags < ActiveRecord::Migration
class MigrateProjectTags < ActiveRecord::Migration[4.2]
def up
ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'labels').update_all(context: 'tags')
end
......
# rubocop:disable all
class MigrateTaggableLabels < ActiveRecord::Migration
class MigrateTaggableLabels < ActiveRecord::Migration[4.2]
def up
taggings = ActsAsTaggableOn::Tagging.where(taggable_type: ['Issue', 'MergeRequest'], context: 'labels')
taggings.find_each(batch_size: 500) do |tagging|
......
# rubocop:disable all
class AddIndexToLabels < ActiveRecord::Migration
class AddIndexToLabels < ActiveRecord::Migration[4.2]
def change
add_index "labels", :project_id
add_index "label_links", :label_id
......
# rubocop:disable all
class MigrateToNewShell < ActiveRecord::Migration
class MigrateToNewShell < ActiveRecord::Migration[4.2]
def change
return if Rails.env.test?
......
# rubocop:disable all
class SerializeServiceProperties < ActiveRecord::Migration
class SerializeServiceProperties < ActiveRecord::Migration[4.2]
def change
unless column_exists?(:services, :properties)
add_column :services, :properties, :text
......
# rubocop:disable all
class AddMembersTable < ActiveRecord::Migration
class AddMembersTable < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
# rubocop:disable all
class MigrateToNewMembersModel < ActiveRecord::Migration
class MigrateToNewMembersModel < ActiveRecord::Migration[4.2]
def up
execute "INSERT INTO members ( user_id, source_id, source_type, access_level, notification_level, type ) SELECT user_id, group_id, 'Namespace', group_access, notification_level, 'GroupMember' FROM users_groups"
execute "INSERT INTO members ( user_id, source_id, source_type, access_level, notification_level, type ) SELECT user_id, project_id, 'Project', project_access, notification_level, 'ProjectMember' FROM users_projects"
......
# rubocop:disable all
class RemoveOldMemberTables < ActiveRecord::Migration
class RemoveOldMemberTables < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
......
# rubocop:disable all
class MoveSlackServiceToWebhook < ActiveRecord::Migration
class MoveSlackServiceToWebhook < ActiveRecord::Migration[4.2]
DOWNTIME = true
DOWNTIME_REASON = 'Move old fields "token" and "subdomain" to one single field "webhook"'
......
# rubocop:disable all
class AddVisibilityLevelToSnippet < ActiveRecord::Migration
class AddVisibilityLevelToSnippet < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
def up
......
# rubocop:disable all
class AddAuditEvent < ActiveRecord::Migration
class AddAuditEvent < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
......@@ -3,7 +3,7 @@
# became a problem after commit c8e78d972a5a628870eefca0f2ccea0199c55bda which
# was added in GitLab 7.5. With this migration we ensure that all rows in
# 'members' have at least some created_at and updated_at timestamp.
class AddTimestampsToMembers < ActiveRecord::Migration
class AddTimestampsToMembers < ActiveRecord::Migration[4.2]
def up
execute "UPDATE members SET created_at = NOW() WHERE created_at is NULL"
execute "UPDATE members SET updated_at = NOW() WHERE updated_at is NULL"
......
# rubocop:disable all
class AddIdentityTable < ActiveRecord::Migration
class AddIdentityTable < ActiveRecord::Migration[4.2]
def up
create_table :identities do |t|
t.string :extern_uid
......
# rubocop:disable all
class AddMergeRequestRebaseEnabledToProjects < ActiveRecord::Migration
class AddMergeRequestRebaseEnabledToProjects < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
......
# rubocop:disable all
class AddLockedAtToMergeRequest < ActiveRecord::Migration
class AddLockedAtToMergeRequest < ActiveRecord::Migration[4.2]
def change
add_column :merge_requests, :locked_at, :datetime
end
......
# rubocop:disable all
class CreateDoorkeeperTables < ActiveRecord::Migration
class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
# rubocop:disable all
class AddOwnerToApplication < ActiveRecord::Migration
class AddOwnerToApplication < ActiveRecord::Migration[4.2]
def change
add_column :oauth_applications, :owner_id, :integer, null: true
add_column :oauth_applications, :owner_type, :string, null: true
......
class AddImportDataToProjectTable < ActiveRecord::Migration
class AddImportDataToProjectTable < ActiveRecord::Migration[4.2]
def change
add_column :projects, :import_type, :string
add_column :projects, :import_source, :string
......
# rubocop:disable all
class AddDevelopersCanPushToProtectedBranches < ActiveRecord::Migration
class AddDevelopersCanPushToProtectedBranches < ActiveRecord::Migration[4.2]
def change
add_column :protected_branches, :developers_can_push, :boolean, default: false, null: false
end
......
# rubocop:disable all
class CreateApplicationSettings < ActiveRecord::Migration
class CreateApplicationSettings < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
class AddHomePageUrlForApplicationSettings < ActiveRecord::Migration
class AddHomePageUrlForApplicationSettings < ActiveRecord::Migration[4.2]
def change
add_column :application_settings, :home_page_url, :string
end
......
class AddGitlabAccessTokenToUser < ActiveRecord::Migration
class AddGitlabAccessTokenToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :gitlab_access_token, :string
end
......
# rubocop:disable all
class AddDefaultBranchProtectionSetting < ActiveRecord::Migration
class AddDefaultBranchProtectionSetting < ActiveRecord::Migration[4.2]
def change
add_column :application_settings, :default_branch_protection, :integer, :default => 2
end
......
# rubocop:disable all
class AddTimestampsToIdentities < ActiveRecord::Migration
class AddTimestampsToIdentities < ActiveRecord::Migration[4.2]
def change
add_timestamps(:identities)
end
......
# rubocop:disable all
class AddIndexToCreatedAt < ActiveRecord::Migration
class AddIndexToCreatedAt < ActiveRecord::Migration[4.2]
def change
add_index "users", [:created_at, :id]
add_index "members", [:created_at, :id]
......
class AddNotificationEmailToUser < ActiveRecord::Migration
class AddNotificationEmailToUser < ActiveRecord::Migration[4.2]
def up
add_column :users, :notification_email, :string
......
# rubocop:disable all
class AddMissingIndex < ActiveRecord::Migration
class AddMissingIndex < ActiveRecord::Migration[4.2]
def change
add_index "services", [:created_at, :id]
end
......
# rubocop:disable all
class AddTemplateToService < ActiveRecord::Migration
class AddTemplateToService < ActiveRecord::Migration[4.2]
def change
add_column :services, :template, :boolean, default: false
end
......
class AllowNullInServicesProjectId < ActiveRecord::Migration
class AllowNullInServicesProjectId < ActiveRecord::Migration[4.2]
def change
change_column :services, :project_id, :integer, null: true
end
......
# rubocop:disable all
class AddTwitterSharingEnabledToApplicationSettings < ActiveRecord::Migration
class AddTwitterSharingEnabledToApplicationSettings < ActiveRecord::Migration[4.2]
def change
add_column :application_settings, :twitter_sharing_enabled, :boolean, default: true
end
......
# rubocop:disable all
class AddHideNoPasswordToUser < ActiveRecord::Migration
class AddHideNoPasswordToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :hide_no_password, :boolean, default: false
end
......
# rubocop:disable all
class AddPasswordAutomaticallySetToUser < ActiveRecord::Migration
class AddPasswordAutomaticallySetToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :password_automatically_set, :boolean, default: false
end
......
class AddBitbucketAccessTokenAndSecretToUser < ActiveRecord::Migration
class AddBitbucketAccessTokenAndSecretToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :bitbucket_access_token, :string
add_column :users, :bitbucket_access_token_secret, :string
......
# rubocop:disable all
class AddEventsToServices < ActiveRecord::Migration
class AddEventsToServices < ActiveRecord::Migration[4.2]
def change
add_column :services, :push_events, :boolean, :default => true
add_column :services, :issues_events, :boolean, :default => true
......
class SetMissingLastActivityAt < ActiveRecord::Migration
class SetMissingLastActivityAt < ActiveRecord::Migration[4.2]
def up
execute "UPDATE projects SET last_activity_at = updated_at WHERE last_activity_at IS NULL"
end
......
# rubocop:disable all
class AddNoteEventsToServices < ActiveRecord::Migration
class AddNoteEventsToServices < ActiveRecord::Migration[4.2]
def change
add_column :services, :note_events, :boolean, default: true, null: false
end
......
class AddRestrictedVisibilityLevelsToApplicationSettings < ActiveRecord::Migration
class AddRestrictedVisibilityLevelsToApplicationSettings < ActiveRecord::Migration[4.2]
def change
add_column :application_settings, :restricted_visibility_levels, :text
end
......
# rubocop:disable all
class FixNamespaceDuplication < ActiveRecord::Migration
class FixNamespaceDuplication < ActiveRecord::Migration[4.2]
def up
#fixes path duplication
select_all('SELECT MAX(id) max, COUNT(id) cnt, path FROM namespaces GROUP BY path HAVING COUNT(id) > 1').each do |nms|
......
# rubocop:disable all
class AddUniqueIndexToNamespace < ActiveRecord::Migration
class AddUniqueIndexToNamespace < ActiveRecord::Migration[4.2]
def change
remove_index :namespaces, column: :name if index_exists?(:namespaces, :name)
remove_index :namespaces, column: :path if index_exists?(:namespaces, :path)
......
# rubocop:disable all
class AddVersionCheckToApplicationSettings < ActiveRecord::Migration
class AddVersionCheckToApplicationSettings < ActiveRecord::Migration[4.2]
def change
add_column :application_settings, :version_check_enabled, :boolean, default: true
end
......
# rubocop:disable all
class CreateSubscriptionsTable < ActiveRecord::Migration
class CreateSubscriptionsTable < ActiveRecord::Migration[4.2]
DOWNTIME = false
def change
......
class AddLocationToUser < ActiveRecord::Migration
class AddLocationToUser < ActiveRecord::Migration[4.2]
def change
add_column :users, :location, :string
end
......
class SetIncorrectAssigneeIdToNull < ActiveRecord::Migration
class SetIncorrectAssigneeIdToNull < ActiveRecord::Migration[4.2]
def up
execute "UPDATE issues SET assignee_id = NULL WHERE assignee_id = -1"
execute "UPDATE merge_requests SET assignee_id = NULL WHERE assignee_id = -1"
......
# rubocop:disable all
class AddPublicToKey < ActiveRecord::Migration
class AddPublicToKey < ActiveRecord::Migration[4.2]
def change
add_column :keys, :public, :boolean, default: false, null: false
end
......
class AddImportDataToProject < ActiveRecord::Migration
class AddImportDataToProject < ActiveRecord::Migration[4.2]
def change
add_column :projects, :import_data, :text
end
......
class AddDeviseTwoFactorToUsers < ActiveRecord::Migration
class AddDeviseTwoFactorToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :encrypted_otp_secret, :string
add_column :users, :encrypted_otp_secret_iv, :string
......
class AddMaxAttachmentSizeToApplicationSettings < ActiveRecord::Migration
class AddMaxAttachmentSizeToApplicationSettings < ActiveRecord::Migration[4.2]
def change
add_column :application_settings, :max_attachment_size, :integer, default: 10, null: false
end
......
class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration
class AddDeviseTwoFactorBackupableToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :otp_backup_codes, :text
end
......
# rubocop:disable all
class AddInviteDataToMember < ActiveRecord::Migration
class AddInviteDataToMember < ActiveRecord::Migration[4.2]
def up
add_column :members, :created_by_id, :integer
add_column :members, :invite_email, :string
......
class FixIdentities < ActiveRecord::Migration
class FixIdentities < ActiveRecord::Migration[4.2]
def up
# Up until now, legacy 'ldap' references in the database were charitably
# interpreted to point to the first LDAP server specified in the GitLab
......
class RenameBuildboxService < ActiveRecord::Migration
class RenameBuildboxService < ActiveRecord::Migration[4.2]
def up
execute "UPDATE services SET type = 'BuildkiteService' WHERE type = 'BuildboxService';"
end
......
# rubocop:disable all
class AddPublicEmailToUsers < ActiveRecord::Migration
class AddPublicEmailToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :public_email, :string, default: "", null: false
end
......
class CreateProjectImportData < ActiveRecord::Migration
class CreateProjectImportData < ActiveRecord::Migration[4.2]
def change
create_table :project_import_data do |t|
t.references :project
......
# rubocop:disable all
class RemoveImportDataFromProject < ActiveRecord::Migration
class RemoveImportDataFromProject < ActiveRecord::Migration[4.2]
def up
remove_column :projects, :import_data
end
......
# rubocop:disable all
class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration[4.2]
include Gitlab::ShellAdapter
class Namespace < ActiveRecord::Base
......
class AddDefaultProjectVisibililtyToApplicationSettings < ActiveRecord::Migration
class AddDefaultProjectVisibililtyToApplicationSettings < ActiveRecord::Migration[4.2]
def up
add_column :application_settings, :default_project_visibility, :integer
visibility = Settings.gitlab.default_projects_features['visibility_level']
......
# This migration is a duplicate of 20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
# It shold be applied before the index additions to ensure that `name` is case sensitive.
class GitlabChangeCollationForTagNames < ActiveRecord::Migration
class GitlabChangeCollationForTagNames < ActiveRecord::Migration[4.2]
def up
if ActsAsTaggableOn::Utils.using_mysql?
execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
......
# rubocop:disable all
class RemoveDuplicateTags < ActiveRecord::Migration
class RemoveDuplicateTags < ActiveRecord::Migration[4.2]
def up
select_all("SELECT name, COUNT(id) as cnt FROM tags GROUP BY name HAVING COUNT(id) > 1").each do |tag|
tag_name = quote_string(tag["name"])
......
# rubocop:disable all
# This migration comes from acts_as_taggable_on_engine (originally 2)
class AddMissingUniqueIndices < ActiveRecord::Migration
class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]
def self.up
add_index :tags, :name, unique: true
......
# rubocop:disable all
# This migration comes from acts_as_taggable_on_engine (originally 3)
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]
def self.up
add_column :tags, :taggings_count, :integer, default: 0
......