summaryrefslogtreecommitdiffstats
path: root/sql/schema.sql
blob: 76916c1fcd00bd192521dd8db6af5edc8414479b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- Schema and table definitions for faktura
--
-- SPDX-FileCopyrightText: 2024 Eilertsens Kodeknekkeri
-- SPDX-FileCopyrightText: 2024 Harald Eilertsen
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

create schema api;

create table api.clients (
  id serial primary key,
  name text not null,
  contact text,
  email text not null,
  phone text,
  address text,
  vat boolean
);

-- Set up web user for anonymous requests
create role web_anon nologin;
grant usage on schema api to web_anon;
grant select on api.clients to web_anon;

-- Set up trusted user for modifications
create role faktura_user nologin;
grant usage on schema api to faktura_user;
grant all on api.clients to faktura_user;
grant usage, select on sequence api.clients_id_seq to faktura_user;

-- Set up authenticator user for db login
create role authenticator noinherit login password 'password';
grant web_anon to authenticator;
grant faktura_user to authenticator;