Skip to content

Table dependency not resolving #401

@microfauna

Description

@microfauna

Hello, I have the following:

src/public/functions/accept_extracted_recipes.sql:

CREATE OR REPLACE FUNCTION accept_extracted_recipes(
    recipe_ids uuid[]
)
RETURNS SETOF recipe_user_save
LANGUAGE plpgsql
VOLATILE
AS $$
BEGIN
  -- ... function content omitted
END;
$$;

and

src/public/tables/recipe_user_save.sql:

CREATE TABLE IF NOT EXISTS recipe_user_save (
    recipe_id uuid,
    user_id uuid DEFAULT auth.uid(),
    CONSTRAINT recipe_user_save_pkey PRIMARY KEY (recipe_id, user_id),
    CONSTRAINT recipe_user_save_recipe_id_fkey FOREIGN KEY (recipe_id) REFERENCES recipe (id) ON DELETE CASCADE
);

When I run the following:

../pgschema/pgschema plan \
  --host localhost \
  --user postgres \
  --db postgres \
  --password postgres \
  --port 54322 \
  --plan-host localhost \
  --plan-db postgres \
  --plan-user postgres \
  --plan-password postgres \
  --plan-port 54322 \
  --file src/public/main.sql \
  --output-human \
  --output-json plan.json \
  --output-sql plan.sql  --schema public

I get:

Error: failed to apply desired state: failed to apply schema SQL to temporary schema pgschema_tmp_20260414_142719_c0de6c1b: ERROR: type "recipe_user_save" does not exist (SQLSTATE 42704)

Even when I empty the function - isolating the problem to RETURNS SETOF recipe_user_save.
I've tried marking it explicitly as RETURNS SETOF public.recipe_user_save and the table defintion with public but nothing changes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions