diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-08-26 22:07:42 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-08-26 22:07:42 +0200 |
commit | 6e6f2ce7c24acabdfd1f1f59378467ea225fb27a (patch) | |
tree | fd8e08320e6d7b57937023621770bb06f2c31fa9 /schema | |
parent | 8d36b0b75904812ba8f6b9e38b50660dfbe78d0d (diff) |
Add alerts
A payload for alert creation can be
```
{
"query": "mutation NewAlert($input: AlertInput!) { newAlert(input: $input) { id createdAt level } }",
"variables": {
"input": {
"points": [
{ "latitude": 40.73061, "longitude": -73.935242 },
{ "latitude": 40.741895, "longitude": -73.989308 },
{ "latitude": 40.712776, "longitude": -74.005974 },
{ "latitude": 40.73061, "longitude": -73.935242 },
],
"level": "TWO"
}
}
}
```
Diffstat (limited to 'schema')
-rw-r--r-- | schema/init.sql | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/schema/init.sql b/schema/init.sql index 682431c..8950a5f 100644 --- a/schema/init.sql +++ b/schema/init.sql @@ -18,3 +18,17 @@ CREATE TABLE positions( CONSTRAINT fk_users_id FOREIGN KEY(user_id) REFERENCES users(id) ); + +CREATE TYPE level_alert AS ENUM ('One', 'Two', 'Three'); + +CREATE TABLE alerts( + id SERIAL NOT NULL, + user_id INTEGER NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + area GEOMETRY(Polygon, 4326), + level level_alert NOT NULL, + reached_users INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY(id), + CONSTRAINT fk_users_id + FOREIGN KEY(user_id) REFERENCES users(id) +); |