diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-12-12 16:38:40 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-12-12 16:38:40 +0100 |
commit | 40ad7d5d7a01a6f019ce1c3bb8864b16fc48e9c8 (patch) | |
tree | b6df001f46b76dbe6f48120209f56439e11f6797 /doc | |
parent | 099777a3569208cdadeb88203a19885dbcd5d527 (diff) | |
download | gitlab-ce-40ad7d5d7a01a6f019ce1c3bb8864b16fc48e9c8.tar.gz |
Fix ActiveRecord::Migration deprecations
Extending from ActiveRecord::Migration is deprecated, but was still used
in a bunch of places.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/development/background_migrations.md | 4 | ||||
-rw-r--r-- | doc/development/migration_style_guide.md | 16 | ||||
-rw-r--r-- | doc/development/prometheus_metrics.md | 2 | ||||
-rw-r--r-- | doc/development/sql.md | 4 | ||||
-rw-r--r-- | doc/development/what_requires_downtime.md | 14 |
5 files changed, 20 insertions, 20 deletions
diff --git a/doc/development/background_migrations.md b/doc/development/background_migrations.md index bb9a296ef12..dd4a9e058d7 100644 --- a/doc/development/background_migrations.md +++ b/doc/development/background_migrations.md @@ -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: ```ruby -class ScheduleExtractServicesUrl < ActiveRecord::Migration +class ScheduleExtractServicesUrl < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Service < ActiveRecord::Base @@ -242,7 +242,7 @@ jobs and manually run on any un-migrated rows. Such a migration would look like this: ```ruby -class ConsumeRemainingExtractServicesUrlJobs < ActiveRecord::Migration +class ConsumeRemainingExtractServicesUrlJobs < ActiveRecord::Migration[4.2] disable_ddl_transaction! class Service < ActiveRecord::Base diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md index a99267bfbba..d0a054c3290 100644 --- a/doc/development/migration_style_guide.md +++ b/doc/development/migration_style_guide.md @@ -67,7 +67,7 @@ body: For example: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] DOWNTIME = true DOWNTIME_REASON = 'This migration requires downtime because ...' @@ -95,7 +95,7 @@ migration. For this to work your migration needs to include the module `Gitlab::Database::MultiThreadedMigration`: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers include Gitlab::Database::MultiThreadedMigration end @@ -105,7 +105,7 @@ You can then use the method `with_multiple_threads` to perform work in separate threads. For example: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers include Gitlab::Database::MultiThreadedMigration @@ -139,7 +139,7 @@ by calling the method `disable_ddl_transaction!` in the body of your migration class like so: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -167,7 +167,7 @@ the method `disable_ddl_transaction!` in the body of your migration class like so: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -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. ```ruby -class Migration < ActiveRecord::Migration +class Migration < ActiveRecord::Migration[4.2] def change 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 value of `10` you'd write the following: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -365,7 +365,7 @@ If you need more complex logic you can define and use models local to a migration. For example: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] class Project < ActiveRecord::Base self.table_name = 'projects' end diff --git a/doc/development/prometheus_metrics.md b/doc/development/prometheus_metrics.md index b6b6d9665ea..0511e735843 100644 --- a/doc/development/prometheus_metrics.md +++ b/doc/development/prometheus_metrics.md @@ -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. ```ruby -class ImportCommonMetrics < ActiveRecord::Migration +class ImportCommonMetrics < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers require Rails.root.join('db/importers/common_metrics_importer.rb') diff --git a/doc/development/sql.md b/doc/development/sql.md index e1e1d31a85f..06005a0a6f8 100644 --- a/doc/development/sql.md +++ b/doc/development/sql.md @@ -106,7 +106,7 @@ transaction. Transactions for migrations can be disabled using the following pattern: ```ruby -class MigrationName < ActiveRecord::Migration +class MigrationName < ActiveRecord::Migration[4.2] disable_ddl_transaction! end ``` @@ -114,7 +114,7 @@ end For example: ```ruby -class AddUsersLowerUsernameEmailIndexes < ActiveRecord::Migration +class AddUsersLowerUsernameEmailIndexes < ActiveRecord::Migration[4.2] disable_ddl_transaction! def up diff --git a/doc/development/what_requires_downtime.md b/doc/development/what_requires_downtime.md index 3630a28fae9..24edd05da2f 100644 --- a/doc/development/what_requires_downtime.md +++ b/doc/development/what_requires_downtime.md @@ -88,7 +88,7 @@ renaming. For example ```ruby # A regular migration in db/migrate -class RenameUsersUpdatedAtToUpdatedAtTimestamp < ActiveRecord::Migration +class RenameUsersUpdatedAtToUpdatedAtTimestamp < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -118,7 +118,7 @@ We can perform this cleanup using ```ruby # A post-deployment migration in db/post_migrate -class CleanupUsersUpdatedAtRename < ActiveRecord::Migration +class CleanupUsersUpdatedAtRename < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -157,7 +157,7 @@ as follows: ```ruby # A regular migration in db/migrate -class ChangeUsersUsernameStringToText < ActiveRecord::Migration +class ChangeUsersUsernameStringToText < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -178,7 +178,7 @@ Next we need to clean up our changes using a post-deployment migration: ```ruby # A post-deployment migration in db/post_migrate -class ChangeUsersUsernameStringToTextCleanup < ActiveRecord::Migration +class ChangeUsersUsernameStringToTextCleanup < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -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: ```ruby -class ExampleMigration < ActiveRecord::Migration +class ExampleMigration < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers disable_ddl_transaction! @@ -257,7 +257,7 @@ release) by a cleanup migration, which should steal from the queue and handle any remaining rows. For example: ```ruby -class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration +class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false @@ -322,7 +322,7 @@ Migrations can take advantage of this by using the method `add_concurrent_index`. For example: ```ruby -class MyMigration < ActiveRecord::Migration +class MyMigration < ActiveRecord::Migration[4.2] def up add_concurrent_index :projects, :column_name end |