Skip to content

Instantly share code, notes, and snippets.

@Tycholiz
Last active April 10, 2021 04:05
Show Gist options
  • Save Tycholiz/bd28263777e250038144d81ba8e3b8de to your computer and use it in GitHub Desktop.
Save Tycholiz/bd28263777e250038144d81ba8e3b8de to your computer and use it in GitHub Desktop.
-- The enum way
create type app_public.role_types as enum (
'READER',
'PUBLISHER'
);
create table app_public.roles (
id uuid primary key,
title app_public.role_types
);
insert into app_public.roles (title) values ('READER')
insert into app_public.roles (title) values ('PUBLISHER')
insert into app_public.roles (title) values ('CURATOR') -- error: ain't no CURATOR on an app_public.role_types
alter type app_public.role_types add value 'CURATOR';
insert into app_public.roles (title) values ('CURATOR') -- all good!
-- The text way
create table app_public.roles (
id uuid primary key,
title text
);
insert into app_public.roles (title) values ('READER')
insert into app_public.roles (title) values ('PUBLISHER')
insert into app_public.roles (title) values ('CURATOR')
insert into app_public.roles (title) values ('CURRATOR') -- whoops, my clumsy fingers mispelled this and now what?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment