Skip to content

Commit 7bb2352

Browse files
authored
docs: warn about golang-migrate file order (#1302)
* docs: warn about golang-migrate file order
1 parent 4bbe1ca commit 7bb2352

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/howto/ddl.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ type Comment struct {
9898

9999
### golang-migrate
100100

101+
Warning: [golang-migrate specifies](https://github.com/golang-migrate/migrate/blob/master/MIGRATIONS.md#migration-filename-format) that the version number in the migration file name is to be interpreted numerically. However, sqlc executes the migration files in **lexicographic** order. If you choose to simply enumerate your migration versions, make sure to prepend enough zeros to the version number to avoid any unexpected behavior.
102+
103+
Probably doesn't work as intended:
104+
```
105+
1_initial.up.sql
106+
...
107+
9_foo.up.sql
108+
# this migration file will be executed BEFORE 9_foo
109+
10_bar.up.sql
110+
```
111+
Works as was probably intended:
112+
```
113+
001_initial.up.sql
114+
...
115+
009_foo.up.sql
116+
010_bar.up.sql
117+
```
118+
101119
In `20060102.up.sql`:
102120

103121
```sql

0 commit comments

Comments
 (0)