linter: add require-enum-value-ordering rule#992
linter: add require-enum-value-ordering rule#992cabello wants to merge 2 commits intosbdchd:masterfrom
Conversation
Add a new lint rule that flags ALTER TYPE ... ADD VALUE statements missing BEFORE or AFTER, which silently append to the end of the enum and can cause unexpected ordering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
👷 Deploy request for squawkhq pending review.Visit the deploys page to approve it
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi 👋 |
|
Cool rule, thank you for putting this together! I was curious how Django handles this, but turns out they don't support Postgres enum types unfortunately.
For the docs, I think it might be helpful to show the query pattern aka the select query you're making that depends on the ordering. Do you have an example? |
|
Thank you for the reply, we don't use ORMs so we try to benefit to all features the database has datatypes, triggers, materialized views, etc. It's the output of a pg_dump of the database, we commit that to git so CI can break if it changes after running migrations; it includes enum creation and internally Postgres must use some tinyint to represent that, it's not trivial to manipulate enums in Postgres. If dev A dumps the schema, commits and the values were A B C then the CI runs it and due to the order of execution the values are A C B, then that dev has to find a way to sync with master otherwise they will always be reverting that change. |
Summary
require-enum-value-orderingthat flagsALTER TYPE ... ADD VALUEstatements missingBEFOREorAFTERTest plan
cargo test -p squawk-linter require_enum_value_ordering— all 7 tests passcargo test -p squawk-linter— full suite (261 tests) passesALTER TYPE ... ADD VALUEwithoutBEFORE/AFTER🤖 Generated with Claude Code