Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ glob = "0.3.1"
insta = "1.39.0"
jsonwebtoken = "8.1.1"
lazy_static = "1.5.0"
libpg_query-sys = { git = "https://github.com/chdsbd/libpg_query-sys.git", rev = "ac223c7b197459d657d166449ccf99883f23bbcb" }
log = "0.4.25"
reqwest = { version = "0.9.18", features = ["default-tls-vendored"]}
serde = { version = "1.0.215", features = ["derive"] }
Expand Down Expand Up @@ -48,8 +47,6 @@ convert_case = "0.7.1"
clap = { version = "4.5.8", features = ["derive"] }

# local
squawk-parser = { version = "0.0.0", path = "./crates/parser" }
squawk-linter = { version = "0.0.0", path = "./crates/linter" }
squawk-github = { version = "0.0.0", path = "./crates/github" }
squawk_lexer = { version = "0.0.0", path = "./crates/squawk_lexer" }
squawk_parser = { version = "0.0.0", path = "./crates/squawk_parser" }
Expand Down
34 changes: 23 additions & 11 deletions docs/docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ slug: /

## Install

Note: due to `squawk`'s dependency on
[`libpg_query`](https://github.com/lfittl/libpg_query/issues/44), `squawk`
only supports Linux and macOS

```shell
npm install -g squawk-cli

# or install binaries directly via the releases page
https://github.com/sbdchd/squawk/releases
```

**NOTE**: You can also try Squawk in the browser via the [Squawk Playground](https://play.squawkhq.com)!

## Usage

<details><summary><code>example-migration.sql</code></summary>
Expand All @@ -40,20 +38,34 @@ squawk example-migration.sql

<br/>

```shell
```
❯ squawk example-migration.sql
example-migration.sql:2:1: warning: disallowed-unique-constraint

2 | ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name);

note: Adding a UNIQUE constraint requires an ACCESS EXCLUSIVE lock which blocks reads.
help: Create an index CONCURRENTLY and create the constraint using the index.
warning[constraint-missing-not-valid]: By default new constraints require a table scan and block writes to the table while that scan occurs.
--> example-migration.sql:2:24
|
2 | ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
warning[disallowed-unique-constraint]: Adding a `UNIQUE` constraint requires an `ACCESS EXCLUSIVE` lock which blocks reads and writes to the table while the index is built.
--> example-migration.sql:2:28
|
2 | ALTER TABLE table_name ADD CONSTRAINT field_name_constraint UNIQUE (field_name);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: Create an index CONCURRENTLY and create the constraint using the index.

Find detailed examples and solutions for each rule at https://squawkhq.com/docs/rules
Found 2 issues in 1 file (checked 1 source file)
```

See ["Running Migrations"](./safe_migrations.md#safety-requirements) for information about safely applying migrations in Postgres.

The [CLI docs](./cli.md) have more information about the `squawk` CLI tool and the [GitHub Integration docs](./github_app.md) outline configuring Squawk to work with GitHub pull requests.

## Playground

You can also lint your SQL in the [Squawk Playground](https://play.squawkhq.com) using the WASM compiled version!

## GitHub Action

```yml
Expand Down
11 changes: 0 additions & 11 deletions docs/docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,3 @@ title: Troubleshooting
---

If you encounter an issue using Squawk that can't be resolved with these docs, please [open an issue](https://github.com/sbdchd/squawk/issues/new).


## common error messages

### postgres failed to parse query

Squawk was unable to parse the query using the PostgreSQL parser.

Usually the provided statement contains an error and isn't a valid Postgres statement.

Squawk uses the [libpg_query-sys](https://github.com/tdbgamer/libpg_query-sys) Rust bindings to [libpg_query](https://github.com/pganalyze/libpg_query) to parse Postgres queries using the Postgres parser.
5 changes: 5 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ module.exports = {
label: "Rules",
position: "left",
},
{
href: "https://play.squawkhq.com",
label: "Playground",
position: "right",
},
{
to: "docs/",
label: "Quick Start",
Expand Down
2 changes: 0 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
Security
]);

LIBPG_QUERY_PATH = final.libpg_query;

meta = with lib; {
description = "Linter for PostgreSQL, focused on migrations";
homepage = "https://github.com/sbdchd/squawk";
Expand Down
Loading