-- Deploy camper:language to pg
-- requires: roles
-- requires: schema_public

begin;

set search_path to public;

create table language
(
	lang_tag text primary key check (length(lang_tag) < 36), -- RFC5646 recommends 35 at least
	name text not null,
	endonym text not null,
	selectable boolean not null,
	currency_pattern text not null,
	redsys_code integer not null
);

grant select on table language to guest;
grant select on table language to employee;
grant select on table language to admin;
grant select on table language to authenticator;

comment on table language is
'Languages/locales available in Camper';

comment on column language.lang_tag is
'BCP-47 language tag';

comment on column language.selectable is
'Whether the language should be a option in a user-facing select control.';

commit;