dfau
06/22/2021, 2:50 PMid String @id @db.Uuid @default(dbgenerated("gen_random_uuid()"))
is there a way to use a function made by me instead of postgresql default one? For reference, my use case would be something like
orderNumber BigInt @default(dbgenerated("random_between(99999, 1000000)"))
Ryan
06/22/2021, 2:52 PMdfau
06/22/2021, 3:18 PMCREATE OR REPLACE FUNCTION random_between(low BIGINT ,high BIGINT)
RETURNS BIGINT AS
$$
BEGIN
RETURN floor(random()* (high-low + 1) + low);
END;
$$ language 'plpgsql' STRICT;
is that the way to do it to reference it in the schema?dfau
06/22/2021, 4:44 PMRyan
06/23/2021, 5:32 AM