我有两种类型的表:具有UUID主键的表和具有BIGINT主键的表。
我有一个特定的表,该表引用具有这两种类型的主键的表。
我不能使用CREATE CAST (character varying AS uuid) WITH INOUT AS IMPLICIT
,因为我不拥有character varying
或uuid
(heroku)。
例如,假设使用这些表:
CREATE TABLE public.changelogs (
id bigint NOT NULL,
record_type character varying NOT NULL,
-- record_id ??? NOT NULL,
event character varying NOT NULL,
actor_id uuid,
transitions jsonb,
object_changes jsonb DEFAULT '{}'::jsonb NOT NULL,
created_at timestamp without time zone NOT NULL,
group_id text NOT NULL
);
这两个表:
CREATE TABLE public.recipes (
id uuid DEFAULT public.gen_random_uuid() NOT NULL,
name text NOT NULL,
slug public.citext NOT NULL,
moderation_state public.citext NOT NULL,
description text NOT NULL,
author_id uuid NOT NULL,
ingredients text[] DEFAULT '{}'::text[] NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
instructions character varying[] DEFAULT '{}'::character varying[] NOT NULL,
cook_time integer NOT NULL,
prep_time integer NOT NULL
);
CREATE TABLE public.allergies (
id bigint NOT NULL,
name character varying NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);