Skip to content

Commit

Permalink
Change le type des colonnes vers double precision
Browse files Browse the repository at this point in the history
  • Loading branch information
derfurth committed Nov 20, 2023
1 parent f58dd22 commit cd30890
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 30 deletions.
46 changes: 19 additions & 27 deletions data_layer/sqitch/deploy/indicateur/artificialisation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@

BEGIN;

create table indicateur_artificialisation
(
collectivite_id integer references collectivite primary key,
total integer not null,
activite integer not null,
habitat integer not null,
mixte integer not null,
routiere integer not null,
ferroviaire integer not null,
inconnue integer not null
);
alter table indicateur_artificialisation
enable row level security;
create policy allow_read on indicateur_artificialisation for select using (true);

create function
indicateur_artificialisation(site_labellisation)
returns setof indicateur_artificialisation
rows 1
security definer
begin
atomic
select ia
from indicateur_artificialisation ia
where ia.collectivite_id = $1.collectivite_id;
end;
comment on function indicateur_artificialisation(site_labellisation) is
'Flux de consommation d’espaces, par destination entre 2009 et 2022';
alter column total type double precision using total::double precision;

alter table indicateur_artificialisation
alter column activite type double precision using activite::double precision;

alter table indicateur_artificialisation
alter column habitat type double precision using habitat::double precision;

alter table indicateur_artificialisation
alter column mixte type double precision using mixte::double precision;

alter table indicateur_artificialisation
alter column routiere type double precision using routiere::double precision;

alter table indicateur_artificialisation
alter column ferroviaire type double precision using ferroviaire::double precision;

alter table indicateur_artificialisation
alter column inconnue type double precision using inconnue::double precision;

COMMIT;
34 changes: 34 additions & 0 deletions data_layer/sqitch/deploy/indicateur/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Deploy tet:indicateur/artificialisation to pg

BEGIN;

create table indicateur_artificialisation
(
collectivite_id integer references collectivite primary key,
total integer not null,
activite integer not null,
habitat integer not null,
mixte integer not null,
routiere integer not null,
ferroviaire integer not null,
inconnue integer not null
);
alter table indicateur_artificialisation
enable row level security;
create policy allow_read on indicateur_artificialisation for select using (true);

create function
indicateur_artificialisation(site_labellisation)
returns setof indicateur_artificialisation
rows 1
security definer
begin
atomic
select ia
from indicateur_artificialisation ia
where ia.collectivite_id = $1.collectivite_id;
end;
comment on function indicateur_artificialisation(site_labellisation) is
'Flux de consommation d’espaces, par destination entre 2009 et 2022';

COMMIT;
24 changes: 21 additions & 3 deletions data_layer/sqitch/revert/indicateur/artificialisation.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
-- Revert tet:indicateur/artificialisation from pg
-- Deploy tet:indicateur/artificialisation to pg

BEGIN;

drop function indicateur_artificialisation(site_labellisation);
drop table indicateur_artificialisation;
alter table indicateur_artificialisation
alter column total type integer using total::integer;

alter table indicateur_artificialisation
alter column activite type integer using activite::integer;

alter table indicateur_artificialisation
alter column habitat type integer using habitat::integer;

alter table indicateur_artificialisation
alter column mixte type integer using mixte::integer;

alter table indicateur_artificialisation
alter column routiere type integer using routiere::integer;

alter table indicateur_artificialisation
alter column ferroviaire type integer using ferroviaire::integer;

alter table indicateur_artificialisation
alter column inconnue type integer using inconnue::integer;

COMMIT;
8 changes: 8 additions & 0 deletions data_layer/sqitch/revert/indicateur/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Revert tet:indicateur/artificialisation from pg

BEGIN;

drop function indicateur_artificialisation(site_labellisation);
drop table indicateur_artificialisation;

COMMIT;
2 changes: 2 additions & 0 deletions data_layer/sqitch/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,5 @@ taxonomie/personne 2023-11-07T08:58:36Z Florian <[email protected]> # Répare

indicateur/artificialisation 2023-11-16T13:12:35Z Florian <[email protected]> # Artificialisation des sols de 2009 à 2022
@v2.81.0 2023-11-16T14:13:44Z Florian <[email protected]> # Indicateur d'artificialisation des sols pour le site

indicateur/artificialisation [indicateur/[email protected]] 2023-11-20T14:17:42Z Florian <[email protected]> # Change le type des colonnes en "double precision"
7 changes: 7 additions & 0 deletions data_layer/sqitch/verify/indicateur/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify tet:indicateur/artificialisation on pg

BEGIN;

-- XXX Add verifications here.

ROLLBACK;

0 comments on commit cd30890

Please sign in to comment.