Each database structure check starts with an SQL query to the pg_catalog.
- SQLFluff is used as a linter for all SQL queries
- All queries must be schema-aware, i.e. we filter out database objects on a schema basis:
where nsp.nspname = :schema_name_param::text
- All tables and indexes names in the query results must be schema-qualified.
We use
::regclassonoidfor that.select psui.relid::regclass::text as table_name, psui.indexrelid::regclass::text as index_name
- All names should be enclosed in double quotes, if required.
- The columns for the index or foreign key must be returned in the order they are used in the index or foreign key:
select array_agg(quote_ident(a.attname) || ',' || a.attnotnull::text order by u.ordinality) as columns
- All query results must be ordered in some way.
- All queries must have a brief description. Links to documentation or articles with detailed descriptions are welcome.
- The name of the sql-file with a query must correspond to diagnostic name in Java project.
- Remember to update
README.md.