Skip to content

Functions that accept an array of row types are not preserved in the migration #3587

@awgneo

Description

@awgneo

Hello,

I have this table in Postgres 17 using SQL to define my input file:

CREATE TABLE agreego.relation (
  id uuid NOT NULL,
  "type" agreego.relation_type NOT NULL,
  "constraint" text NOT NULL,
  source_type text NOT NULL,
  source_columns text[] NOT NULL DEFAULT '{}',
  destination_type text NOT NULL,
  destination_columns text[] NOT NULL DEFAULT '{}',
  prefix text NULL,
  CONSTRAINT pk_relation PRIMARY KEY (id),
  CONSTRAINT u_relation UNIQUE (id, "type"),
  CONSTRAINT u_relation_constraint UNIQUE (source_type, destination_type, prefix)
);

And this function:

CREATE OR REPLACE FUNCTION agreego.reduce_entity_relations(
  relations agreego.relation[],
  "relative" JSONB,
  relation_name TEXT
) RETURNS agreego.relation AS $$

It takes an array of the automatically-generated Postgres table row type agreego.relation as relations.

After running atlas migrate diff, the migration file contains this function definition:

-- Create "reduce_entity_relations" function
CREATE FUNCTION "agreego"."reduce_entity_relations" ("relations" "agreego"."relation", "relative" jsonb, "relation_name" text) RETURNS "agreego"."relation" LANGUAGE plpgsql AS $$
DECLARE
  matching_relations agreego.relation[];
  matched_relation agreego.relation;
BEGIN

Notice how relations went from agreego.relation[] to agreego.relation, generating an improper function signature in the database.

Let me know if this is enough information to resolve the issue.

Cheers,
Alex Groleau
(Pro Member)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions