Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global code review #9

Open
wants to merge 117 commits into
base: reviewed
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
be1792d
refactor: change repository (#1)
Rignchen Apr 8, 2024
70f6f43
feat: implement login (#5)
jordyBSK Apr 12, 2024
9042cb9
feat: launch everything from the same docker compose (#2)
Rignchen Apr 12, 2024
308e75f
Fix: fix a few issues on the backend (#6)
Rignchen May 31, 2024
7752bef
feat: plan canvas (#8)
jordyBSK Jun 3, 2024
d85de2d
feat: get the ip address when averaging the values with the avg_date …
Rignchen Jun 7, 2024
2b4b46f
feat: setup a sqitch to handle migrations (#23)
Rignchen Jun 10, 2024
a5214ed
fix: readme and use latest docker images (#24)
Rignchen Jun 10, 2024
3148fca
refactor: reposition php code in the folder (#25)
Rignchen Jun 10, 2024
b983d79
fix: install php stan (#26)
Rignchen Jun 11, 2024
6283251
Interface next js (#28)
jordyBSK Jun 18, 2024
ad260bc
Login (#29)
jordyBSK Jun 18, 2024
16af540
Get data.ts files (#30)
jordyBSK Jun 18, 2024
d94906a
refactor: renamed file type and function for better separation (#31)
Alex-zReeZ Jun 18, 2024
e095c1b
feat: implement logout (#32)
jordyBSK Jun 19, 2024
32d7886
add Esp table (#33)
jordyBSK Jun 19, 2024
5fd26f4
fix: redirect to login when we logout (#34)
jordyBSK Jun 19, 2024
f12bde6
sort data by room ip (#35)
jordyBSK Jun 19, 2024
48db262
Revert "sort data by room ip (#35)" (#36)
jordyBSK Jun 19, 2024
00d6c9e
Revert "Revert "sort data by room ip (#35)" (#36)" (#37)
jordyBSK Jun 19, 2024
6d4434c
Plan data (#38)
jordyBSK Jun 20, 2024
38e1aec
feat: added dynamic data in dashboard and esp pages (#39)
Alex-zReeZ Jun 21, 2024
f3ed78b
Date range (#40)
jordyBSK Jun 21, 2024
8ec2912
fix: fix import duplication (#41)
jordyBSK Jun 21, 2024
2be57e8
fix: change dockerfile to work with next js
Alex-zReeZ Jun 24, 2024
4a1417d
refactor: added new Ip adresse
Alex-zReeZ Jun 24, 2024
3db6d23
refactor: removed output and added distdir to out
Alex-zReeZ Jun 24, 2024
0d16c0f
refactor: reformated file
Alex-zReeZ Jun 24, 2024
8d04934
refactor: added new Ip adresse, rounded data, moved getColor file and…
Alex-zReeZ Jun 25, 2024
4197a28
refactor: Rounded data (#42)
Alex-zReeZ Jun 25, 2024
16a782f
fix: tofixed temperature in espmap
Jun 25, 2024
36315e8
feat: added Workflow to check the format and lint (#46)
Alex-zReeZ Jun 25, 2024
1619744
refactor: resolve conflit
Jun 25, 2024
d150924
Merge branch 'Dev' of github.com:museebolo/climat_guardian into Dev
Jun 25, 2024
fbf86e5
Merge remote-tracking branch 'upstream/Dev' into Dev
Alex-zReeZ Jun 25, 2024
27f2fc5
feat: serve interface using a nodejs server (#48)
Rignchen Jun 25, 2024
b913fde
Merge remote-tracking branch 'upstream/Dev' into Dev
Alex-zReeZ Jun 25, 2024
ccd1027
fix: logout redirection (#49)
jordyBSK Jun 25, 2024
226b0a3
refactor: moved .github directory to root
Alex-zReeZ Jun 25, 2024
5934484
refactor: changed workflow execution type (#47)
Alex-zReeZ Jun 25, 2024
392eb9c
Merge branch 'Dev' of github.com:museebolo/climat_guardian into Dev
Alex-zReeZ Jun 25, 2024
f5864fb
style: properly format code
Jun 25, 2024
2a20a7e
fix: fix bugs to prepare for release (#50)
jordyBSK Jun 25, 2024
28306f3
fix: changed format commande and added format check and fix ts config…
Alex-zReeZ Jun 25, 2024
366d14c
feat: push production ready version to main (#52)
jordyBSK Jun 25, 2024
0639d73
Merge branch 'main' into fix-prettier-config
Alex-zReeZ Jun 25, 2024
f7f65b8
Revert "feat: push production ready version to main (#52)" (#53)
jordyBSK Jun 25, 2024
fa206fd
Merge pull request #54 from museebolo/Dev
jordyBSK Jun 25, 2024
df703d3
Merge branch 'main' into fix-prettier-config
Alex-zReeZ Jun 25, 2024
7940eae
refactor: removed -D flag in npm install and reformated code
Alex-zReeZ Jun 25, 2024
d456c85
Merge remote-tracking branch 'origin/fix-prettier-config' into fix-pr…
Alex-zReeZ Jun 25, 2024
5bb4b39
fix: fixed workflow not finding package lock because in the wrong dir…
Alex-zReeZ Jun 25, 2024
4a77a4a
fix: fix changed direction directory
Alex-zReeZ Jun 25, 2024
7980609
fix: fix changed cd direction
Alex-zReeZ Jun 25, 2024
92683b6
refactor: changed steps order
Alex-zReeZ Jun 25, 2024
521ba26
refactor: specified where to find package-lock.json
Alex-zReeZ Jun 25, 2024
3fb499b
refactor: removed change directory and replaced it with working-direc…
Alex-zReeZ Jun 25, 2024
c125ea7
Merge pull request #51 from Alex-zReeZ/fix-prettier-config
jordyBSK Jun 25, 2024
57152bf
fix: update developpment docker compose to work with current state of…
Rignchen Jun 26, 2024
4ef8f0a
fix: add .env inside php and nextjs folders (#57)
Rignchen Jun 26, 2024
7bcbfc3
Merge pull request #58 from museebolo/Dev
fuzoh Jun 27, 2024
5380f2a
Migration esp (#60)
jordyBSK Jun 27, 2024
f467e4d
refactor: Change interface style (#61)
Alex-zReeZ Jun 28, 2024
3ccd42e
feat: added display of the average of data in chosen range (#62)
Alex-zReeZ Jun 28, 2024
d463987
Middleware (#64)
jordyBSK Jul 1, 2024
164ee27
feat: added dark theme (#63)
Alex-zReeZ Jul 1, 2024
2c78465
feat: edit esp position (#65)
jordyBSK Jul 2, 2024
298994d
Feat: added possibility to rename an esp and added reload when adding…
Alex-zReeZ Jul 2, 2024
2567559
fix: added missing import of useState and reformated code (#67)
Alex-zReeZ Jul 2, 2024
57e298f
refactor: refactoring html structure for simpler structure (#68)
Alex-zReeZ Jul 3, 2024
38192a0
fix: resolved conflit (#71)
jordyBSK Jul 3, 2024
67625a7
refactor: changed graph hover popup, reformated files and removed unu…
Alex-zReeZ Jul 4, 2024
f694eb1
fix: replace local storage for cookies to store theme of user (#73)
Alex-zReeZ Jul 4, 2024
35505ab
refactor: changed branch and type execution of workflow to main (#74)
Alex-zReeZ Jul 4, 2024
8949ea8
ci: added workflow to check if the docker builds (#75)
Alex-zReeZ Jul 4, 2024
5146d68
style: change dark mode colors and use shadcn card (#77)
jordyBSK Jul 4, 2024
968f8fe
ci: added curl check to test (#78)
Alex-zReeZ Jul 4, 2024
0cc19ff
refactor: dashboard scroll (#79)
jordyBSK Jul 4, 2024
856f93b
Feat: added precision selector on esp page graph (#80)
Alex-zReeZ Jul 4, 2024
12f3cf3
refactor: Fix responsive in esp rooms and little details (#81)
Alex-zReeZ Jul 4, 2024
84e7b48
fix: fixed workflow to check for token (#84)
Alex-zReeZ Jul 4, 2024
d0dce56
refactor: check if token is valid (#85)
jordyBSK Jul 4, 2024
a7a3995
refactor: centered thermometer (#86)
Alex-zReeZ Jul 5, 2024
26cd04a
refactor: display ip address (#88)
jordyBSK Jul 5, 2024
92b90cc
refactor: changed border color in precision selector (#87)
Alex-zReeZ Jul 5, 2024
0056ec4
feat: allow users to remove users (#89)
Rignchen Jul 5, 2024
a856bbf
refactor: added button to show esp jwt token (#90)
Alex-zReeZ Jul 5, 2024
b3115ec
feat: implement add users in database (#91)
jordyBSK Jul 5, 2024
683f9ea
fix: fixed function getting user token instead of esp token (#92)
Alex-zReeZ Jul 5, 2024
4ec1499
feat: added gap on add user input (#93)
jordyBSK Jul 5, 2024
79b8d1b
fix: fixed jwt token fetch getting no Ip (#94)
Alex-zReeZ Jul 5, 2024
b7364e6
refactor: install the slim router for the php (#27)
Rignchen Jul 5, 2024
d8a64f5
feat: remove reload on move esp (#96)
jordyBSK Jul 8, 2024
d9a1758
feat: remove the choice of precision according to the days chosen (#95)
jordyBSK Jul 8, 2024
3aa4305
refactor: removed window reload when adding new esp to display new es…
Alex-zReeZ Jul 9, 2024
313a2a9
refactor: added verification of IP input with js (#99)
Alex-zReeZ Jul 9, 2024
e591139
docs: update readme (#101)
Rignchen Jul 9, 2024
ed38067
feat: Seperate days by a bar and added time stamp of data on graph (#…
Alex-zReeZ Jul 10, 2024
4a32441
fix: allow esp to know who they are (#106)
Rignchen Jul 10, 2024
f95ef11
fix: removed hardcoded localhost link (#107)
Alex-zReeZ Jul 10, 2024
4697933
refactor: added timestamp in graph xAxis (#108)
Alex-zReeZ Jul 10, 2024
bab4e08
refactor: removed readme in nextjs interface (#110)
Alex-zReeZ Jul 10, 2024
5e7e65a
fix: fix check build workflow and set timezon UTC+02:00 (#112)
Alex-zReeZ Aug 5, 2024
26ed858
fix: fix warning "list should have unique key" (#118)
Alex-zReeZ Aug 6, 2024
01c45dc
feat: added zooming interface in plan (#121)
adbme Aug 14, 2024
04cba05
feat: show the day when clicking on it (#122)
adbme Aug 15, 2024
c5c372f
Fix espid link when clicking on day (#123)
adbme Aug 16, 2024
5db9cfd
feat: show variance between days with two esp (#124)
adbme Aug 27, 2024
c451411
docs: add database and migrations documentation (#125)
fuzoh Aug 28, 2024
558a92a
ci: setup dependabot for automatic versions updates (#128)
fuzoh Aug 28, 2024
8c667f1
build: refactor dockerfiles name to avoid file type mismatches (#134)
fuzoh Aug 28, 2024
775dc2f
build(deps): bump micromatch from 4.0.7 to 4.0.8 in /nextjs-interface…
dependabot[bot] Aug 28, 2024
08e569a
build(deps-dev): bump @types/react in /nextjs-interface (#133)
dependabot[bot] Aug 28, 2024
0e4ecff
build(deps-dev): bump typescript in /nextjs-interface (#140)
dependabot[bot] Sep 4, 2024
e2b7852
build(deps): bump @radix-ui/react-popover in /nextjs-interface (#131)
dependabot[bot] Sep 4, 2024
7ee95a3
build(deps): bump @radix-ui/react-label in /nextjs-interface (#130)
dependabot[bot] Sep 4, 2024
2964325
build(deps): bump @radix-ui/react-slot in /nextjs-interface (#129)
dependabot[bot] Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .assets/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .assets/hardware-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .assets/software-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
POSTGREST_API=http://postg-rest:3000
DETAILED_ERRORS=false

ESP_PATH=./esp32/config
DB_PATH=./database/data

JWT_SECRET=
POSTGRES_PASSWORD=
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
# vim backup files
*.sw[pon]
.env
# nohup
nohup.out
19 changes: 19 additions & 0 deletions Dockerfile/Dockerfile.Nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# node 20, build the application
FROM node:20.12.2-alpine3.19
COPY ../Interface .
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have the Interface folder. Where does it come from?

is it nextjs-interface ?

RUN npm install
RUN npm run build


# nginx 1.26 on port 80, keep the build output, nginx config
FROM nginx:1.26-alpine-otel
EXPOSE 80
COPY --from=0 ../dist /var/www/memoires-info/html
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

../dist does not exist...
is it nextjs-interface/.next ?

COPY ../.env /var/www/memoires-info/html/.env

# copy the nginx config
COPY ../nginx.conf /etc/nginx/conf.d/default.conf
RUN sed -i '/location \/adminer\//,/}/d' /etc/nginx/conf.d/default.conf
# copy php files for ngnix to know they exist
COPY ../php/public /var/www/memoires-info/php/public

13 changes: 13 additions & 0 deletions Dockerfile/Dockerfile.Php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# php 8.3 with the files, install dependencies
FROM composer:2.7
COPY ../php .
RUN composer install

# copy required files to new image
FROM php:8.3-fpm-alpine
COPY ../php/public /var/www/memoires-info/php/public
COPY ../php/private /var/www/memoires-info/php/private
COPY ../php/lib.php /var/www/memoires-info/php
COPY ../.env /var/www/memoires-info/php/
COPY --from=0 ../app/vendor /var/www/memoires-info/php/vendor

3 changes: 3 additions & 0 deletions Dockerfile/Dockerfile.Sqitch
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM sqitch/sqitch:v1.4.1.0
CMD ["deploy"]

118 changes: 116 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,116 @@
# climat_guardian
Système de surveillance climatique
[Info]: <> (
All the information that are likely to need to be updated have a comment above them like this one
)
# Climate-Guardian
This project was made for the non-profit organization memoires-informatiques\
Memoires-informatiques has a lot of old computers and other electronic devices that need to be stored in a controlled environment\
The goal of this project is to monitor the temperature and humidity of the different rooms of the organization and to display the data on a web interface

# Setup
From now on, the computer that runs the docker will be called "server" and
the computer used by the user will be called "computer"

## Network
The server and the esp need to be connected to the same network, it is recommended to give both of them a static ip address\
The computer can be connected from any network as long as the network has open ports, otherwise you'll have to be on the same network as the server

![hardware](/.assets/hardware-diagram.png)\
![software](/.assets/software-diagram.png)

## Requirements
For this project to work you need to have the following installed on the server:
- Linux (Tested on [Ubuntu Server 22.04](https://ubuntu.com/download/server))
- [Docker Engine](https://docs.docker.com/engine/install/ubuntu/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Curl](https://curl.se/download.html)
- [jq](https://stedolan.github.io/jq/download/)
```bash
sudo apt-get update
sudo apt-get install git curl jq
sudo apt-get install ca-certificates
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

## Installation
First thing you need to do is to clone the repository from GitHub on the server
```bash
git clone https://github.com/museebolo/climat-guardian.git && cd climat-guardian
```

---
[Info]: <> (
This is the list of all the files that end with .example
)
Once the repository is cloned you can remove the `.example` at the end of the following files:
- .env.example
- esp32/config/secrets.yaml.example
- Interface/src/contexts/SampleContext.example.tsx
```bash
cp .env.example .env
cp esp32/config/secrets.yaml.example esp32/config/secrets.yaml
cp Interface/src/contexts/SampleContext.example.tsx Interface/src/contexts/SampleContext.tsx
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file SampleContext.example.tsx does not exist.
Can you update this?

```

---
Now you want to generate a secret key for the jwt tokens used by the api
```bash
sed -i '/JWT_SECRET/d' .env
echo "JWT_SECRET=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
```

You may also want to generate a random password for the database
```bash
sed -i '/POSTGRES_PASSWORD/d' .env
echo "POSTGRES_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 32)" >> .env
```

It is recommended to let the other environment variables as they are

---
Finally, you **have to** fill the Wi-Fi credentials in `esp32/config/secrets.yaml`\
You also **have to** change the `127.0.0.1` in `Interface/src/contexts/SampleContext.tsx` and `esp32/config/secrets.yaml` by the ip address of the server

## Start the project
Once everything is configured on the server, you can start the project by running the docker compose on the server
```bash
docker compose -f docker-compose.prod.yml up -d --remove-orphans --build
```
Once the docker is running you can access the web interface by going to the ip address of the server in the web browser of the computer\
the default user is `admin` and has `admin` as password

![web interface](/.assets/dashboard.png)

## ESP 32 Installation
This project uses [esp home](https://github.com/esphome/esphome) to manage the esp32, you can configure the esp32 by following the instructions below
- Connect yourself to the esp home interface by going to `127.0.0.1/esp` in the web browser of the computer (replace `127.0.0.1` with the ip address of the server)
- Plug the esp32 to the server
- Press the `+ NEW DEVICE` button inside esp home
- Name your device
- Select `ESP32` (on the top of the list)
- Press `INSTALL` and select `Plug into the computer running ESPHome Dashboard` (the 3rd option)
- Select the device with ``/dev/ttyUSB0`` as path
- Wait for the installation to finish\
Be sure to memorize the ip address of the esp32 (you can find it in the logs)
$${\color{gray} \text{[15:39:12]} \color{magenta} \text{[C][wifi:416]: IP Address: 172.16.5.65}}$$
- You can now unplug the esp32 and plug it to any other power source
- Press `Edit` at the bottom of the logs
- Copy everything from the line 31 of the file `esp32/esp32.yaml` on the server and paste it at the end of your esp32's configuration file
```bash
clear && cat esp32/esp32.yaml | sed -n '31,$p'
```
- Replace the XXX... at the end of the code with the token of your esp32\
you can generate this token by running the following command on the server (replace `255.255.255.255` with the ip address of the esp32)
```bash
export TOKEN=$(curl 'http://127.0.0.1/php/login.php' -d '{"username":"admin","password":"admin"}' -X POST | jq '.token' -r)
curl -H "Authorization: Bearer $TOKEN" "http://127.0.0.1/php/esp.php" -d '{"ip":"255.255.255.255"}' -X POST | jq '.token' -r
```
- Press `INSTALL` and select `Wirelessly` (the 1st option)
- Wait for the installation to finish
- Press `STOP` to exit the logs

1 change: 1 addition & 0 deletions database/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data
56 changes: 56 additions & 0 deletions database/migration/deploy/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- Deploy climat-guardian:data to pg

BEGIN;

create table api.data (
temperature real,
humidity real,
timestamp timestamp NOT NULL,
ip character varying(15) NOT NULL
);
grant select on api.data to web_user;

-- convert unix timestamp to timestamp and insert it
create or replace function api.insert_data(
temperature real,
humidity real,
ip varchar(15),
unix_timestamp bigint
)
returns void as $$
begin
-- if the ip said in the token is not the same as the one in the request, then this means that the user is not who he pretends to be and we should throw an error
if (current_setting('request.jwt.claims', true)::json->>'ip' != ip) then
raise exception insufficient_privilege
using hint = 'You are not who you pretend to be';
end if;
-- insert the data
insert into api.data("temperature", "humidity", "ip", "timestamp") values (temperature, humidity, ip, to_timestamp(unix_timestamp));
end $$ language plpgsql;
grant insert on api.data to esp32;

-- create a function to get the average temperature and humidity of each delta time
create function api.avg_date(
delta varchar
)
returns table(
avg_temperature double precision,
avg_humidity double precision,
date timestamp,
ip character varying(15),
count bigint
) as $$
begin
return query select
avg(temperature) as avg_temperature,
avg(humidity) as avg_humidity,
date_trunc(delta, timestamp) as date,
data.ip,
count(*) as count
from api.data
group by date, data.ip
order by date;
end;
$$ language plpgsql;

COMMIT;
8 changes: 8 additions & 0 deletions database/migration/deploy/postgrest.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Deploy climat-guardian:postgrest to pg

BEGIN;

create schema api;
create role authenticator noinherit login password 'mysecretpassword';

COMMIT;
25 changes: 25 additions & 0 deletions database/migration/deploy/roles.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Deploy climat-guardian:roles to pg

BEGIN;

-- anonymous role
create role web_anon nologin;
grant usage on schema api to web_anon;
grant web_anon to authenticator;

-- create role for the esp 32
create role esp32 nologin;
grant usage on schema api to esp32;
grant esp32 to authenticator;

-- create role for the users
create role web_user nologin;
grant usage on schema api to web_user;
grant web_user to authenticator;

-- create a role for the login
create role web_login nologin;
grant usage on schema api to web_login;
grant web_login to authenticator;

COMMIT;
18 changes: 18 additions & 0 deletions database/migration/deploy/user.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Deploy climat-guardian:user to pg

BEGIN;

create table api.users (
id serial primary key,
username character varying(50) NOT NULL UNIQUE,
password character varying(60) NOT NULL
);

grant usage, select on sequence api.users_id_seq to web_user;
grant insert on api.users to web_user; -- any user can add new users
grant select on api.users to web_login;

-- create first user to be able to connect first time
insert into api.users(username, password) values ('admin', '$2y$10$vJMf8H4u0f913VOJJDqVIeYrqnZBSzgYZ3Zyoh76MDjf6ZlmNDKPu');

COMMIT;
9 changes: 9 additions & 0 deletions database/migration/revert/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Revert climat-guardian:data from pg

BEGIN;

drop table api.data;
drop function api.avg_date;
drop function api.insert_data;

COMMIT;
8 changes: 8 additions & 0 deletions database/migration/revert/postgrest.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Revert climat-guardian:postgrest from pg

BEGIN;

drop schema api;
drop role authenticator;

COMMIT;
21 changes: 21 additions & 0 deletions database/migration/revert/roles.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Revert climat-guardian:roles from pg

BEGIN;

-- anonymous role
revoke usage on schema api from web_anon;
drop role web_anon;

-- esp 32
revoke usage on schema api from esp32;
drop role esp32;

-- users
revoke usage on schema api from web_user;
drop role web_user;

-- login
revoke usage on schema api from web_login;
drop role web_login;

COMMIT;
7 changes: 7 additions & 0 deletions database/migration/revert/user.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert climat-guardian:user from pg

BEGIN;

drop table api.users;

COMMIT;
Loading