Commit b31fd56b authored by Yorick Peterse's avatar Yorick Peterse

Fix ActiveRecord::Migration deprecations

Extending from ActiveRecord::Migration is deprecated, but was still used
in a bunch of places.
parent fc7b4a83
# frozen_string_literal: true # frozen_string_literal: true
class CreateClustersApplicationsCertManager < ActiveRecord::Migration class CreateClustersApplicationsCertManager < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class CleanupEnvironmentsExternalUrl < ActiveRecord::Migration class CleanupEnvironmentsExternalUrl < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class AddEncryptedRunnersTokenToSettings < ActiveRecord::Migration class AddEncryptedRunnersTokenToSettings < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class KnativeExternalIp < ActiveRecord::Migration class KnativeExternalIp < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class AddMergeRequestIdToCiPipelines < ActiveRecord::Migration class AddMergeRequestIdToCiPipelines < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def up def up
......
# frozen_string_literal: true # frozen_string_literal: true
class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class AddTokenEncryptedToCiRunners < ActiveRecord::Migration class AddTokenEncryptedToCiRunners < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class AddCiBuildsPartialIndexOnProjectIdAndStatus < ActiveRecord::Migration class AddCiBuildsPartialIndexOnProjectIdAndStatus < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class RemoveRedundantCiBuildsPartialIndex < ActiveRecord::Migration class RemoveRedundantCiBuildsPartialIndex < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class BackfillStoreProjectFullPathInRepo < ActiveRecord::Migration class BackfillStoreProjectFullPathInRepo < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class MigrateForbiddenRedirectUris < ActiveRecord::Migration class MigrateForbiddenRedirectUris < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
# frozen_string_literal: true # frozen_string_literal: true
class ScheduleRunnersTokenEncryption < ActiveRecord::Migration class ScheduleRunnersTokenEncryption < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
......
...@@ -211,7 +211,7 @@ existing data. Since we're dealing with a lot of rows we'll schedule jobs in ...@@ -211,7 +211,7 @@ existing data. Since we're dealing with a lot of rows we'll schedule jobs in
batches instead of doing this one by one: batches instead of doing this one by one:
```ruby ```ruby
class ScheduleExtractServicesUrl < ActiveRecord::Migration class ScheduleExtractServicesUrl < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
class Service < ActiveRecord::Base class Service < ActiveRecord::Base
...@@ -242,7 +242,7 @@ jobs and manually run on any un-migrated rows. Such a migration would look like ...@@ -242,7 +242,7 @@ jobs and manually run on any un-migrated rows. Such a migration would look like
this: this:
```ruby ```ruby
class ConsumeRemainingExtractServicesUrlJobs < ActiveRecord::Migration class ConsumeRemainingExtractServicesUrlJobs < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
class Service < ActiveRecord::Base class Service < ActiveRecord::Base
......
...@@ -67,7 +67,7 @@ body: ...@@ -67,7 +67,7 @@ body:
For example: For example:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
DOWNTIME = true DOWNTIME = true
DOWNTIME_REASON = 'This migration requires downtime because ...' DOWNTIME_REASON = 'This migration requires downtime because ...'
...@@ -95,7 +95,7 @@ migration. For this to work your migration needs to include the module ...@@ -95,7 +95,7 @@ migration. For this to work your migration needs to include the module
`Gitlab::Database::MultiThreadedMigration`: `Gitlab::Database::MultiThreadedMigration`:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
include Gitlab::Database::MultiThreadedMigration include Gitlab::Database::MultiThreadedMigration
end end
...@@ -105,7 +105,7 @@ You can then use the method `with_multiple_threads` to perform work in separate ...@@ -105,7 +105,7 @@ You can then use the method `with_multiple_threads` to perform work in separate
threads. For example: threads. For example:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
include Gitlab::Database::MultiThreadedMigration include Gitlab::Database::MultiThreadedMigration
...@@ -139,7 +139,7 @@ by calling the method `disable_ddl_transaction!` in the body of your migration ...@@ -139,7 +139,7 @@ by calling the method `disable_ddl_transaction!` in the body of your migration
class like so: class like so:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -167,7 +167,7 @@ the method `disable_ddl_transaction!` in the body of your migration class like ...@@ -167,7 +167,7 @@ the method `disable_ddl_transaction!` in the body of your migration class like
so: so:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -193,7 +193,7 @@ Here's an example where we add a new column with a foreign key ...@@ -193,7 +193,7 @@ Here's an example where we add a new column with a foreign key
constraint. Note it includes `index: true` to create an index for it. constraint. Note it includes `index: true` to create an index for it.
```ruby ```ruby
class Migration < ActiveRecord::Migration class Migration < ActiveRecord::Migration[4.2]
def change def change
add_reference :model, :other_model, index: true, foreign_key: { on_delete: :cascade } add_reference :model, :other_model, index: true, foreign_key: { on_delete: :cascade }
...@@ -216,7 +216,7 @@ For example, to add the column `foo` to the `projects` table with a default ...@@ -216,7 +216,7 @@ For example, to add the column `foo` to the `projects` table with a default
value of `10` you'd write the following: value of `10` you'd write the following:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -365,7 +365,7 @@ If you need more complex logic you can define and use models local to a ...@@ -365,7 +365,7 @@ If you need more complex logic you can define and use models local to a
migration. For example: migration. For example:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
class Project < ActiveRecord::Base class Project < ActiveRecord::Base
self.table_name = 'projects' self.table_name = 'projects'
end end
......
...@@ -30,7 +30,7 @@ You might want to add additional database migration that makes a decision what t ...@@ -30,7 +30,7 @@ You might want to add additional database migration that makes a decision what t
For example: you might be interested in migrating all dependent data to a different metric. For example: you might be interested in migrating all dependent data to a different metric.
```ruby ```ruby
class ImportCommonMetrics < ActiveRecord::Migration class ImportCommonMetrics < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
require Rails.root.join('db/importers/common_metrics_importer.rb') require Rails.root.join('db/importers/common_metrics_importer.rb')
......
...@@ -106,7 +106,7 @@ transaction. Transactions for migrations can be disabled using the following ...@@ -106,7 +106,7 @@ transaction. Transactions for migrations can be disabled using the following
pattern: pattern:
```ruby ```ruby
class MigrationName < ActiveRecord::Migration class MigrationName < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
end end
``` ```
...@@ -114,7 +114,7 @@ end ...@@ -114,7 +114,7 @@ end
For example: For example:
```ruby ```ruby
class AddUsersLowerUsernameEmailIndexes < ActiveRecord::Migration class AddUsersLowerUsernameEmailIndexes < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
......
...@@ -88,7 +88,7 @@ renaming. For example ...@@ -88,7 +88,7 @@ renaming. For example
```ruby ```ruby
# A regular migration in db/migrate # A regular migration in db/migrate
class RenameUsersUpdatedAtToUpdatedAtTimestamp < ActiveRecord::Migration class RenameUsersUpdatedAtToUpdatedAtTimestamp < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -118,7 +118,7 @@ We can perform this cleanup using ...@@ -118,7 +118,7 @@ We can perform this cleanup using
```ruby ```ruby
# A post-deployment migration in db/post_migrate # A post-deployment migration in db/post_migrate
class CleanupUsersUpdatedAtRename < ActiveRecord::Migration class CleanupUsersUpdatedAtRename < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -157,7 +157,7 @@ as follows: ...@@ -157,7 +157,7 @@ as follows:
```ruby ```ruby
# A regular migration in db/migrate # A regular migration in db/migrate
class ChangeUsersUsernameStringToText < ActiveRecord::Migration class ChangeUsersUsernameStringToText < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -178,7 +178,7 @@ Next we need to clean up our changes using a post-deployment migration: ...@@ -178,7 +178,7 @@ Next we need to clean up our changes using a post-deployment migration:
```ruby ```ruby
# A post-deployment migration in db/post_migrate # A post-deployment migration in db/post_migrate
class ChangeUsersUsernameStringToTextCleanup < ActiveRecord::Migration class ChangeUsersUsernameStringToTextCleanup < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -213,7 +213,7 @@ the work / load over a longer time period, without slowing down deployments. ...@@ -213,7 +213,7 @@ the work / load over a longer time period, without slowing down deployments.
For example, to change the column type using a background migration: For example, to change the column type using a background migration:
```ruby ```ruby
class ExampleMigration < ActiveRecord::Migration class ExampleMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
...@@ -257,7 +257,7 @@ release) by a cleanup migration, which should steal from the queue and handle ...@@ -257,7 +257,7 @@ release) by a cleanup migration, which should steal from the queue and handle
any remaining rows. For example: any remaining rows. For example:
```ruby ```ruby
class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
...@@ -322,7 +322,7 @@ Migrations can take advantage of this by using the method ...@@ -322,7 +322,7 @@ Migrations can take advantage of this by using the method
`add_concurrent_index`. For example: `add_concurrent_index`. For example:
```ruby ```ruby
class MyMigration < ActiveRecord::Migration class MyMigration < ActiveRecord::Migration[4.2]
def up def up
add_concurrent_index :projects, :column_name add_concurrent_index :projects, :column_name
end end
......
...@@ -11,7 +11,7 @@ describe RuboCop::Cop::Migration::AddTimestamps do ...@@ -11,7 +11,7 @@ describe RuboCop::Cop::Migration::AddTimestamps do
subject(:cop) { described_class.new } subject(:cop) { described_class.new }
let(:migration_with_add_timestamps) do let(:migration_with_add_timestamps) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -24,7 +24,7 @@ describe RuboCop::Cop::Migration::AddTimestamps do ...@@ -24,7 +24,7 @@ describe RuboCop::Cop::Migration::AddTimestamps do
let(:migration_without_add_timestamps) do let(:migration_without_add_timestamps) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -36,7 +36,7 @@ describe RuboCop::Cop::Migration::AddTimestamps do ...@@ -36,7 +36,7 @@ describe RuboCop::Cop::Migration::AddTimestamps do
let(:migration_with_add_timestamps_with_timezone) do let(:migration_with_add_timestamps_with_timezone) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
...@@ -12,7 +12,7 @@ describe RuboCop::Cop::Migration::Datetime do ...@@ -12,7 +12,7 @@ describe RuboCop::Cop::Migration::Datetime do
let(:migration_with_datetime) do let(:migration_with_datetime) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -25,7 +25,7 @@ describe RuboCop::Cop::Migration::Datetime do ...@@ -25,7 +25,7 @@ describe RuboCop::Cop::Migration::Datetime do
let(:migration_with_timestamp) do let(:migration_with_timestamp) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -38,7 +38,7 @@ describe RuboCop::Cop::Migration::Datetime do ...@@ -38,7 +38,7 @@ describe RuboCop::Cop::Migration::Datetime do
let(:migration_without_datetime) do let(:migration_without_datetime) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -50,7 +50,7 @@ describe RuboCop::Cop::Migration::Datetime do ...@@ -50,7 +50,7 @@ describe RuboCop::Cop::Migration::Datetime do
let(:migration_with_datetime_with_timezone) do let(:migration_with_datetime_with_timezone) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
...@@ -11,7 +11,7 @@ describe RuboCop::Cop::Migration::Timestamps do ...@@ -11,7 +11,7 @@ describe RuboCop::Cop::Migration::Timestamps do
subject(:cop) { described_class.new } subject(:cop) { described_class.new }
let(:migration_with_timestamps) do let(:migration_with_timestamps) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -27,7 +27,7 @@ describe RuboCop::Cop::Migration::Timestamps do ...@@ -27,7 +27,7 @@ describe RuboCop::Cop::Migration::Timestamps do
let(:migration_without_timestamps) do let(:migration_without_timestamps) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
...@@ -42,7 +42,7 @@ describe RuboCop::Cop::Migration::Timestamps do ...@@ -42,7 +42,7 @@ describe RuboCop::Cop::Migration::Timestamps do
let(:migration_with_timestamps_with_timezone) do let(:migration_with_timestamps_with_timezone) do
%q( %q(
class Users < ActiveRecord::Migration class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def change def change
......
class FakeRenameReservedPathMigrationV1 < ActiveRecord::Migration class FakeRenameReservedPathMigrationV1 < ActiveRecord::Migration[4.2]
include Gitlab::Database::RenameReservedPathsMigration::V1 include Gitlab::Database::RenameReservedPathsMigration::V1
def version def version
......
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