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

Inherited tables do not get updating after adding column to parent table #3024

Open
eberkund opened this issue Nov 29, 2023 · 2 comments · May be fixed by #3354
Open

Inherited tables do not get updating after adding column to parent table #3024

eberkund opened this issue Nov 29, 2023 · 2 comments · May be fixed by #3354
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@eberkund
Copy link

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

@eberkund eberkund added bug Something isn't working triage New issues that hasn't been reviewed labels Nov 29, 2023
@dbhoot
Copy link

dbhoot commented Mar 19, 2024

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

@dbhoot
Copy link

dbhoot commented Mar 28, 2024

@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.

@dbhoot dbhoot linked a pull request Apr 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants