From 301add4992640486b4a477ca1d129ffc6a174e6d Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Mon, 15 Jan 2024 11:36:21 +1100 Subject: [PATCH] Remove faulty migration generation The long timestamps don't play well with Rails default timestamps for migrations. They are always seen as the newest. Not using long timestamps leads to duplicate timestamps though. The better solution is to use `rails generate migration` and copy the `change` method. --- spec/models/database_spec.rb | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/spec/models/database_spec.rb b/spec/models/database_spec.rb index 2731e145b8..b8f89dc1f2 100644 --- a/spec/models/database_spec.rb +++ b/spec/models/database_spec.rb @@ -60,11 +60,6 @@ RSpec.describe "Database" do puts migrations.join("\n") puts "\nTo disable this warning, add the class name(s) of the model(s) to models_todo " \ "in #{__FILE__}" - - return if ENV.fetch("OFN_WRITE_FOREIGN_KEY_MIGRATIONS", false) - - puts "Migrations have not been written to disk. To write migrations to disk, please " \ - "add OFN_WRITE_FOREIGN_KEY_MIGRATIONS=true to the file .env.test.local" end def process_association(model_class, association) @@ -104,9 +99,6 @@ RSpec.describe "Database" do migration_name = "add_foreign_key_to_#{model_class.table_name}_" \ "#{foreign_key_table_name}_#{foreign_key_column}" migration_class_name = migration_name.camelize - millisecond_timestamp = generate_timestamp - migration_file_name = "db/migrate/#{millisecond_timestamp}_" \ - "#{migration_name}.rb" orphaned_records_query = generate_orphaned_records_query(model_class, foreign_key_table_name, foreign_key_column) @@ -122,11 +114,6 @@ RSpec.describe "Database" do end MIGRATION - if ENV.fetch("OFN_WRITE_FOREIGN_KEY_MIGRATIONS", false) - File.open(migration_file_name, 'w') do |file| - file.puts migration - end - end migration end