migrations/000001_create_users.down.sql:1:0: warning: ban-drop-table
1 | drop table users;
note: Dropping a table may break existing clients.
migrations/000001_create_users.up.sql
create table users (
id bigserial primary key,
username varchar(128) not null unique,
email text not null unique,
full_name text not null,
password_hash text not null
)
insert into users(username, email, full_name, password_hash)
values ('testusername111', 'testemail111@mail.com', 'John Doe', '$2a$10$eB3Axm6ikuREMCwYlxgrgOuEqjxL7r20ZIgaWziIL8JajzuXRQ6HW');
🚒 Rule Violations (1)
migrations/000001_create_users.up.sql:0:0: error: invalid-statement
0 | create table users (
1 | id bigserial primary key,
2 | username varchar(128) not null unique,
3 | email text not null unique,
4 | full_name text not null,
5 | password_hash text not null
6 | )
7 |
8 | insert into users(username, email, full_name, password_hash)
9 | values ('testusername111', 'testemail111@mail.com', 'John Doe', '$2a$10$eB3Axm6ikuREMCwYlxgrgOuEqjxL7r20ZIgaWziIL8JajzuXRQ6HW');
note: Postgres failed to parse query: syntax error at or near "insert"
help: Modify your Postgres statement to use valid syntax.
migrations/000002_create_categories.down.sql
drop index categories_unique_idx;
drop table categories;
drop type category_type;
🚒 Rule Violations (5)
migrations/000002_create_categories.down.sql:1:0: warning: prefer-robust-stmts
1 | drop index categories_unique_idx;
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000002_create_categories.down.sql:1:0: warning: require-concurrent-index-deletion
1 | drop index categories_unique_idx;
note: Deleting an index blocks selects, inserts, updates, and deletes on the index's table.
help: Delete the index CONCURRENTLY.
migrations/000002_create_categories.down.sql:2:1: warning: ban-drop-table
2 | drop table categories;
note: Dropping a table may break existing clients.
migrations/000002_create_categories.down.sql:2:1: warning: prefer-robust-stmts
2 | drop table categories;
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000002_create_categories.down.sql:3:1: warning: prefer-robust-stmts
3 | drop type category_type;
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000002_create_categories.up.sql
create type category_type as enum ('income', 'expense');
create table categories (
id bigserial primary key,
user_id varchar(128) not null,
name varchar(128) not null,
type category_type not null
);
create unique index categories_unique_idx on categories(user_id, type, name);
insert into categories(user_id, name, type) values ('testusername111', 'day job', 'income');
insert into categories(user_id, name, type) values ('testusername111', 'vigilante', 'income');
insert into categories(user_id, name, type) values ('testusername111', 'groceries', 'expense');
insert into categories(user_id, name, type) values ('testusername111', 'fun', 'expense');
insert into categories(user_id, name, type) values ('testusername111', 'eating out', 'expense');
🚒 Rule Violations (6)
migrations/000002_create_categories.up.sql:2:2: warning: prefer-identity
2 | create table categories (
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | name varchar(128) not null,
6 | type category_type not null
7 | );
note: Serial types have confusing behaviors that make schema management difficult.
help: Use identity columns instead for more features and better usability.
migrations/000002_create_categories.up.sql:2:2: warning: prefer-robust-stmts
2 | create table categories (
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | name varchar(128) not null,
6 | type category_type not null
7 | );
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000002_create_categories.up.sql:2:2: warning: prefer-text-field
2 | create table categories (
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | name varchar(128) not null,
6 | type category_type not null
7 | );
note: Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock.
help: Use a text field with a check constraint.
migrations/000002_create_categories.up.sql:2:2: warning: prefer-text-field
2 | create table categories (
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | name varchar(128) not null,
6 | type category_type not null
7 | );
note: Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock.
help: Use a text field with a check constraint.
migrations/000002_create_categories.up.sql:9:2: warning: prefer-robust-stmts
9 | create unique index categories_unique_idx on categories(user_id, type, name);
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000002_create_categories.up.sql:9:2: warning: require-concurrent-index-creation
9 | create unique index categories_unique_idx on categories(user_id, type, name);
note: Creating an index blocks writes.
help: Create the index CONCURRENTLY.
migrations/000003_create_entries.down.sql
drop index entries_idx;
drop table entries;
drop type entry_type;
🚒 Rule Violations (5)
migrations/000003_create_entries.down.sql:1:0: warning: prefer-robust-stmts
1 | drop index entries_idx;
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000003_create_entries.down.sql:1:0: warning: require-concurrent-index-deletion
1 | drop index entries_idx;
note: Deleting an index blocks selects, inserts, updates, and deletes on the index's table.
help: Delete the index CONCURRENTLY.
migrations/000003_create_entries.down.sql:2:1: warning: ban-drop-table
2 | drop table entries;
note: Dropping a table may break existing clients.
migrations/000003_create_entries.down.sql:2:1: warning: prefer-robust-stmts
2 | drop table entries;
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000003_create_entries.down.sql:3:1: warning: prefer-robust-stmts
3 | drop type entry_type;
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000003_create_entries.up.sql
create type entry_type as enum ('income', 'expense');
create table entries(
id bigserial primary key,
user_id varchar(128) not null,
category_id bigint not null,
amount double precision not null,
date timestamp not null,
description text not null,
type entry_type not null
);
create index entries_idx on entries(user_id, type);
insert into entries(user_id, category_id, amount, date, description, type)
values ('testusername111', '1', '120000.0', '2023-06-10', 'june salary', 'income');
insert into entries(user_id, category_id, amount, date, description, type)
values ('testusername111', '1', '5500.0', '2023-06-10', 'bonus', 'income');
insert into entries(user_id, category_id, amount, date, description, type)
values ('testusername111', '3', '453.19', '2023-06-08', 'BREAD', 'expense');
insert into entries(user_id, category_id, amount, date, description, type)
values ('testusername111', '3', '850.2', '2023-06-09', 'milk and eggs', 'expense');
insert into entries(user_id, category_id, amount, date, description, type)
values ('testusername111', '4', '600.0', '2023-06-09', 'cinema', 'expense');
🚒 Rule Violations (6)
migrations/000003_create_entries.up.sql:2:2: warning: prefer-identity
2 | create table entries(
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | category_id bigint not null,
6 | amount double precision not null,
7 | date timestamp not null,
8 | description text not null,
9 | type entry_type not null
10 | );
note: Serial types have confusing behaviors that make schema management difficult.
help: Use identity columns instead for more features and better usability.
migrations/000003_create_entries.up.sql:2:2: warning: prefer-robust-stmts
2 | create table entries(
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | category_id bigint not null,
6 | amount double precision not null,
7 | date timestamp not null,
8 | description text not null,
9 | type entry_type not null
10 | );
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000003_create_entries.up.sql:2:2: warning: prefer-text-field
2 | create table entries(
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | category_id bigint not null,
6 | amount double precision not null,
7 | date timestamp not null,
8 | description text not null,
9 | type entry_type not null
10 | );
note: Changing the size of a varchar field requires an ACCESS EXCLUSIVE lock.
help: Use a text field with a check constraint.
migrations/000003_create_entries.up.sql:2:2: warning: prefer-timestamptz
2 | create table entries(
3 | id bigserial primary key,
4 | user_id varchar(128) not null,
5 | category_id bigint not null,
6 | amount double precision not null,
7 | date timestamp not null,
8 | description text not null,
9 | type entry_type not null
10 | );
note: A timestamp field without a timezone can lead to data loss, depending on your database session timezone.
help: Use timestamptz instead of timestamp for your column type.
migrations/000003_create_entries.up.sql:12:2: warning: prefer-robust-stmts
12 | create index entries_idx on entries(user_id, type);
help: Consider wrapping in a transaction or adding a IF NOT EXISTS clause if the statement supports it.
migrations/000003_create_entries.up.sql:12:2: warning: require-concurrent-index-creation
12 | create index entries_idx on entries(user_id, type);
note: Creating an index blocks writes.
help: Create the index CONCURRENTLY.
Squawk Report
🚒 24 violations across 6 file(s)
migrations/000001_create_users.down.sql
🚒 Rule Violations (1)
migrations/000001_create_users.up.sql
🚒 Rule Violations (1)
migrations/000002_create_categories.down.sql
🚒 Rule Violations (5)
migrations/000002_create_categories.up.sql
🚒 Rule Violations (6)
migrations/000003_create_entries.down.sql
🚒 Rule Violations (5)
migrations/000003_create_entries.up.sql
🚒 Rule Violations (6)
📚 More info on rules
⚡️ Powered by
Squawk
(0.24.0), a linter for PostgreSQL, focused on migrations