types created from extensions cause an error in planning
Given the following database definition:
create extension hstore;
create table some_table(
id serial primary key,
some_value hstore
);
pgschema dump outputs:
--
-- pgschema database dump
--
-- Dumped from database version PostgreSQL 17.0
-- Dumped by pgschema version 1.4.0
--
-- Name: some_table; Type: TABLE; Schema: -; Owner: -
--
CREATE TABLE IF NOT EXISTS some_table (
id SERIAL,
some_value hstore,
CONSTRAINT some_table_pkey PRIMARY KEY (id)
);
However when you attempt to plan on this dumped schema you get the following error:
Error: failed to apply desired state to embedded PostgreSQL: failed to apply schema SQL: ERROR: type "hstore" does not exist (SQLSTATE 42704)
the dump file would probably have to include CREATE EXTENSION statements.
pgschema operates on schema level.
CREATE EXTENSION is a database level statement and is not supported https://www.pgschema.com/syntax/unsupported#database-level-commands
User needs to manage the lifecycle of extensions outside of pgschema
i agree that pgschema shouldn't manage extensions, but in order to plan using an internal embedded database the extension will have to be installed on that embedded database as it can provide dependencies like types or even tables or views.
The embedded pg doesn't support extension. I need to think of different plan.
https://github.com/fergusstrange/embedded-postgres/issues/21 https://github.com/zonkyio/embedded-postgres-binaries/issues/6
sorry for being such a challenge lol...i do really like the tool but it's been challenging to get to a point where we can use it against our obviously very complex database
if it helps i would not be opposed to allowing pgschema to own a database on my postgres server to load the target schema into. i imagine that is probably heavier than you'd prefer but it would solve the extension issue at least.
@whoward if you mean something similar to Prisma shadow DB https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database
Yes, that's an option we can resort to. I am still researching
Please use external plan db: https://www.pgschema.com/cli/plan-db. Available in 1.4.1
very nice! i checked and this works well. Thanks!