From 2c87473bc46dd61f0950589ee657ef851cd45e17 Mon Sep 17 00:00:00 2001 From: remLse <54984957+remLse@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:50:23 +0100 Subject: [PATCH 1/2] docs: warn about golang-migrate file order --- docs/howto/ddl.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/howto/ddl.md b/docs/howto/ddl.md index 936842312d..5f63f15a84 100644 --- a/docs/howto/ddl.md +++ b/docs/howto/ddl.md @@ -98,6 +98,24 @@ type Comment struct { ### golang-migrate +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 enumert your migration versions, make sure to prepend enough zeros to the version number to avoid any unexpected behavior. + +Probably doesn't work as intended: +``` +1_initial.up.sql +... +9_foo.up.sql +# this migration file will be executed BEFORE 9_foo +10_bar.up.sql +``` +Works as was probably intended: +``` +001_initial.up.sql +... +009_foo.up.sql +010_bar.up.sql +``` + In `20060102.up.sql`: ```sql From aae63b0707a947758da4f7b54513da28d53a2846 Mon Sep 17 00:00:00 2001 From: remLse <54984957+remLse@users.noreply.github.com> Date: Mon, 22 Nov 2021 18:27:14 +0100 Subject: [PATCH 2/2] docs: fix typo --- docs/howto/ddl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/howto/ddl.md b/docs/howto/ddl.md index 5f63f15a84..e2f36788b9 100644 --- a/docs/howto/ddl.md +++ b/docs/howto/ddl.md @@ -98,7 +98,7 @@ type Comment struct { ### golang-migrate -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 enumert your migration versions, make sure to prepend enough zeros to the version number to avoid any unexpected behavior. +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. Probably doesn't work as intended: ```