all edit_* have CUID random alphanumeric unique id with 12 characters length. automatically created on INSERT and not touched on update. but can be udpated manually on UPDATE command. on INSERT cuid is ALWAYS overwritten with auto create Add CSS loading style sheet
18 lines
395 B
PL/PgSQL
Executable File
18 lines
395 B
PL/PgSQL
Executable File
-- create random string with length X
|
|
|
|
CREATE FUNCTION random_string(randomLength int)
|
|
RETURNS text AS $$
|
|
SELECT array_to_string(
|
|
ARRAY(
|
|
SELECT substring(
|
|
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
|
|
trunc(random() * 62)::int + 1,
|
|
1
|
|
)
|
|
FROM generate_series(1, randomLength) AS gs(x)
|
|
),
|
|
''
|
|
)
|
|
$$ LANGUAGE SQL
|
|
RETURNS NULL ON NULL INPUT
|
|
VOLATILE; -- LEAKPROOF; |