@@ -23,8 +23,8 @@ Each file should be:
23
23
When the Postgres container starts with no existing data, SuperStack will
24
24
automatically run migrations once.
25
25
26
- After the first ` docker compose up ` , migrations will only run if you
27
- manually apply them.
26
+ After the first startup , migrations will only run if you manually apply
27
+ them.
28
28
29
29
To apply your migrations, run:
30
30
@@ -35,21 +35,16 @@ bin/postgres migrate
35
35
This will:
36
36
37
37
1 . Run any migration files that haven’t been applied yet (in filename order)
38
- 2 . Record each successfully applied file in ` .applied_migrations `
38
+ 2 . Record each successfully applied file in ` .applied_migrations ` (this
39
+ file lives in the postgres data volume)
39
40
40
41
Already-applied scripts are skipped on subsequent runs.
41
42
42
- > 💡 ` bin/postgres ` is short for ` docker compose exec postgres `
43
+ > 💡 ` bin/postgres ` is a small script that basically aliases ` docker compose exec postgres `
43
44
44
- ## 🔁 Transactions
45
-
46
- Use ` BEGIN; ` and ` COMMIT; ` to wrap migration files when all included
47
- statements are transactional. This ensures that all changes are applied
48
- atomically.
49
-
50
- For example:
45
+ Here's an example migration script:
51
46
52
- ``` sql title="postgres/migrations/03 -create_table_example.sql"
47
+ ``` sql title="postgres/migrations/02 -create_table_example.sql"
53
48
begin ;
54
49
55
50
create table director (
@@ -66,13 +61,15 @@ create table movie (
66
61
commit ;
67
62
```
68
63
69
- > 💡 If your migration script only contains one statement, there's no need
70
- > to use a transaction, the statement will be auto-committed.
64
+ ## 🔁 Transactions
71
65
72
- Avoid wrapping non-transactional operations in a transaction — these will
73
- cause errors if used inside ` BEGIN ... COMMIT ` .
66
+ Use ` begin; ` and ` commit; ` to wrap statements in a transaction. This
67
+ ensures that all changes are applied atomically. Any statements outside of
68
+ transactions will be auto-committed.
74
69
75
- Examples of non-transactional statements include:
70
+ Avoid wrapping non-transactional operations in a transaction — these will
71
+ cause errors if used inside ` begin ... commit ` . Examples of
72
+ non-transactional statements include:
76
73
77
74
``` sql
78
75
CREATE EXTENSION
0 commit comments