With Postgres native partitioning, can you add extra columns to a partition of the base table? Like:
CREATE TABLE item (
tenant_id bigint NOT NULL,
item_id bigint NOT NULL,
kind text NOT NULL CHECK ( kind IN ('product', 'ingredient') ),
PRIMARY KEY (tenant_id, item_id)
) PARTITION BY LIST (kind);
CREATE TABLE item_product PARTITION OF item (
extra_sku TEXT
) FOR VALUES IN ('product');
CREATE TABLE item_ingredient PARTITION OF item
FOR VALUES IN ('ingredient');
The CREATE TABLE
syntax doesn't seem to support adding columns on child tables, only adding constraints to existing columns, so I'm guessing it's not allowed.