diff --git a/db/post_migrate/20221027203951_drop_experiment_users_table.rb b/db/post_migrate/20221027203951_drop_experiment_users_table.rb index 95455db98e5c6f08df0fc0cecf8beb916cbe9253..838a960574004586cfbce2f22df1d09b9d5ddb59 100644 --- a/db/post_migrate/20221027203951_drop_experiment_users_table.rb +++ b/db/post_migrate/20221027203951_drop_experiment_users_table.rb @@ -6,7 +6,7 @@ def up end def down - create_table :experiment_users do |t| # rubocop:disable Migration/SchemaAdditionMethodsNoPost + create_table :experiment_users do |t| t.bigint :experiment_id, null: false t.bigint :user_id, null: false t.integer :group_type, limit: 2, null: false, default: 0 diff --git a/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb b/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb index 371f214de6de70443925761ad3940cdf5508b1a3..f7c10192afb92211e567fa51017d1d1ad8027fc8 100644 --- a/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb +++ b/db/post_migrate/20221114142602_drop_experiment_subjects_table.rb @@ -7,7 +7,7 @@ def up def down unless table_exists?(:experiment_subjects) - create_table :experiment_subjects do |t| # rubocop:disable Migration/SchemaAdditionMethodsNoPost + create_table :experiment_subjects do |t| t.bigint :experiment_id, null: false t.bigint :user_id t.bigint :project_id diff --git a/db/post_migrate/20221114142616_drop_experiments_table.rb b/db/post_migrate/20221114142616_drop_experiments_table.rb index da6c112249402697e609621e06e523b2e00eb791..a8280eb9f6954ef023c0f3d42aad52d48a012be6 100644 --- a/db/post_migrate/20221114142616_drop_experiments_table.rb +++ b/db/post_migrate/20221114142616_drop_experiments_table.rb @@ -9,7 +9,7 @@ def up def down unless table_exists?(:experiments) - create_table :experiments do |t| # rubocop:disable Migration/SchemaAdditionMethodsNoPost + create_table :experiments do |t| t.text :name, null: false t.index :name, unique: true diff --git a/db/post_migrate/20221115184525_remove_namespaces_tmp_project_id_column.rb b/db/post_migrate/20221115184525_remove_namespaces_tmp_project_id_column.rb index 01424f8113f71995440285d00d226bd8e03d2a62..d044c44e95e362922c2b4cced1fe5696132a7d57 100644 --- a/db/post_migrate/20221115184525_remove_namespaces_tmp_project_id_column.rb +++ b/db/post_migrate/20221115184525_remove_namespaces_tmp_project_id_column.rb @@ -14,9 +14,9 @@ def up def down unless column_exists?(:namespaces, :tmp_project_id) with_lock_retries do - # rubocop:disable Migration/SchemaAdditionMethodsNoPost, Migration/AddColumnsToWideTables + # rubocop:disable Migration/AddColumnsToWideTables add_column :namespaces, :tmp_project_id, :integer - # rubocop:enable Migration/SchemaAdditionMethodsNoPost, Migration/AddColumnsToWideTables + # rubocop:enable Migration/AddColumnsToWideTables end end diff --git a/db/post_migrate/20230104103748_remove_new_amount_used_column.rb b/db/post_migrate/20230104103748_remove_new_amount_used_column.rb index 0aaa7c1bd8f90900976e6088dacb70ff36bcbd5b..b93879c2b50393a249717f8b28e67b459d928d34 100644 --- a/db/post_migrate/20230104103748_remove_new_amount_used_column.rb +++ b/db/post_migrate/20230104103748_remove_new_amount_used_column.rb @@ -10,10 +10,10 @@ def up def down return if column_exists?(:ci_project_monthly_usages, :new_amount_used) - # rubocop:disable Migration/SchemaAdditionMethodsNoPost, Migration/AddColumnsToWideTables + # rubocop:disable Migration/AddColumnsToWideTables add_column :ci_project_monthly_usages, :new_amount_used, :decimal, default: 0.0, precision: 18, scale: 2, null: false - # rubocop:enable Migration/SchemaAdditionMethodsNoPost, Migration/AddColumnsToWideTables + # rubocop:enable Migration/AddColumnsToWideTables install_rename_triggers :ci_project_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME end diff --git a/db/post_migrate/20230105180002_remove_new_amount_used_column_on_ci_namespace_monthly_usages.rb b/db/post_migrate/20230105180002_remove_new_amount_used_column_on_ci_namespace_monthly_usages.rb index cebda3e353e25a541cb0b04af20a793a52dd33b3..11e212a697d318b866f402df6b6b94732a9f1c0b 100644 --- a/db/post_migrate/20230105180002_remove_new_amount_used_column_on_ci_namespace_monthly_usages.rb +++ b/db/post_migrate/20230105180002_remove_new_amount_used_column_on_ci_namespace_monthly_usages.rb @@ -12,10 +12,10 @@ def up def down return if column_exists?(:ci_namespace_monthly_usages, :new_amount_used) - # rubocop:disable Migration/SchemaAdditionMethodsNoPost, Migration/AddColumnsToWideTables + # rubocop:disable Migration/AddColumnsToWideTables add_column :ci_namespace_monthly_usages, :new_amount_used, :decimal, default: 0.0, precision: 18, scale: 2, null: false - # rubocop:enable Migration/SchemaAdditionMethodsNoPost, Migration/AddColumnsToWideTables + # rubocop:enable Migration/AddColumnsToWideTables install_rename_triggers :ci_namespace_monthly_usages, :amount_used, :new_amount_used, trigger_name: TRIGGER_NAME end diff --git a/db/post_migrate/20230201082038_drop_web_hook_calls_high_column.rb b/db/post_migrate/20230201082038_drop_web_hook_calls_high_column.rb index 7f90b3293d8fc68e8be55a0e8497d4bbb79e5db7..76c93be0f42330232bf414b5a679f0999cb1df3b 100644 --- a/db/post_migrate/20230201082038_drop_web_hook_calls_high_column.rb +++ b/db/post_migrate/20230201082038_drop_web_hook_calls_high_column.rb @@ -14,9 +14,7 @@ def up def down with_lock_retries do unless column_exists?(:plan_limits, :web_hook_calls_high) - # rubocop:disable Migration/SchemaAdditionMethodsNoPost add_column :plan_limits, :web_hook_calls_high, :integer, default: 0 - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end end end diff --git a/db/post_migrate/20230316185746_drop_packages_events_table.rb b/db/post_migrate/20230316185746_drop_packages_events_table.rb index bb51fc7ae9c5b2359ee0319984b9cd4d51e3c70d..f8b37651249f5bc4cd669415faed2e880fe25e2e 100644 --- a/db/post_migrate/20230316185746_drop_packages_events_table.rb +++ b/db/post_migrate/20230316185746_drop_packages_events_table.rb @@ -8,7 +8,7 @@ def up def down return if table_exists?(:packages_events) - create_table :packages_events do |t| # rubocop:disable Migration/SchemaAdditionMethodsNoPost + create_table :packages_events do |t| t.integer :event_type, limit: 2, null: false t.integer :event_scope, limit: 2, null: false t.integer :originator_type, limit: 2, null: false diff --git a/db/post_migrate/20230323131521_remove_machine_id_from_builds_metadata.rb b/db/post_migrate/20230323131521_remove_machine_id_from_builds_metadata.rb index f034bc21847315970379640d245113bafc921097..41d23735807957ed85467d8ecfd7e90b904fdb0d 100644 --- a/db/post_migrate/20230323131521_remove_machine_id_from_builds_metadata.rb +++ b/db/post_migrate/20230323131521_remove_machine_id_from_builds_metadata.rb @@ -14,7 +14,7 @@ def up end def down - add_column :p_ci_builds_metadata, :runner_machine_id, :bigint, if_not_exists: true # rubocop: disable Migration/SchemaAdditionMethodsNoPost + add_column :p_ci_builds_metadata, :runner_machine_id, :bigint, if_not_exists: true add_concurrent_partitioned_index :p_ci_builds_metadata, :runner_machine_id, name: INDEX_NAME, where: 'runner_machine_id IS NOT NULL' diff --git a/db/post_migrate/20230425114355_remove_application_settings_clickhouse_connection_string.rb b/db/post_migrate/20230425114355_remove_application_settings_clickhouse_connection_string.rb index d5bdd33a95285f7ab71d55832c10dbdf5089ae21..3c27c48a7f3dfebdcded6c1e9855f89d919de407 100644 --- a/db/post_migrate/20230425114355_remove_application_settings_clickhouse_connection_string.rb +++ b/db/post_migrate/20230425114355_remove_application_settings_clickhouse_connection_string.rb @@ -9,9 +9,7 @@ def up def down unless column_exists?(:application_settings, :clickhouse_connection_string) - # rubocop:disable Migration/SchemaAdditionMethodsNoPost add_column :application_settings, :clickhouse_connection_string, :text - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end add_text_limit :application_settings, :clickhouse_connection_string, 1024 diff --git a/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb b/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb index 8949e37dcc35733f24587e5a2ad429439fb7eaf6..3eb5fc13a2a216bbeebd7683c5c5aa035f74bcaa 100644 --- a/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb +++ b/db/post_migrate/20230501180958_drop_clusters_applications_cert_managers.rb @@ -10,7 +10,6 @@ def up # Based on init migration: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20181228175414_init_schema.rb#L680-L689 - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table "clusters_applications_cert_managers", id: :serial, force: :cascade do |t| t.integer "cluster_id", null: false @@ -23,5 +22,4 @@ def down t.index ["cluster_id"], name: "index_clusters_applications_cert_managers_on_cluster_id", unique: true end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb b/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb index 8d80bae0a5230232353dad585267785e015a4a49..2c7b7d89bf5fc20a4eb8eec8fa7271f23271bc1d 100644 --- a/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb +++ b/db/post_migrate/20230502134532_drop_clusters_applications_cilium.rb @@ -10,7 +10,6 @@ def up # Based on original migration: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20200615234047_create_clusters_applications_cilium.rb - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table :clusters_applications_cilium do |t| t.references :cluster, null: false, index: { unique: true } @@ -19,5 +18,4 @@ def down t.text :status_reason # rubocop:disable Migration/AddLimitToTextColumns end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb b/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb index c35cfc8fd963a1600d13864d07b7f006421a3118..1eeb7770c82a51ae2974d7c5b14339fc620ae4b6 100644 --- a/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb +++ b/db/post_migrate/20230502182754_drop_clusters_applications_crossplane.rb @@ -10,7 +10,6 @@ def up # Based on original migration: # https://gitlab.com/gitlab-org/gitlab/-/blob/8b1637296b286a5c46e0d8fdf6da42a43a7c9986/db/migrate/20191017191341_create_clusters_applications_crossplane.rb - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table :clusters_applications_crossplane, id: :integer do |t| t.timestamps_with_timezone null: false @@ -22,5 +21,4 @@ def down t.index :cluster_id, unique: true end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb b/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb index 21df851229c63ad7ed6592df164b0833a6569172..c435b356e010270cdbd4bd32692b0579a09232a2 100644 --- a/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb +++ b/db/post_migrate/20230502193525_drop_clusters_applications_helm.rb @@ -10,7 +10,6 @@ def up # Based on init schema: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20181228175414_init_schema.rb#L691-L702 - # rubocop:disable Migration/SchemaAdditionMethodsNoPost # rubocop:disable Migration/Datetime def down create_table "clusters_applications_helm", id: :serial, force: :cascade do |t| @@ -26,6 +25,5 @@ def down t.index ["cluster_id"], name: "index_clusters_applications_helm_on_cluster_id", unique: true end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost # rubocop:enable Migration/Datetime end diff --git a/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb b/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb index a349346f91b5b69c75890bed6c64fe7e67115cb5..3ccc536cb7e7719034e6edd4e51c9ec7dedd1f15 100644 --- a/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb +++ b/db/post_migrate/20230502201251_drop_clusters_applications_ingress.rb @@ -10,7 +10,6 @@ def up # Based on init schema: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20181228175414_init_schema.rb#L704-L715 - # rubocop:disable Migration/SchemaAdditionMethodsNoPost # rubocop:disable Migration/Datetime def down create_table "clusters_applications_ingress", id: :serial, force: :cascade do |t| @@ -27,6 +26,5 @@ def down t.index ["cluster_id"], name: "index_clusters_applications_ingress_on_cluster_id", unique: true end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost # rubocop:enable Migration/Datetime end diff --git a/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb b/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb index 3c2a0cc3ee84441a4314edd9108c0396822c6d1f..bd98aa6d19ca802c3e0b331a0087b9d10b0031a7 100644 --- a/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb +++ b/db/post_migrate/20230503115918_drop_clusters_applications_jupyter.rb @@ -10,7 +10,6 @@ def up # Based on init schema: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20181228175414_init_schema.rb#L717-L728 - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table "clusters_applications_jupyter", id: :serial, force: :cascade do |t| t.integer "cluster_id", null: false @@ -25,5 +24,4 @@ def down t.index ["oauth_application_id"], name: "index_clusters_applications_jupyter_on_oauth_application_id" end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb b/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb index c94b9bba64b8003a64db9e8ba536d4ab970287b2..e8473b7440851bf00e778d63f2be3eb2089ced65 100644 --- a/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb +++ b/db/post_migrate/20230503152349_drop_clusters_applications_knative.rb @@ -10,7 +10,6 @@ def up # Based on init migration: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20181228175414_init_schema.rb#L730-L740 - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table "clusters_applications_knative", id: :serial, force: :cascade do |t| t.integer "cluster_id", null: false @@ -25,5 +24,4 @@ def down t.index ["cluster_id"], name: "index_clusters_applications_knative_on_cluster_id", unique: true end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb b/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb index 6391c1ee5ae042f2a0f4e23ebc0fc3fab5839e23..b62452f2052e77df38e544af53e5670b9ea4f462 100644 --- a/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb +++ b/db/post_migrate/20230503173101_drop_clusters_applications_prometheus.rb @@ -10,7 +10,6 @@ def up # Based on init schema: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20181228175414_init_schema.rb#L742-L750 - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table "clusters_applications_prometheus", id: :serial, force: :cascade do |t| t.integer "cluster_id", null: false @@ -26,5 +25,4 @@ def down t.boolean "healthy" end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb b/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb index 813cb23f56ad725703c7425576394afbd4bf355a..a4ab75dbce5afae9948e6e5aef41a818faffe230 100644 --- a/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb +++ b/db/post_migrate/20230503175406_drop_clusters_applications_runners.rb @@ -10,7 +10,6 @@ def up # Based on init schema: # https://gitlab.com/gitlab-org/gitlab/-/blob/b237f836df215a4ada92b9406733e6cd2483ca2d/db/migrate/20181228175414_init_schema.rb#L752-L763 - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table "clusters_applications_runners", id: :serial, force: :cascade do |t| t.integer "cluster_id", null: false @@ -25,5 +24,4 @@ def down t.index ["runner_id"], name: "index_clusters_applications_runners_on_runner_id" end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb b/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb index 94d3a2faf3bbdfc38ab6a4b9b54c832c85312014..003f2d91b549e765d2966423590cc1a556031fd3 100644 --- a/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb +++ b/db/post_migrate/20230503181808_drop_serverless_domain_cluster.rb @@ -10,7 +10,6 @@ def up # Based on original migration: # https://gitlab.com/gitlab-org/gitlab/-/blob/5f7bd5b1455d87e2f1a2d1ae2c1147d51e97aa55/db/migrate/20191127030005_create_serverless_domain_cluster.rb - # rubocop:disable Migration/SchemaAdditionMethodsNoPost def down create_table :serverless_domain_cluster, id: false, primary_key: :uuid do |t| t.string :uuid, null: false, limit: 14, primary_key: true @@ -29,5 +28,4 @@ def down t.index :creator_id, name: 'index_serverless_domain_cluster_on_creator_id' end end - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end diff --git a/db/post_migrate/20230510130050_remove_ci_triggers_ref_column.rb b/db/post_migrate/20230510130050_remove_ci_triggers_ref_column.rb index fa4fab5b8df306ae90d4b2f708fdac17fe50067a..84b69f7bc86e8ac5297644351c7155a0bd28625f 100644 --- a/db/post_migrate/20230510130050_remove_ci_triggers_ref_column.rb +++ b/db/post_migrate/20230510130050_remove_ci_triggers_ref_column.rb @@ -8,8 +8,6 @@ def up end def down - # rubocop:disable Migration/SchemaAdditionMethodsNoPost add_column :ci_triggers, :ref, :string, if_not_exists: true - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end end diff --git a/db/post_migrate/20230518121320_remove_time_format_in_24h_column.rb b/db/post_migrate/20230518121320_remove_time_format_in_24h_column.rb index 60abf4b6d8bc75313ede8fd8b7d9700f4c895723..489c2446fe27822330fe1b1c993253257c1580ff 100644 --- a/db/post_migrate/20230518121320_remove_time_format_in_24h_column.rb +++ b/db/post_migrate/20230518121320_remove_time_format_in_24h_column.rb @@ -8,8 +8,6 @@ def up end def down - # rubocop:disable Migration/SchemaAdditionMethodsNoPost add_column :user_preferences, :time_format_in_24h, :boolean - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end end diff --git a/db/post_migrate/20230523125245_remove_project_ci_cd_setting_opt_in_jwt_column.rb b/db/post_migrate/20230523125245_remove_project_ci_cd_setting_opt_in_jwt_column.rb index 7f7d58edc1b7685134278d013c136f329ac0d8b7..2826077d6f07354e9ac730a8e73069d5a232ea83 100644 --- a/db/post_migrate/20230523125245_remove_project_ci_cd_setting_opt_in_jwt_column.rb +++ b/db/post_migrate/20230523125245_remove_project_ci_cd_setting_opt_in_jwt_column.rb @@ -8,8 +8,6 @@ def up end def down - # rubocop:disable Migration/SchemaAdditionMethodsNoPost add_column(:project_ci_cd_settings, :opt_in_jwt, :boolean, default: false, null: false, if_not_exists: true) - # rubocop:enable Migration/SchemaAdditionMethodsNoPost end end diff --git a/db/post_migrate/20230602063059_remove_broadcast_messages_namespace_id_column.rb b/db/post_migrate/20230602063059_remove_broadcast_messages_namespace_id_column.rb index ad7e23b7cb1687fc930bd4510b071f2e1ed27029..144b16e4806216e1c5f3e75158c641c3f4df53b1 100644 --- a/db/post_migrate/20230602063059_remove_broadcast_messages_namespace_id_column.rb +++ b/db/post_migrate/20230602063059_remove_broadcast_messages_namespace_id_column.rb @@ -10,9 +10,7 @@ def up end def down - # rubocop:disable Migration/SchemaAdditionMethodsNoPost add_column :broadcast_messages, :namespace_id, :bigint unless column_exists?(:broadcast_messages, :namespace_id) - # rubocop:enable Migration/SchemaAdditionMethodsNoPost add_concurrent_index :broadcast_messages, :namespace_id, name: INDEX_NAME end diff --git a/rubocop/cop/migration/schema_addition_methods_no_post.rb b/rubocop/cop/migration/schema_addition_methods_no_post.rb index c35b82f91573a8861742629c8472dc5889c969eb..53b47dc99dc3e602b0923ffb97f890e41baf4b0d 100644 --- a/rubocop/cop/migration/schema_addition_methods_no_post.rb +++ b/rubocop/cop/migration/schema_addition_methods_no_post.rb @@ -5,7 +5,7 @@ module RuboCop module Cop module Migration - # Cop that checks that no background batched migration helpers are called by regular migrations. + # Cop that checks that no schema migration methods are called by post-deployment migrations. class SchemaAdditionMethodsNoPost < RuboCop::Cop::Base include MigrationHelpers @@ -39,7 +39,7 @@ def on_send(node) private def rolling_back_migration?(node) - rolling_back_migration(node.parent) + node.each_ancestor(:def).any? { |a| rolling_back_migration(a) } end end end diff --git a/spec/rubocop/cop/migration/schema_addition_methods_no_post_spec.rb b/spec/rubocop/cop/migration/schema_addition_methods_no_post_spec.rb index 94c0638cf1bd86034f244a302f2d4b02fed735fa..92e714d7a0217bca927f6dc8ed8e57342c1f7037 100644 --- a/spec/rubocop/cop/migration/schema_addition_methods_no_post_spec.rb +++ b/spec/rubocop/cop/migration/schema_addition_methods_no_post_spec.rb @@ -42,5 +42,13 @@ def down end CODE end + + it "allows forbidden method to be called within nested statement" do + expect_no_offenses(<<~CODE) + def down + add_column(:table, :column, :boolean) unless column_exists?(:table, :column) + end + CODE + end end end