-
Notifications
You must be signed in to change notification settings - Fork 29
Description
I'm using an external database that has several schemas and each script deletes one or more tables in the previous script.
Schema 1 - Public
--
-- pgschema database dump
--
-- Dumped from database version PostgreSQL 17.7
-- Dumped by pgschema version 1.7.1
CREATE TABLE IF NOT EXISTS geotab_database (
name citext NOT NULL,
active boolean DEFAULT true NOT NULL,
id uuid DEFAULT uuid_generate_v1mc(),
api_password text,
CONSTRAINT geotab_database_pk PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS geotab_database_active_idx ON geotab_database (active);
CREATE INDEX IF NOT EXISTS geotab_database_name_idx ON geotab_database (name);
CREATE INDEX IF NOT EXISTS geotab_database_name_idx1 ON geotab_database USING gin (lower(name::text) gin_trgm_ops);
CREATE TABLE IF NOT EXISTS service_state (
id uuid DEFAULT uuid_generate_v1mc(),
service_name citext NOT NULL,
last_run timestamptz,
start_time time,
interval text NOT NULL,
enabled boolean NOT NULL,
last_status text,
CONSTRAINT service_state_pkey PRIMARY KEY (id)
);Schema 2 - vehicle
--
-- pgschema database dump
--
-- Dumped from database version PostgreSQL 17.7
-- Dumped by pgschema version 1.7.1
CREATE TABLE IF NOT EXISTS vehicle_config (
geotab_database_name public.citext NOT NULL,
vehicle_group_id text,
report_last_sent timestamptz,
enabled boolean DEFAULT false NOT NULL,
vehicle_group_name public.citext,
password text NOT NULL,
id uuid DEFAULT public.uuid_generate_v1mc(),
CONSTRAINT vehicle_config_pk PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS vehicle_config_enabled_idx ON vehicle_config (enabled);
CREATE INDEX IF NOT EXISTS vehicle_config_geotab_database_name_idx ON vehicle_config (geotab_database_name);
CREATE INDEX IF NOT EXISTS vehicle_config_report_last_sent_idx ON vehicle_config (report_last_sent);
CREATE INDEX IF NOT EXISTS vehicle_config_vehicle_group_name_idx ON vehicle_config (vehicle_group_name);I do the dump from the external database and get the SQL files. I thought the tables from other schemas had the schema prefix on the table. Notice that the vehicle schema just says "vehicle_config" and not "vehicle.vehicle_config".
I dump 3 non-public schemas and none have and schema references anymore.
I run Apply on the public.sql file and both tables get created. Sweet.
I run Apply on the vehicle.sql file and it deleted the table created in public.sql and created vehicle_config in the public schema instead of the vehicle schema.
Example dump command.
dump --host host.docker.internal --db support --user postgres --port 5432 --no-comments --schema public > s_public.sql
Example apply command.
apply --host host.docker.internal --db support --user postgres --port 5433 --plan-host host.docker.internal --plan-db support --plan-user postgres --plan-port 5432 --file s_public.sql --auto-approve