feat(lint): add linter rules for migration and naming conventions
* Implement migration safety rules: - MIG001: Warn on CREATE INDEX without CONCURRENT. - MIG002: Warn on ALTER TABLE ADD COLUMN NOT NULL without DEFAULT. - MIG003: Warn on ALTER TABLE ADD CONSTRAINT without NOT VALID. * Implement naming conventions rules: - NAM001: Warn on non-snake_case table names. - NAM002: Warn on non-snake_case column names in CREATE TABLE. - NAM003: Warn on non-snake_case function names. * Add test fixtures for all new rules.
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
-- Fixtures for naming rules (NAM001-NAM003).
|
||||
-- Quoted identifiers preserve case in the PG parse tree; unquoted identifiers
|
||||
-- are always folded to lowercase by the parser and cannot violate snake_case.
|
||||
|
||||
-- NAM001: quoted CamelCase table name
|
||||
CREATE TABLE "UserAccounts" (
|
||||
-- NAM002: quoted camelCase column names
|
||||
"userId" integer PRIMARY KEY,
|
||||
"emailAddress" text NOT NULL
|
||||
);
|
||||
|
||||
-- NAM003: quoted CamelCase function name
|
||||
CREATE FUNCTION "GetUserById"(p_id integer) RETURNS text LANGUAGE sql AS $$
|
||||
SELECT email FROM users WHERE id = p_id
|
||||
$$;
|
||||
Reference in New Issue
Block a user