Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for name/up.sql and name/down.sql migrations #3771

Open
SamWhited opened this issue Jan 3, 2025 · 1 comment
Open
Labels
📚 postgresql documentation Improvements or additions to documentation enhancement New feature or request

Comments

@SamWhited
Copy link

SamWhited commented Jan 3, 2025

What do you want to change?

In two different projects I'm using two different migration systems that both keep migrations in separate directories that are walked in lexical order with up.sql and down.sql files in those directories. For example, the first migration might be: migrations/01_init/up.sql and migrations/01_init/down.sql.

When I run sqlc it complains that the schema or tables or what not don't exist, presumably because it's not actually picking up the migration files when I set schema: migrations/ (I was unable to find any way to verify that this is actually what's going on, but the documentation doesn't mention this type of migration).

It would be nice if sqlc could support finding migrations in up/down files in individual directories. Thanks!

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

sqlc.yaml: version: "2" sql: - engine: "postgresql" queries: "query.sql" schema: "migrations/" gen: go: package: "store" sql_package: "pgx/v5" out: "internal/store"

sqlc version: v1.27.0

@SamWhited SamWhited added the enhancement New feature or request label Jan 3, 2025
@SamWhited
Copy link
Author

SamWhited commented Jan 3, 2025

After posting this it occurred to me to try setting schema: "migrations/*/up.sql, which appears to work, but I don't see this documented anywhere that wildcards and multiple files are supported. Maybe this issue could be changed to a documentation issue and an example of this could be added to the page on migrations:

https://docs.sqlc.dev/en/v1.19.0/howto/ddl.html

@kyleconroy kyleconroy added the documentation Improvements or additions to documentation label Jan 9, 2025
@kyleconroy kyleconroy changed the title Support name/up.sql and name/down.sql migrations Update documentation for name/up.sql and name/down.sql migrations Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 postgresql documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants