@@ -32,11 +32,20 @@ To apply your migrations, run:
32
32
bin/postgres migrate
33
33
```
34
34
35
+ This command will:
36
+ Apply new migrations – runs any migration files (in filename order) that haven’t been applied yet.
37
+ Record applied migrations – logs each successfully applied migration in a .applied_migrations file so it won’t run again.
38
+ Persist migration history with your database – the .applied_migrations file lives inside the postgres_data Docker volume alongside the database files.
39
+ If the postgres_data volume is deleted or recreated, both the database and the migration history are reset, so migrations will run again from scratch.
40
+
35
41
This will:
36
42
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 ` (this
39
- file lives in the postgres data volume)
43
+ 1 . ** Apply new migrations,** in filename order.
44
+ 2 . ** Record applied migrations** in a file named ` .applied_migrations ` . This
45
+ plain-text file keeps a record of successfully applied migrations so they
46
+ aren't applied again next time. It lives in the same volume as the database
47
+ files, so when that volume is removed or recreated, the
48
+ ` .applied_migrations ` file goes with it and you start over.
40
49
41
50
Already-applied scripts are skipped on subsequent runs.
42
51
@@ -63,9 +72,9 @@ commit;
63
72
64
73
## 🔁 Transactions
65
74
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.
75
+ Use ` begin; ` and ` commit; ` to wrap statements in a transaction. This ensures
76
+ that all changes are applied atomically. Any statements outside of transactions
77
+ will be auto-committed.
69
78
70
79
Avoid wrapping non-transactional operations in a transaction — these will
71
80
cause errors if used inside ` begin ... commit ` . Examples of
0 commit comments