Files
query-orchestration/internal/database/migrations/00000000000001_extensions.up.sql
T
Michael McGuinness edc50c7510 Merged in feature/part (pull request #113)
Size Import Parts

* parts

* think

* workingpart

* textout
2025-04-08 12:44:09 +00:00

38 lines
794 B
PL/PgSQL

CREATE EXTENSION IF NOT EXISTS "pgcrypto";
create or replace function uuid_generate_v7()
returns uuid
as $$
select encode(
set_bit(
set_bit(
overlay(uuid_send(gen_random_uuid())
placing substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) from 3)
from 1 for 6
),
52, 1
),
53, 1
),
'hex')::uuid;
$$
language SQL
volatile;
CREATE FUNCTION isInVersion(
_version int,
_addedVersion int,
_removedVersion int
)
RETURNS boolean as $$
BEGIN
RETURN _version is null OR (
_version >= _addedVersion AND
(_removedVersion is null OR _version < _removedVersion)
);
END;
$$ LANGUAGE plpgsql;
CREATE DOMAIN unsignedsmallint AS SMALLINT
CHECK (VALUE >= 0);