Version
1.29.0
What happened?
SQLC cannot handle cross-schema inheritance.
migration file, valid in postgres
CREATE SCHEMA schema_one;
CREATE SCHEMA schema_two;
CREATE TABLE schema_one.parent (
foo TEXT
);
CREATE TABLE schema_two.child (
bar TEXT
) INHERITS (schema_one.parent);
command:
sqlc generate
output:
000001_some_migration.up.sql:1:1: relation "parent" does not exist
Looking at the PR which adds inheritance it seems like the problem is that the schema of the CREATE clause is used to fetched the inherited table. I.e. there is an assumption that the tables are in the same schema. Same is done in latest version; see this line.
Fix, I would assume, would be to get the schema for the table referred to in the INHERITS part. Then use inherited_schema.getTable(inheritTable).
Relevant log output
000001_some_migration.up.sql:1:1: relation "parent" does not exist
Database schema
CREATE SCHEMA schema_one;
CREATE SCHEMA schema_two;
CREATE TABLE schema_one.parent (
foo TEXT
);
CREATE TABLE schema_two.child (
bar TEXT
) INHERITS (schema_one.parent);
SQL queries
Configuration
Playground URL
No response
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Version
1.29.0
What happened?
SQLC cannot handle cross-schema inheritance.
migration file, valid in postgres
command:
sqlc generateoutput:
Looking at the PR which adds inheritance it seems like the problem is that the schema of the
CREATEclause is used to fetched the inherited table. I.e. there is an assumption that the tables are in the same schema. Same is done in latest version; see this line.Fix, I would assume, would be to get the schema for the table referred to in the
INHERITSpart. Then useinherited_schema.getTable(inheritTable).Relevant log output
000001_some_migration.up.sql:1:1: relation "parent" does not existDatabase schema
SQL queries
Configuration
Playground URL
No response
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go