Commit 0fc9f9d3 authored by Jan Provaznik's avatar Jan Provaznik

Add version 4.2 to all existing migrations

DB schema generated by a migration may look different in
rails 4 and 5 (because rails 5 may use different default values).
For this reason it's important to explicitly set for which rails
version a migration was written for.

See https://stackoverflow.com/questions/35929869/activerecordmigration-deprecation-warning-asks-for-rails-version-but-im-no/35930912#35930912
parent fcec474c

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
class InitSchema < ActiveRecord::Migration class InitSchema < ActiveRecord::Migration[4.2]
DOWNTIME = true DOWNTIME = true
# rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/AbcSize
......
class FixNamespaces < ActiveRecord::Migration class FixNamespaces < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def up def up
......
# rubocop:disable all # rubocop:disable all
class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration[4.2]
def up def up
change_column :merge_request_diffs, :state, :string, null: true, change_column :merge_request_diffs, :state, :string, null: true,
default: nil default: nil
......
# rubocop:disable all # rubocop:disable all
class AddIndexOnIid < ActiveRecord::Migration class AddIndexOnIid < ActiveRecord::Migration[4.2]
def change def change
RemoveDuplicateIid.clean(Issue) RemoveDuplicateIid.clean(Issue)
RemoveDuplicateIid.clean(MergeRequest, 'target_project_id') RemoveDuplicateIid.clean(MergeRequest, 'target_project_id')
......
# rubocop:disable all # rubocop:disable all
class IndexOnCurrentSignInAt < ActiveRecord::Migration class IndexOnCurrentSignInAt < ActiveRecord::Migration[4.2]
def change def change
add_index :users, :current_sign_in_at add_index :users, :current_sign_in_at
end end
......
# rubocop:disable all # rubocop:disable all
class AddNotesIndexUpdatedAt < ActiveRecord::Migration class AddNotesIndexUpdatedAt < ActiveRecord::Migration[4.2]
def change def change
add_index :notes, :updated_at add_index :notes, :updated_at
end end
......
# rubocop:disable all # rubocop:disable all
class AddRepoSizeToDb < ActiveRecord::Migration class AddRepoSizeToDb < ActiveRecord::Migration[4.2]
def change def change
add_column :projects, :repository_size, :float, default: 0 add_column :projects, :repository_size, :float, default: 0
end end
......
# rubocop:disable all # rubocop:disable all
class MigrateRepoSize < ActiveRecord::Migration class MigrateRepoSize < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def up def up
......
# rubocop:disable all # rubocop:disable all
class AddPositionToMergeRequest < ActiveRecord::Migration class AddPositionToMergeRequest < ActiveRecord::Migration[4.2]
def change def change
add_column :merge_requests, :position, :integer, default: 0 add_column :merge_requests, :position, :integer, default: 0
end end
......
# rubocop:disable all # rubocop:disable all
class CreateUsersStarProjects < ActiveRecord::Migration class CreateUsersStarProjects < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
# rubocop:disable all # rubocop:disable all
class CreateLabels < ActiveRecord::Migration class CreateLabels < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
# rubocop:disable all # rubocop:disable all
class CreateLabelLinks < ActiveRecord::Migration class CreateLabelLinks < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
class MigrateProjectTags < ActiveRecord::Migration class MigrateProjectTags < ActiveRecord::Migration[4.2]
def up def up
ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'labels').update_all(context: 'tags') ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'labels').update_all(context: 'tags')
end end
......
# rubocop:disable all # rubocop:disable all
class MigrateTaggableLabels < ActiveRecord::Migration class MigrateTaggableLabels < ActiveRecord::Migration[4.2]
def up def up
taggings = ActsAsTaggableOn::Tagging.where(taggable_type: ['Issue', 'MergeRequest'], context: 'labels') taggings = ActsAsTaggableOn::Tagging.where(taggable_type: ['Issue', 'MergeRequest'], context: 'labels')
taggings.find_each(batch_size: 500) do |tagging| taggings.find_each(batch_size: 500) do |tagging|
......
# rubocop:disable all # rubocop:disable all
class AddIndexToLabels < ActiveRecord::Migration class AddIndexToLabels < ActiveRecord::Migration[4.2]
def change def change
add_index "labels", :project_id add_index "labels", :project_id
add_index "label_links", :label_id add_index "label_links", :label_id
......
# rubocop:disable all # rubocop:disable all
class MigrateToNewShell < ActiveRecord::Migration class MigrateToNewShell < ActiveRecord::Migration[4.2]
def change def change
return if Rails.env.test? return if Rails.env.test?
......
# rubocop:disable all # rubocop:disable all
class SerializeServiceProperties < ActiveRecord::Migration class SerializeServiceProperties < ActiveRecord::Migration[4.2]
def change def change
unless column_exists?(:services, :properties) unless column_exists?(:services, :properties)
add_column :services, :properties, :text add_column :services, :properties, :text
......
# rubocop:disable all # rubocop:disable all
class AddMembersTable < ActiveRecord::Migration class AddMembersTable < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
# rubocop:disable all # rubocop:disable all
class MigrateToNewMembersModel < ActiveRecord::Migration class MigrateToNewMembersModel < ActiveRecord::Migration[4.2]
def up 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, 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" 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 # rubocop:disable all
class RemoveOldMemberTables < ActiveRecord::Migration class RemoveOldMemberTables < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def up def up
......
# rubocop:disable all # rubocop:disable all
class MoveSlackServiceToWebhook < ActiveRecord::Migration class MoveSlackServiceToWebhook < ActiveRecord::Migration[4.2]
DOWNTIME = true DOWNTIME = true
DOWNTIME_REASON = 'Move old fields "token" and "subdomain" to one single field "webhook"' DOWNTIME_REASON = 'Move old fields "token" and "subdomain" to one single field "webhook"'
......
# rubocop:disable all # rubocop:disable all
class AddVisibilityLevelToSnippet < ActiveRecord::Migration class AddVisibilityLevelToSnippet < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
def up def up
......
# rubocop:disable all # rubocop:disable all
class AddAuditEvent < ActiveRecord::Migration class AddAuditEvent < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# became a problem after commit c8e78d972a5a628870eefca0f2ccea0199c55bda which # became a problem after commit c8e78d972a5a628870eefca0f2ccea0199c55bda which
# was added in GitLab 7.5. With this migration we ensure that all rows in # 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. # 'members' have at least some created_at and updated_at timestamp.
class AddTimestampsToMembers < ActiveRecord::Migration class AddTimestampsToMembers < ActiveRecord::Migration[4.2]
def up def up
execute "UPDATE members SET created_at = NOW() WHERE created_at is NULL" execute "UPDATE members SET created_at = NOW() WHERE created_at is NULL"
execute "UPDATE members SET updated_at = NOW() WHERE updated_at is NULL" execute "UPDATE members SET updated_at = NOW() WHERE updated_at is NULL"
......
# rubocop:disable all # rubocop:disable all
class AddIdentityTable < ActiveRecord::Migration class AddIdentityTable < ActiveRecord::Migration[4.2]
def up def up
create_table :identities do |t| create_table :identities do |t|
t.string :extern_uid t.string :extern_uid
......
# rubocop:disable all # rubocop:disable all
class AddMergeRequestRebaseEnabledToProjects < ActiveRecord::Migration class AddMergeRequestRebaseEnabledToProjects < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime. # Set this constant to true if this migration requires downtime.
......
# rubocop:disable all # rubocop:disable all
class AddLockedAtToMergeRequest < ActiveRecord::Migration class AddLockedAtToMergeRequest < ActiveRecord::Migration[4.2]
def change def change
add_column :merge_requests, :locked_at, :datetime add_column :merge_requests, :locked_at, :datetime
end end
......
# rubocop:disable all # rubocop:disable all
class CreateDoorkeeperTables < ActiveRecord::Migration class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
# rubocop:disable all # rubocop:disable all
class AddOwnerToApplication < ActiveRecord::Migration class AddOwnerToApplication < ActiveRecord::Migration[4.2]
def change def change
add_column :oauth_applications, :owner_id, :integer, null: true add_column :oauth_applications, :owner_id, :integer, null: true
add_column :oauth_applications, :owner_type, :string, null: true add_column :oauth_applications, :owner_type, :string, null: true
......
class AddImportDataToProjectTable < ActiveRecord::Migration class AddImportDataToProjectTable < ActiveRecord::Migration[4.2]
def change def change
add_column :projects, :import_type, :string add_column :projects, :import_type, :string
add_column :projects, :import_source, :string add_column :projects, :import_source, :string
......
# rubocop:disable all # rubocop:disable all
class AddDevelopersCanPushToProtectedBranches < ActiveRecord::Migration class AddDevelopersCanPushToProtectedBranches < ActiveRecord::Migration[4.2]
def change def change
add_column :protected_branches, :developers_can_push, :boolean, default: false, null: false add_column :protected_branches, :developers_can_push, :boolean, default: false, null: false
end end
......
# rubocop:disable all # rubocop:disable all
class CreateApplicationSettings < ActiveRecord::Migration class CreateApplicationSettings < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
class AddHomePageUrlForApplicationSettings < ActiveRecord::Migration class AddHomePageUrlForApplicationSettings < ActiveRecord::Migration[4.2]
def change def change
add_column :application_settings, :home_page_url, :string add_column :application_settings, :home_page_url, :string
end end
......
class AddGitlabAccessTokenToUser < ActiveRecord::Migration class AddGitlabAccessTokenToUser < ActiveRecord::Migration[4.2]
def change def change
add_column :users, :gitlab_access_token, :string add_column :users, :gitlab_access_token, :string
end end
......
# rubocop:disable all # rubocop:disable all
class AddDefaultBranchProtectionSetting < ActiveRecord::Migration class AddDefaultBranchProtectionSetting < ActiveRecord::Migration[4.2]
def change def change
add_column :application_settings, :default_branch_protection, :integer, :default => 2 add_column :application_settings, :default_branch_protection, :integer, :default => 2
end end
......
# rubocop:disable all # rubocop:disable all
class AddTimestampsToIdentities < ActiveRecord::Migration class AddTimestampsToIdentities < ActiveRecord::Migration[4.2]
def change def change
add_timestamps(:identities) add_timestamps(:identities)
end end
......
# rubocop:disable all # rubocop:disable all
class AddIndexToCreatedAt < ActiveRecord::Migration class AddIndexToCreatedAt < ActiveRecord::Migration[4.2]
def change def change
add_index "users", [:created_at, :id] add_index "users", [:created_at, :id]
add_index "members", [:created_at, :id] add_index "members", [:created_at, :id]
......
class AddNotificationEmailToUser < ActiveRecord::Migration class AddNotificationEmailToUser < ActiveRecord::Migration[4.2]
def up def up
add_column :users, :notification_email, :string add_column :users, :notification_email, :string
......
# rubocop:disable all # rubocop:disable all
class AddMissingIndex < ActiveRecord::Migration class AddMissingIndex < ActiveRecord::Migration[4.2]
def change def change
add_index "services", [:created_at, :id] add_index "services", [:created_at, :id]
end end
......
# rubocop:disable all # rubocop:disable all
class AddTemplateToService < ActiveRecord::Migration class AddTemplateToService < ActiveRecord::Migration[4.2]
def change def change
add_column :services, :template, :boolean, default: false add_column :services, :template, :boolean, default: false
end end
......
class AllowNullInServicesProjectId < ActiveRecord::Migration class AllowNullInServicesProjectId < ActiveRecord::Migration[4.2]
def change def change
change_column :services, :project_id, :integer, null: true change_column :services, :project_id, :integer, null: true
end end
......
# rubocop:disable all # rubocop:disable all
class AddTwitterSharingEnabledToApplicationSettings < ActiveRecord::Migration class AddTwitterSharingEnabledToApplicationSettings < ActiveRecord::Migration[4.2]
def change def change
add_column :application_settings, :twitter_sharing_enabled, :boolean, default: true add_column :application_settings, :twitter_sharing_enabled, :boolean, default: true
end end
......
# rubocop:disable all # rubocop:disable all
class AddHideNoPasswordToUser < ActiveRecord::Migration class AddHideNoPasswordToUser < ActiveRecord::Migration[4.2]
def change def change
add_column :users, :hide_no_password, :boolean, default: false add_column :users, :hide_no_password, :boolean, default: false
end end
......
# rubocop:disable all # rubocop:disable all
class AddPasswordAutomaticallySetToUser < ActiveRecord::Migration class AddPasswordAutomaticallySetToUser < ActiveRecord::Migration[4.2]
def change def change
add_column :users, :password_automatically_set, :boolean, default: false add_column :users, :password_automatically_set, :boolean, default: false
end end
......
class AddBitbucketAccessTokenAndSecretToUser < ActiveRecord::Migration class AddBitbucketAccessTokenAndSecretToUser < ActiveRecord::Migration[4.2]
def change def change
add_column :users, :bitbucket_access_token, :string add_column :users, :bitbucket_access_token, :string
add_column :users, :bitbucket_access_token_secret, :string add_column :users, :bitbucket_access_token_secret, :string
......
# rubocop:disable all # rubocop:disable all
class AddEventsToServices < ActiveRecord::Migration class AddEventsToServices < ActiveRecord::Migration[4.2]
def change def change
add_column :services, :push_events, :boolean, :default => true add_column :services, :push_events, :boolean, :default => true
add_column :services, :issues_events, :boolean, :default => true add_column :services, :issues_events, :boolean, :default => true
......
class SetMissingLastActivityAt < ActiveRecord::Migration class SetMissingLastActivityAt < ActiveRecord::Migration[4.2]
def up def up
execute "UPDATE projects SET last_activity_at = updated_at WHERE last_activity_at IS NULL" execute "UPDATE projects SET last_activity_at = updated_at WHERE last_activity_at IS NULL"
end end
......
# rubocop:disable all # rubocop:disable all
class AddNoteEventsToServices < ActiveRecord::Migration class AddNoteEventsToServices < ActiveRecord::Migration[4.2]
def change def change
add_column :services, :note_events, :boolean, default: true, null: false add_column :services, :note_events, :boolean, default: true, null: false
end end
......
class AddRestrictedVisibilityLevelsToApplicationSettings < ActiveRecord::Migration class AddRestrictedVisibilityLevelsToApplicationSettings < ActiveRecord::Migration[4.2]
def change def change
add_column :application_settings, :restricted_visibility_levels, :text add_column :application_settings, :restricted_visibility_levels, :text
end end
......
# rubocop:disable all # rubocop:disable all
class FixNamespaceDuplication < ActiveRecord::Migration class FixNamespaceDuplication < ActiveRecord::Migration[4.2]
def up def up
#fixes path duplication #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| 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 # rubocop:disable all
class AddUniqueIndexToNamespace < ActiveRecord::Migration class AddUniqueIndexToNamespace < ActiveRecord::Migration[4.2]
def change def change
remove_index :namespaces, column: :name if index_exists?(:namespaces, :name) remove_index :namespaces, column: :name if index_exists?(:namespaces, :name)
remove_index :namespaces, column: :path if index_exists?(:namespaces, :path) remove_index :namespaces, column: :path if index_exists?(:namespaces, :path)
......
# rubocop:disable all # rubocop:disable all
class AddVersionCheckToApplicationSettings < ActiveRecord::Migration class AddVersionCheckToApplicationSettings < ActiveRecord::Migration[4.2]
def change def change
add_column :application_settings, :version_check_enabled, :boolean, default: true add_column :application_settings, :version_check_enabled, :boolean, default: true
end end
......
# rubocop:disable all # rubocop:disable all
class CreateSubscriptionsTable < ActiveRecord::Migration class CreateSubscriptionsTable < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false