From 5956acf4ebffe8d4fa0248e54f6f8ad6d2ecbad2 Mon Sep 17 00:00:00 2001 From: ColinBruce <colin.bruce@digital.justice.gov.uk> Date: Mon, 11 Sep 2023 10:06:25 +0100 Subject: [PATCH 1/3] Initial, empty, commit To simulate a normal branch, allow github to build a standard image and deploy it, before we remove the gem and migrations From 0f7eabbae900d9708aff1c94cb1c208cab1a0c3b Mon Sep 17 00:00:00 2001 From: ColinBruce <colin.bruce@digital.justice.gov.uk> Date: Fri, 1 Sep 2023 08:04:58 +0100 Subject: [PATCH 2/3] Update: Remove Webdack gem --- Gemfile | 1 - Gemfile.lock | 3 --- 2 files changed, 4 deletions(-) diff --git a/Gemfile b/Gemfile index 9b0e47b186..60225170ec 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,6 @@ gem "sentry-ruby" gem "sentry-sidekiq" gem "simple_command" gem "tzinfo-data" -gem "webdack-uuid_migration", "~> 1.4.0" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", ">= 1.1.0", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 75c8d6e2f9..d46ad6d953 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -696,8 +696,6 @@ GEM addressable httpi (~> 3.0) nokogiri (>= 1.4.2) - webdack-uuid_migration (1.4.0) - activerecord (>= 4.0) webmock (3.19.1) addressable (>= 2.8.0) crack (>= 0.3.2) @@ -809,7 +807,6 @@ DEPENDENCIES tzinfo-data vcr view_component - webdack-uuid_migration (~> 1.4.0) webmock webrick From 7ac8ac29bceba3e24c737e37c289fb23e9c13ade Mon Sep 17 00:00:00 2001 From: ColinBruce <colin.bruce@digital.justice.gov.uk> Date: Fri, 1 Sep 2023 08:07:56 +0100 Subject: [PATCH 3/3] Remove migrations before the final webdack migration Replace final webdack migration with an error This is based on an older [medium post](https://medium.com/clutter-engineering/cleaning-up-old-rails-migrations-1b55b638abb5) describing how to clean up your codebase by removing old migrations and using `db:schema:load`. I updated the error message with more explanation and replaced with newer rails db commands When the db:prepare finds a database with an existing migrations table, it tries to run them all again. This unless should ensure that new migrations are run in uat, staging and prod, while alerting devs trying to run locally --- ...80807211758_create_legal_aid_applications.rb | 9 --------- db/migrate/20180820112730_create_applicant.rb | 10 ---------- ...pplicant_reference_legal_aid_applications.rb | 5 ----- ...legal_aid_application_reference_applicant.rb | 7 ------- .../20180829144026_create_proceeding_types.rb | 11 ----------- ...te_legal_aid_application_proceeding_types.rb | 9 --------- ...43012_add_new_columns_to_proceeding_types.rb | 8 -------- .../20180913101947_rename_name_to_first_name.rb | 5 ----- ...0180913103146_add_last_name_to_applicants.rb | 5 ----- ...917084624_add_email_address_to_applicants.rb | 5 ----- ...d_national_insurance_number_to_applicants.rb | 5 ----- db/migrate/20181011143410_create_addresses.rb | 13 ------------- .../20181017202608_enable_pgcrypto_extension.rb | 5 ----- db/migrate/20181018165257_add_foreign_keys.rb | 7 ------- db/migrate/20181018165405_id_to_uuid_fk.rb | 17 ----------------- db/migrate/20181018165537_old_migrations.rb | 17 +++++++++++++++++ db/migrate/20181018165537_uuid_migration.rb | 16 ---------------- 17 files changed, 17 insertions(+), 137 deletions(-) delete mode 100644 db/migrate/20180807211758_create_legal_aid_applications.rb delete mode 100644 db/migrate/20180820112730_create_applicant.rb delete mode 100644 db/migrate/20180821121644_add_applicant_reference_legal_aid_applications.rb delete mode 100644 db/migrate/20180821122427_remove_legal_aid_application_reference_applicant.rb delete mode 100644 db/migrate/20180829144026_create_proceeding_types.rb delete mode 100644 db/migrate/20180829150801_create_legal_aid_application_proceeding_types.rb delete mode 100644 db/migrate/20180911143012_add_new_columns_to_proceeding_types.rb delete mode 100644 db/migrate/20180913101947_rename_name_to_first_name.rb delete mode 100644 db/migrate/20180913103146_add_last_name_to_applicants.rb delete mode 100644 db/migrate/20180917084624_add_email_address_to_applicants.rb delete mode 100644 db/migrate/20180929123828_add_national_insurance_number_to_applicants.rb delete mode 100644 db/migrate/20181011143410_create_addresses.rb delete mode 100644 db/migrate/20181017202608_enable_pgcrypto_extension.rb delete mode 100644 db/migrate/20181018165257_add_foreign_keys.rb delete mode 100644 db/migrate/20181018165405_id_to_uuid_fk.rb create mode 100644 db/migrate/20181018165537_old_migrations.rb delete mode 100644 db/migrate/20181018165537_uuid_migration.rb diff --git a/db/migrate/20180807211758_create_legal_aid_applications.rb b/db/migrate/20180807211758_create_legal_aid_applications.rb deleted file mode 100644 index 7eec14cdc7..0000000000 --- a/db/migrate/20180807211758_create_legal_aid_applications.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateLegalAidApplications < ActiveRecord::Migration[5.2] - def change - create_table :legal_aid_applications do |t| - t.string :application_ref - - t.timestamps - end - end -end diff --git a/db/migrate/20180820112730_create_applicant.rb b/db/migrate/20180820112730_create_applicant.rb deleted file mode 100644 index dff3cfc17f..0000000000 --- a/db/migrate/20180820112730_create_applicant.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateApplicant < ActiveRecord::Migration[5.2] - def change - create_table :applicants do |t| - t.string :name - t.date :date_of_birth - t.timestamps - t.references :legal_aid_application - end - end -end diff --git a/db/migrate/20180821121644_add_applicant_reference_legal_aid_applications.rb b/db/migrate/20180821121644_add_applicant_reference_legal_aid_applications.rb deleted file mode 100644 index ebab253c9b..0000000000 --- a/db/migrate/20180821121644_add_applicant_reference_legal_aid_applications.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddApplicantReferenceLegalAidApplications < ActiveRecord::Migration[5.2] - def change - add_reference :legal_aid_applications, :applicant, index: true - end -end diff --git a/db/migrate/20180821122427_remove_legal_aid_application_reference_applicant.rb b/db/migrate/20180821122427_remove_legal_aid_application_reference_applicant.rb deleted file mode 100644 index 8a75741227..0000000000 --- a/db/migrate/20180821122427_remove_legal_aid_application_reference_applicant.rb +++ /dev/null @@ -1,7 +0,0 @@ -# rubocop:disable Rails/ReversibleMigration -class RemoveLegalAidApplicationReferenceApplicant < ActiveRecord::Migration[5.2] - def change - remove_reference :applicants, :legal_aid_application, index: true - end -end -# rubocop:enable Rails/ReversibleMigration diff --git a/db/migrate/20180829144026_create_proceeding_types.rb b/db/migrate/20180829144026_create_proceeding_types.rb deleted file mode 100644 index 049b253c2a..0000000000 --- a/db/migrate/20180829144026_create_proceeding_types.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateProceedingTypes < ActiveRecord::Migration[5.2] - def change - create_table :proceeding_types do |t| - t.string :code, index: true - t.string :ccms_code - t.string :meaning - t.string :description - t.timestamps - end - end -end diff --git a/db/migrate/20180829150801_create_legal_aid_application_proceeding_types.rb b/db/migrate/20180829150801_create_legal_aid_application_proceeding_types.rb deleted file mode 100644 index c1d5899789..0000000000 --- a/db/migrate/20180829150801_create_legal_aid_application_proceeding_types.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateLegalAidApplicationProceedingTypes < ActiveRecord::Migration[5.2] - def change - create_table :application_proceeding_types do |t| - t.references :legal_aid_application - t.references :proceeding_type - t.timestamps - end - end -end diff --git a/db/migrate/20180911143012_add_new_columns_to_proceeding_types.rb b/db/migrate/20180911143012_add_new_columns_to_proceeding_types.rb deleted file mode 100644 index 5659153603..0000000000 --- a/db/migrate/20180911143012_add_new_columns_to_proceeding_types.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddNewColumnsToProceedingTypes < ActiveRecord::Migration[5.2] - def change - add_column :proceeding_types, :ccms_category_law, :string - add_column :proceeding_types, :ccms_category_law_code, :string - add_column :proceeding_types, :ccms_matter, :string - add_column :proceeding_types, :ccms_matter_code, :string - end -end diff --git a/db/migrate/20180913101947_rename_name_to_first_name.rb b/db/migrate/20180913101947_rename_name_to_first_name.rb deleted file mode 100644 index f351886947..0000000000 --- a/db/migrate/20180913101947_rename_name_to_first_name.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RenameNameToFirstName < ActiveRecord::Migration[5.2] - def change - rename_column :applicants, :name, :first_name - end -end diff --git a/db/migrate/20180913103146_add_last_name_to_applicants.rb b/db/migrate/20180913103146_add_last_name_to_applicants.rb deleted file mode 100644 index 1538d05ffd..0000000000 --- a/db/migrate/20180913103146_add_last_name_to_applicants.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLastNameToApplicants < ActiveRecord::Migration[5.2] - def change - add_column :applicants, :last_name, :string - end -end diff --git a/db/migrate/20180917084624_add_email_address_to_applicants.rb b/db/migrate/20180917084624_add_email_address_to_applicants.rb deleted file mode 100644 index 7215a32380..0000000000 --- a/db/migrate/20180917084624_add_email_address_to_applicants.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEmailAddressToApplicants < ActiveRecord::Migration[5.2] - def change - add_column :applicants, :email_address, :string - end -end diff --git a/db/migrate/20180929123828_add_national_insurance_number_to_applicants.rb b/db/migrate/20180929123828_add_national_insurance_number_to_applicants.rb deleted file mode 100644 index 1364c42904..0000000000 --- a/db/migrate/20180929123828_add_national_insurance_number_to_applicants.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNationalInsuranceNumberToApplicants < ActiveRecord::Migration[5.2] - def change - add_column :applicants, :national_insurance_number, :string - end -end diff --git a/db/migrate/20181011143410_create_addresses.rb b/db/migrate/20181011143410_create_addresses.rb deleted file mode 100644 index 4c6e9f69da..0000000000 --- a/db/migrate/20181011143410_create_addresses.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateAddresses < ActiveRecord::Migration[5.2] - def change - create_table :addresses do |t| - t.string :address_line_one - t.string :address_line_two - t.string :city - t.string :county - t.string :postcode - t.references :applicant, foreign_key: true, null: false - t.timestamps null: false - end - end -end diff --git a/db/migrate/20181017202608_enable_pgcrypto_extension.rb b/db/migrate/20181017202608_enable_pgcrypto_extension.rb deleted file mode 100644 index 9a4ae47d21..0000000000 --- a/db/migrate/20181017202608_enable_pgcrypto_extension.rb +++ /dev/null @@ -1,5 +0,0 @@ -class EnablePgcryptoExtension < ActiveRecord::Migration[5.1] - def change - enable_extension 'pgcrypto' - end -end diff --git a/db/migrate/20181018165257_add_foreign_keys.rb b/db/migrate/20181018165257_add_foreign_keys.rb deleted file mode 100644 index 25789db317..0000000000 --- a/db/migrate/20181018165257_add_foreign_keys.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddForeignKeys < ActiveRecord::Migration[5.2] - def change - add_foreign_key :application_proceeding_types, :proceeding_types - add_foreign_key :application_proceeding_types, :legal_aid_applications - add_foreign_key :legal_aid_applications, :applicants - end -end diff --git a/db/migrate/20181018165405_id_to_uuid_fk.rb b/db/migrate/20181018165405_id_to_uuid_fk.rb deleted file mode 100644 index ab9731d8d2..0000000000 --- a/db/migrate/20181018165405_id_to_uuid_fk.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'webdack/uuid_migration/helpers' - -class IdToUuidFk < ActiveRecord::Migration[5.2] - def change - reversible do |dir| - dir.up do - primary_key_and_all_references_to_uuid :applicants - primary_key_and_all_references_to_uuid :legal_aid_applications - primary_key_and_all_references_to_uuid :proceeding_types - end - - dir.down do - raise ActiveRecord::IrreversibleMigration - end - end - end -end diff --git a/db/migrate/20181018165537_old_migrations.rb b/db/migrate/20181018165537_old_migrations.rb new file mode 100644 index 0000000000..78412a3f7b --- /dev/null +++ b/db/migrate/20181018165537_old_migrations.rb @@ -0,0 +1,17 @@ +class OldMigrations < ActiveRecord::Migration[5.2] + REQUIRED_VERSION = 20181018165537 + def up + if ActiveRecord::Migrator.current_version < REQUIRED_VERSION + error_message = <<~OLDMIGRATIONERROR + Due to old migrations requiring gems we no longer use migrations + prior to this have been deleted, this will not affect production + environments, but will affect developers re-creating their local + databases. + We recommend using the newer `rails db:reset`, this will run drop, + create, schema:load, and seed. If you need to run `rails db:migrate` + then you will need to run `rails db:schema:load` must be run first + OLDMIGRATIONERROR + raise StandardError, error_message unless Rails.env.production? + end + end +end diff --git a/db/migrate/20181018165537_uuid_migration.rb b/db/migrate/20181018165537_uuid_migration.rb deleted file mode 100644 index 8429a5f0ce..0000000000 --- a/db/migrate/20181018165537_uuid_migration.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'webdack/uuid_migration/helpers' - -class UuidMigration < ActiveRecord::Migration[5.2] - def change - reversible do |dir| - dir.up do - primary_key_to_uuid :addresses - primary_key_to_uuid :application_proceeding_types - end - - dir.down do - raise ActiveRecord::IrreversibleMigration - end - end - end -end