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
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# squawk [![npm](https://img.shields.io/npm/v/squawk-cli)](https://www.npmjs.com/package/squawk-cli)

> linter for Postgres migrations
> Linter for Postgres migrations & SQL

[quick start](https://squawkhq.com/docs/) | [rules documentation](https://squawkhq.com/docs/rules) | [github action](https://github.com/sbdchd/squawk-action) | [diy github integration](https://squawkhq.com/docs/github_app)
[Quick Start](https://squawkhq.com/docs/) | [Playground](https://play.squawkhq.com) | [Rules Documentation](https://squawkhq.com/docs/rules) | [GitHub Action](https://github.com/sbdchd/squawk-action) | [DIY GitHub Integration](https://squawkhq.com/docs/github_app)

## Why?

Prevent unexpected downtime caused by database migrations and encourage best
practices around Postgres schemas and SQL.

Also it seemed like a nice project to spend more time with Rust.

## Install

```shell
Expand Down Expand Up @@ -179,11 +177,11 @@ repos:

Note the `files` parameter as it specifies the location of the files to be linted.

## prior art
## Prior Art

- <https://github.com/erik/squabble>

### related tools
### Related Tools

- <https://github.com/yandex/zero-downtime-migrations>
- <https://github.com/tbicr/django-pg-zero-downtime-migrations>
Expand All @@ -195,7 +193,7 @@ Note the `files` parameter as it specifies the location of the files to be linte
- <https://github.com/supabase-community/postgres-language-server>
- <https://github.com/premium-minds/sonar-postgres-plugin>

## related blog posts / SE Posts / PG Docs
## Related Blog Posts / SE Posts / PG Docs

- <https://www.braintreepayments.com/blog/safe-operations-for-high-volume-postgresql/>
- <https://gocardless.com/blog/zero-downtime-postgres-migrations-the-hard-parts/>
Expand All @@ -207,7 +205,7 @@ Note the `files` parameter as it specifies the location of the files to be linte
- <https://benchling.engineering/move-fast-and-migrate-things-how-we-automated-migrations-in-postgres-d60aba0fc3d4>
- <https://medium.com/paypal-tech/postgresql-at-scale-database-schema-changes-without-downtime-20d3749ed680>

## dev
## Dev

```shell
cargo install
Expand All @@ -228,15 +226,15 @@ $ nix develop
[nix-shell]$ ./s/fmt
```

### adding a new rule
### Adding a New Rule

When adding a new rule, the `s/new-rule` script will create stubs for your rule in Rust and in Documentation site.

```bash
s/new-rule 'prefer big serial'
```

### releasing a new version
### Releasing a New Version

1. Update the `CHANGELOG.md`

Expand All @@ -253,17 +251,12 @@ s/new-rule 'prefer big serial'

Use the text and version from the `CHANGELOG.md`

### algolia
### Algolia

The squawkhq.com Algolia index can be found on [the crawler website](https://crawler.algolia.com/admin/crawlers/9bf0dffb-bc5a-4d46-9b8d-2f1197285213/overview). Algolia reindexes the site every day at 5:30 (UTC).

## how it works

squawk wraps calls to [libpg_query-sys](https://github.com/tdbgamer/libpg_query-sys) in a safe
interface and parses the JSON into easier to work with structures.
libpg_query-sys in turn uses [bindgen](https://rust-lang.github.io/rust-bindgen/) to bind to
[libpg_query](https://github.com/lfittl/libpg_query), which itself wraps Postgres' SQL
parser in a bit of C code that outputs the parsed AST into a JSON string.
## How it Works

Squawk then runs the rule functions over the parsed AST, gathers and pretty
prints the rule violations.
Squawk uses its parser (based on rust-analyzer's parser) to create a CST. The
linters then use an AST layered on top of the CST to navigate and record
warnings, which are then pretty printed!
4 changes: 3 additions & 1 deletion docs/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ function Home() {
<header className={clsx("hero hero--primary", styles.heroBanner)}>
<div className="container">
<h1 className="hero__title">Squawk</h1>
<p className="hero__subtitle">A linter for Postgres migrations</p>
<p className="hero__subtitle">
A linter for Postgres migrations & SQL
</p>
<div className={styles.buttons}>
<Link
className={clsx(
Expand Down
2 changes: 2 additions & 0 deletions playground/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# playground

> <https://play.squawkhq.com>

## dev

```shell
Expand Down
4 changes: 2 additions & 2 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "wasm-pack build --target web ../crates/wasm --out-dir ../../playground/src/pkg && vite build",
"deploy": "netlify deploy --prod",
"build": "wasm-pack build --target web ../crates/squawk_wasm --out-dir ../../playground/src/pkg && vite build",
"deploy": "netlify deploy --prod --dir dist",
"lint": "eslint .",
"preview": "vite preview"
},
Expand Down
Loading