mirror of https://github.com/BRAVO68WEB/shx.git
19 lines
567 B
PL/PgSQL
19 lines
567 B
PL/PgSQL
-- Could not auto-generate a down migration.
|
|
-- Please write an appropriate down migration for the SQL below:
|
|
-- create function unique_random(len int, _table text, _col text) returns text as $$
|
|
-- declare
|
|
-- result text;
|
|
-- numrows int;
|
|
-- begin
|
|
-- result = random_string(len);
|
|
-- loop
|
|
-- execute format('select 1 from %I where %I = %L', _table, _col, result);
|
|
-- get diagnostics numrows = row_count;
|
|
-- if numrows = 0 then
|
|
-- return result;
|
|
-- end if;
|
|
-- result = random_string(len);
|
|
-- end loop;
|
|
-- end;
|
|
-- $$ language plpgsql;
|