Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

migrations #1708

Unanswered
bluebrown asked this question in Q&A
Jun 25, 2022 · 1 comment
Discussion options

Hi, I am confused about migrations. I read in the docs that sqlc executes migration:

However, sqlc executes the migration files in lexicographic order.

How can I do this? It's not part of the getting started guide, and It's not further explained. The generated code doesnt contain migration functions either.

You must be logged in to vote

Replies: 1 comment

Comment options

I finally figured it out!

Your schema file needs to be in your migrations folder. Eg for Goose:

sql/migrator
├── migrations
│  ├── 0_schema.sql
│  ├── 20230125153147_student_tooltop.sql
│  ├── 20230125155123_remove_tern_table.sql
 ...

Then in your sqlc.yaml you specify the migrations directory instead of the schema file:

version: "2"
sql:
 - schema: "sql/migrator/migrations"
 queries: "sql/queries"
 engine: "postgresql"
...

I agree that the docs need to be updated, as this wasn't at all obvious to me for months.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /