Tons of changes here, all in the name of quickly getting to where I can create test compliance letters.
16 lines
454 B
PL/PgSQL
16 lines
454 B
PL/PgSQL
-- +goose Up
|
|
-- +goose StatementBegin
|
|
CREATE OR REPLACE FUNCTION generate_alphanumeric_code(code_length INTEGER DEFAULT 8)
|
|
RETURNS TEXT AS $$
|
|
DECLARE
|
|
chars TEXT := 'ABCDEFGHJKMNPQRSTUVWXYZ23456789';
|
|
result TEXT := '';
|
|
i INTEGER;
|
|
BEGIN
|
|
FOR i IN 1..code_length LOOP
|
|
result := result || substr(chars, floor(random() * length(chars) + 1)::INTEGER, 1);
|
|
END LOOP;
|
|
RETURN result;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
-- +goose StatementEnd
|