Inherited tables do not get updating after adding column to parent table
Version
1.24.0
What happened?
I created an inherited table in Postgres and everything worked as expected.
Then I decided I needed to add a column to the parent table, but when I did this the models for the inherited tables did not get updated with the new column.
Relevant log output
No response
Database schema
CREATE TABLE traffic_sensors(
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
serial_number varchar(16) NOT NULL,
sampling_rate interval NOT NULL,
base_station_serial varchar NOT NULL
);
CREATE TABLE traffic_sensors_random(
max integer NOT NULL,
min integer NOT NULL
)
INHERITS (
traffic_sensors
);
ALTER TABLE traffic_sensors
ADD sensor_type varchar;
SQL queries
SELECT
*
FROM
traffic_sensors_random;
Configuration
version: "2"
sql:
- engine: "postgresql"
queries: "sql/queries"
schema: "sql/migrations"
gen:
go:
package: "persist"
out: "persist"
emit_interface: true
overrides:
go:
overrides:
- db_type: "pg_catalog.interval"
engine: "postgresql"
go_type:
import: "github.com/jackc/pgtype"
type: "Interval"
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
I also have this problem. Reported it on discord.
Here you can see an example. The reads on the table look fine
https://play.sqlc.dev/p/43d68dfffc64b904b300282294e356055252994105047bab8f112481c1411f3e
But you cannot write to the new columns
https://play.sqlc.dev/p/5481fc05f363aae6e9556daa7d4033b3c492ae0aff2bbcff96ef1a30da37e133
@kyleconroy @andrewmbenton is one of you by chance available to take a look at this?
I'm also willing to dig in and submit a PR if neither of you are available / no one from the core maintainers is available.
It seems that the maintainers are inactive or not interested in fixing this issue, thats a bummer. I actually liked this tool.
It seems that the maintainers are inactive or not interested in fixing this issue, thats a bummer. I actually liked this tool.
@ShadowBr0ther Fwiw, inheritance is generally discouraged (i didn't know that when i used it). I have a workaround depending on your setup.
How are you managing your schema?