This commit is contained in:
2025-09-18 07:48:51 +02:00
parent b131af5a82
commit a413a5173d
6 changed files with 134 additions and 22 deletions

View File

@@ -65,24 +65,3 @@ create table region (
insert into region values
(1, 'Est'), (2, 'Ouest');
-- Apache Superset
create database superset;
create user superset with password 'supermotdepasse';
grant all privileges on database superset to superset;
grant connect on database sql to superset;
grant usage on schema public to superset;
grant select on table famille, article to superset;
-- Pour toutes les tables dun schéma existant
grant select on all tables in schema public to superset;
-- Privilège par défaut pour que chaque nouvelle table créée dans public donnera automatiquement le droit SELECT à superset.
alter default privileges in schema public
grant select on tables to superset;
\c superset
alter schema public owner to superset;
grant all privileges on schema public to superset;

View File

@@ -9,3 +9,23 @@ create view nb_total_tickets as
create view nb_total_adherents as
select count(*) as nb_total_adherents from adherent;
create materialized view detail_ticket as
select t.id as ticket_id, t.date_ticket, t.mode_rglt,
h.id as adherent_id, h.codepostal, h.genre,
round(sum(l.total), 2) as total
from ticket t
join ligne l on l.ticket_id = t.id
join adherent h on h.id = t.adherent_id
group by t.id, h.id;
create materialized view detail_vente as
select t.id as ticket_id, t.date_ticket, t.mode_rglt,
h.id as adherent_id, h.codepostal, h.genre,
l.article_code, a.famille_code,
round(sum(l.total), 2) as total
from ticket t
join ligne l on l.ticket_id = t.id
join adherent h on h.id = t.adherent_id
join article a on a.code = l.article_code
group by t.id, h.id, l.article_code, a.famille_code;

View File

@@ -0,0 +1,43 @@
-- Metabase
create role metabase_user with
login
nosuperuser
nocreatedb
nocreaterole
noinherit
noreplication
connection limit -1
password 'supermotdepasse';
create database metabase with
owner metabase_user;
grant connect
on database metabase
to metabase_user;
grant connect
on database sql
to metabase_user;
grant usage
on schema public
to metabase_user;
grant select
on table famille, article
to metabase_user;
-- Pour toutes les tables du schéma public
grant select
on all tables
in schema public
to metabase_user;
-- Privilège par défaut pour que chaque nouvelle table créée dans public donnera automatiquement le droit SELECT à metabase.
alter default privileges
in schema public
grant select
on tables
to metabase_user;

View File

@@ -0,0 +1,43 @@
-- Apache Superset
create role superset_user with
login
nosuperuser
nocreatedb
nocreaterole
noinherit
noreplication
connection limit -1
password 'supermotdepasse';
create database superset with
owner superset_user;
grant connect
on database superset
to superset_user;
grant connect
on database sql
to superset_user;
grant usage
on schema public
to superset_user;
grant select
on table famille, article
to superset_user;
-- Pour toutes les tables du schéma public
grant select
on all tables
in schema public
to superset_user;
-- Privilège par défaut pour que chaque nouvelle table créée dans public donnera automatiquement le droit SELECT à superset_user.
alter default privileges
in schema public
grant select
on tables
to superset_user;