Closed
Description
Version
1.19.1
What happened?
Hey :)
I am encountering a simmilar issue as mentioned in #1644. I am trying to migrate from gorm
to sqlc
and therefore need the old tables renamed to not interfere with the newly created schema. If the old tables do not exsist the renaming should be skipped obviously. I am using tern
as my migration setup.
The migration looks like this:
BEGIN;
ALTER TABLE IF EXISTS foo RENAME TO deprecated_foo;
ALTER TABLE IF EXISTS bar RENAME TO deprecated_bar;
COMMIT;
When running sqlc generate
get this log output:
pkg/db/migrations/002_deprecate_legacy_schema.sql:1:1: relation "foo" does not exist
pkg/db/migrations/002_deprecate_legacy_schema.sql:1:1: relation "bar" does not exist
Expectation
I expect, that the generate process would respect the IF EXISTS
fragement, and not throw an error.
Relevant log output
No response
Database schema
No response
SQL queries
BEGIN;
ALTER TABLE IF EXISTS foo RENAME TO deprecated_foo;
ALTER TABLE IF EXISTS bar RENAME TO deprecated_bar;
COMMIT;
Configuration
version: "2"
sql:
- engine: "postgresql"
queries: "/pkg/db/query"
schema: "/pkg/db/migrations"
gen:
go:
package: "db"
sql_package: "pgx/v5"
out: "pkg/db"
Playground URL
https://play.sqlc.dev/p/c9232e411dbc9a7b6fd84d5a631a186c0e6054bbfc5ac0b07b22527f4e48ccb4
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go