strong_migrations 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 250e255ba679a0e581fb86ed13b2824cf5749b7dc3ac5bf0a26bfffebe314fb8
4
- data.tar.gz: d91882cb145d2f59a688e41e0d20301c6ca41d3e5e9790be9996eb256cc26dd2
3
+ metadata.gz: 506dc7670dbae5a7f4bb621d39da43e67098b9629cc76a854d2677d006f0919a
4
+ data.tar.gz: 3cfd8d8f74a1575b23485ca16ef26f04de5f52b8c059fcded94d1a42410afc41
5
5
  SHA512:
6
- metadata.gz: b0bba6d87fd23e3bf68d8a8274cc6d22346a73f0001e8078f99f3c7a039772e39ded14138a2ad87eb7476f855a56647a1e07f84e7dadc96d5f3df53aebd27c9a
7
- data.tar.gz: b985a53c42f12ec3268f6fd2570bdb2cdf777f80217b17a68872e86d4366b5939a702c0b8551b0ddab4f44ddfb9ef5da8a3f74ca97365124a086d46c2fe66f10
6
+ metadata.gz: 0b55091991fdba05bbc088a3b8967a66473e150ccce62f2065d671fa1b61f2dc70b0cd149f5a9645135b9fdcc9e10f344b7ea548e391ab9bcca371bdff35443c
7
+ data.tar.gz: '09a1b778c608aa600a3e84ca99da6fb8ad5771cec839092b2f77e0788e6dc6a0940442665de94ec5ea07487fcdb7b665bc41a258c44266f79f322616336986e9'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.8.0 (2026-05-14)
2
+
3
+ - Added check for `rename_enum_value`
4
+
1
5
  ## 2.7.0 (2026-04-25)
2
6
 
3
7
  - Added check for `add_foreign_key` with MySQL and MariaDB
data/README.md CHANGED
@@ -80,6 +80,7 @@ Postgres-specific checks:
80
80
  - [adding a json column](#adding-a-json-column)
81
81
  - [adding a column with a volatile default value](#adding-a-column-with-a-volatile-default-value)
82
82
  - [setting NOT NULL on an existing column](#setting-not-null-on-an-existing-column)
83
+ - [renaming an enum value](#renaming-an-enum-value)
83
84
  - [renaming a schema](#renaming-a-schema)
84
85
 
85
86
  MySQL and MariaDB-specific checks:
@@ -686,6 +687,38 @@ class ValidateSomeColumnNotNull < ActiveRecord::Migration[8.1]
686
687
  end
687
688
  ```
688
689
 
690
+ ### Renaming an enum value
691
+
692
+ #### Bad
693
+
694
+ Renaming an enum value that’s in use will cause errors in your application.
695
+
696
+ ```ruby
697
+ class RenameDoneToCompleted < ActiveRecord::Migration[8.1]
698
+ def change
699
+ rename_enum_value :status, from: "done", to: "completed"
700
+ end
701
+ end
702
+ ```
703
+
704
+ #### Good
705
+
706
+ A safer approach is to:
707
+
708
+ 1. Add a new enum value before or after the old value
709
+ 2. Update application code to handle both values and write the new value
710
+ 3. Backfill data from the old value to the new value
711
+
712
+ ```ruby
713
+ class AddCompletedToStatus < ActiveRecord::Migration[8.1]
714
+ def up
715
+ add_enum_value :status, "completed", after: "done"
716
+ end
717
+ end
718
+ ```
719
+
720
+ Removing enum values is not supported in Postgres (without creating a new enum).
721
+
689
722
  ### Renaming a schema
690
723
 
691
724
  #### Bad
@@ -79,6 +79,8 @@ module StrongMigrations
79
79
  check_remove_index(*args)
80
80
  when :rename_column
81
81
  check_rename_column
82
+ when :rename_enum_value
83
+ check_rename_enum_value(*args)
82
84
  when :rename_schema
83
85
  check_rename_schema
84
86
  when :rename_table
@@ -467,6 +467,14 @@ module StrongMigrations
467
467
  raise_error :rename_column
468
468
  end
469
469
 
470
+ def check_rename_enum_value(*args)
471
+ options = args.extract_options!
472
+ type_name, _ = args
473
+
474
+ raise_error :rename_enum_value,
475
+ command: command_str("add_enum_value", [type_name, options[:to], {after: options[:from]}])
476
+ end
477
+
470
478
  def check_rename_schema
471
479
  raise_error :rename_schema
472
480
  end
@@ -117,6 +117,20 @@ in your application. A safer approach is to:
117
117
  5. Stop writing to the old column
118
118
  6. Drop the old column",
119
119
 
120
+ rename_enum_value:
121
+ "Renaming an enum value that's in use will cause errors
122
+ in your application. A safer approach is to:
123
+
124
+ 1. Add a new enum value before or after the old value
125
+ 2. Update application code to handle both values and write the new value
126
+ 3. Backfill data from the old value to the new value
127
+
128
+ class %{migration_name} < ActiveRecord::Migration%{migration_suffix}
129
+ def up
130
+ %{command}
131
+ end
132
+ end",
133
+
120
134
  rename_schema:
121
135
  "Renaming a schema that's in use will cause errors
122
136
  in your application. A safer approach is to:
@@ -1,3 +1,3 @@
1
1
  module StrongMigrations
2
- VERSION = "2.7.0"
2
+ VERSION = "2.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 4.0.6
75
+ rubygems_version: 4.0.10
76
76
  specification_version: 4
77
77
  summary: Catch unsafe migrations in development
78
78
  test_files: []