You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A domain is "essentially a data type with optional constraints". You can think of them as type aliases. By using a domain, you can easily create custom types. For example, here's how you could create a KSUID type.
CREATEDOMAINksuidASVARCHAR(27) NOT NULL;
CREATETABLEfoo (
id ksuid PRIMARY KEY,
created_at TIMESTAMP DEFAULT NOW()
);
CREATETABLEbar (
id ksuid PRIMARY KEY,
created_at TIMESTAMP DEFAULT NOW(),
foo_id ksuid REFERENCES foo(id),
name textNOT NULL,
slug textNOT NULL UNIQUE
);
The advantage to using a domain is that you'd only need one entry in overrides
Activity
stepan-romankov commentedon Jul 12, 2023
This looks to be supported, except schema scoped domain types like
CREATE DOMAIN public.name TEXT NOT NULL;hectorj-thetreep commentedon Dec 8, 2023
It seems to work too, you just have to include the scope in the
db_type