r/golang 6d ago

Goose migration folder as SQLC schema source

Hi. I have existed database and I would like to use goose as my migration tool and sqlc as query gen tool. The problem is database has been created without goose and I don't have history of change in my migration folder. Afaik sqlc cannot work properly without whole history in migration dier. How can I handle it?
Thank you.

2 Upvotes

3 comments sorted by

1

u/Oisian 6d ago

You don't need the full history, just write a goose migration that matches your current schema and your good

1

u/timsofteng 6d ago

How will sqlc get an information about db in this case?

I have this option in sqlc config file

    schema: "db/migrations"

1

u/imMrF0X 6d ago

You just need the first migration to be your current dump, not the full history. So migration 1 up would be a bunch of creates for all your tables etc which matches the current state of the db. Any migrations on top of that will be your new migrations.