You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2. using the --fix flag adds zero changes to linted sql files
example:
assuming migrations/schema/test.sql
CREATETABLEaccount (
name character varying(255) NOT NULLPRIMARY KEY,
password text,
created_by character varying(255), -- NOT NULL == subaccount
created_at timestamptzNOT NULL DEFAULT CURRENT_TIMESTAMP
);
current
the sql files in
migrations/schema
,migrations/seed
andmigrations/testseed
are not lintedexpected
1. lint sql files with https://hub.docker.com/r/sqlfluff/sqlfluff
example commands:
i) single file
docker run -it --rm -v $PWD:/sql sqlfluff/sqlfluff:3.2.5 lint --dialect postgres migrations/schema/000001_account.up.sql
ii) directories
docker run -it --rm -v $PWD:/sql sqlfluff/sqlfluff:3.2.5 lint --dialect postgres migrations/schema
2. using the --fix flag adds zero changes to linted sql files
example:
assuming migrations/schema/test.sql
docker run -it --rm -v $PWD:/sql sqlfluff/sqlfluff:3.2.5 lint --dialect postgres migrations/schema/test.sql
returns 0 errors3. add a
migrations/.sqlfluff
config file with contents:now commands require a --config instead of a
--dialect
flagdocker run -it --rm -v $PWD:/sql sqlfluff/sqlfluff:3.2.5 lint --config migrations/.sqlfluff migrations/schema/test.sql
doc: https://docs.sqlfluff.com/en/stable/reference/cli.html
4. add "sql linting" section in
migrations/README.md
documenting example lint commandsexample:
The text was updated successfully, but these errors were encountered: