Skip to content

Commit 45b477d

Browse files
authored
docs: add short guide for migrations (#220)
1 parent c77e7cf commit 45b477d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

docs/checking_migrations.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Linting Migrations
2+
3+
Postgres Language Tools comes with a `check` command that can be integrated into your development workflow to catch problematic schema changes and encourage best practices.
4+
5+
To run it, simply point at your migrations directory.
6+
7+
```sh
8+
pglt check supabase/migrations
9+
```
10+
11+
When you are setting it up in an existing project, you might want to ignore all migrations that are already applied. To do so, add `migrations_dir` and `after` to your `pglt.toml` file
12+
13+
14+
```toml
15+
[migrations]
16+
migrations_dir = "supabase/migrations"
17+
after = 1740868021
18+
```
19+
20+
Alternatively, pass them directly.
21+
22+
```
23+
pglt check supabase/migrations --migrations-dir="supabase/migrations" --after=1740868021
24+
```
25+
26+
This will only check migrations after the specified timestamp.
27+
28+
For pre-commit hooks and when working locally, use `--staged` to only lint files that have been staged. In CI environments, you most likely want to use `--changed` to only lint files that have been changed compared to your `defaultBranch` configuration. If `defaultBranch` is not set in your `pglt.toml`, use `--since=REF` to specify the base branch to compare against.
29+

docs/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ Make sure to point the database connection settings at your local development da
6969

7070
## Usage
7171

72-
You can check SQL files using the `check` command:
72+
You can use the language tools either via CLI or a Language Server.
73+
74+
The CLI exposes a simple `check` command that will run all checks on the given files or paths.
7375

7476
```sh
7577
pglt check myfile.sql

0 commit comments

Comments
 (0)