This commit is contained in:
Daniel Flanagan 2022-10-07 17:23:43 -05:00
parent eb79b6f28f
commit 4fd2b61322
Signed by untrusted user: lytedev-divvy
GPG key ID: 6D69CEEE4ABBCD82
2 changed files with 8 additions and 2 deletions

View file

@ -14,4 +14,4 @@ This will watch the project directory and restart as necessary.
- Authn: https://github.com/dashbitco/mix_phx_gen_auth_demo/blob/auth/README.md
- Mail client
- Tokens and IDs? I'd love to use ULIDs or something
- Tokens and IDs? I'd love to use some kind of short identifier (youtube-esque IDs) or something

View file

@ -1,6 +1,6 @@
import { query } from "@/db/mod.ts";
const id = "id uuid primary key default uuid_generate_v4()";
const id = "id uuid primary key default generate_ulid()";
interface TableSpec {
columns: string[];
@ -106,6 +106,12 @@ begin;
${dropTables}
create extension if not exists "uuid-ossp";
create extension if not exists "pgcrypto";
create or replace function generate_ulid() returns uuid
as $$
select (lpad(to_hex(floor(extract(epoch from clock_timestamp()) * 1000)::bigint), 12, '0') || encode(gen_random_bytes(10), 'hex'))::uuid;
$$ language sql;
${createTables}