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.
CREATE DOMAIN ksuid AS VARCHAR(27) NOT NULL;
CREATE TABLE foo (
id ksuid PRIMARY KEY,
created_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE bar (
id ksuid PRIMARY KEY,
created_at TIMESTAMP DEFAULT NOW(),
foo_id ksuid REFERENCES foo(id),
name text NOT NULL,
slug text NOT NULL UNIQUE
);
The advantage to using a domain is that you'd only need one entry in overrides
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.
The advantage to using a domain is that you'd only need one entry in overrides
Replaces #418