-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Get Weather alert and save it on db (#314)
- Loading branch information
1 parent
ec8c030
commit 46e5d33
Showing
11 changed files
with
505 additions
and
37,678 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
151 changes: 151 additions & 0 deletions
151
api-node/prisma/migrations/20231224160600_add_phenomenons/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
-- CreateEnum | ||
CREATE TYPE "DataAvailabilityEnum" AS ENUM ('AVAILABLE', 'NOT_AVAILABLE'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "CodeAlertEnums" AS ENUM ('GREEN', 'YELLOW', 'ORANGE', 'RED'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "PhenomenonsEnum" AS ENUM ('VIOLENT_WIND', 'RAIN_FLOOD', 'STORM', 'FLOOD', 'SNOW_ICE', 'HEAT_WAVE', 'COLD_WAVE', 'AVALANCHE', 'WAVES_SUBMERSION'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "PollutionStateEnum" AS ENUM ('ALERT', 'INFORMATION_AND_RECOMMANDATION', 'NO_ALERT', 'ALERT_PERSISTANCE'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "PollutionCodeEnum" AS ENUM ('SULFUR_DIOXIDE', 'NITROGEN_DIOXIDE', 'FINES_PARTICLES', 'OZONE', 'PM10', 'PM25', 'BENZENE'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL, | ||
"matomo_id" TEXT NOT NULL, | ||
"municipality_insee_code" TEXT, | ||
"municipality_name" TEXT, | ||
"municipality_zip_code" TEXT, | ||
"push_notif_token" TEXT, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "IndiceUv" ( | ||
"id" TEXT NOT NULL, | ||
"validity_start" TIMESTAMP(3) NOT NULL, | ||
"validity_end" TIMESTAMP(3) NOT NULL, | ||
"diffusion_date" TIMESTAMP(3) NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"municipality_insee_code" TEXT NOT NULL, | ||
"data_availability" "DataAvailabilityEnum" DEFAULT 'AVAILABLE', | ||
"uv_j0" INTEGER NOT NULL, | ||
"uv_j1" INTEGER NOT NULL, | ||
"uv_j2" INTEGER NOT NULL, | ||
"uv_j3" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "IndiceUv_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "PollenAllergyRisk" ( | ||
"id" TEXT NOT NULL, | ||
"validity_start" TIMESTAMP(3) NOT NULL, | ||
"validity_end" TIMESTAMP(3) NOT NULL, | ||
"diffusion_date" TIMESTAMP(3) NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"municipality_insee_code" TEXT NOT NULL, | ||
"data_availability" "DataAvailabilityEnum" DEFAULT 'AVAILABLE', | ||
"cypres" INTEGER DEFAULT 0, | ||
"noisetier" INTEGER DEFAULT 0, | ||
"aulne" INTEGER DEFAULT 0, | ||
"peuplier" INTEGER DEFAULT 0, | ||
"saule" INTEGER DEFAULT 0, | ||
"frene" INTEGER DEFAULT 0, | ||
"charme" INTEGER DEFAULT 0, | ||
"bouleau" INTEGER DEFAULT 0, | ||
"platane" INTEGER DEFAULT 0, | ||
"chene" INTEGER DEFAULT 0, | ||
"olivier" INTEGER DEFAULT 0, | ||
"tilleul" INTEGER DEFAULT 0, | ||
"chataignier" INTEGER DEFAULT 0, | ||
"rumex" INTEGER DEFAULT 0, | ||
"graminees" INTEGER DEFAULT 0, | ||
"plantain" INTEGER DEFAULT 0, | ||
"urticacees" INTEGER DEFAULT 0, | ||
"armoises" INTEGER DEFAULT 0, | ||
"ambroisies" INTEGER DEFAULT 0, | ||
"total" INTEGER DEFAULT 0, | ||
|
||
CONSTRAINT "PollenAllergyRisk_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Phenomenon" ( | ||
"id" TEXT NOT NULL, | ||
"name" "PhenomenonsEnum", | ||
"code_alert" "CodeAlertEnums", | ||
"weatherAlertId" TEXT, | ||
|
||
CONSTRAINT "Phenomenon_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "WeatherAlert" ( | ||
"id" TEXT NOT NULL, | ||
"validity_start" TIMESTAMP(3) NOT NULL, | ||
"validity_end" TIMESTAMP(3) NOT NULL, | ||
"diffusion_date" TIMESTAMP(3) NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"municipality_insee_code" TEXT NOT NULL, | ||
"data_availability" "DataAvailabilityEnum" DEFAULT 'AVAILABLE', | ||
|
||
CONSTRAINT "WeatherAlert_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "IndiceAtmosperic" ( | ||
"id" TEXT NOT NULL, | ||
"validity_start" TIMESTAMP(3) NOT NULL, | ||
"validity_end" TIMESTAMP(3) NOT NULL, | ||
"diffusion_date" TIMESTAMP(3) NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"municipality_insee_code" TEXT NOT NULL, | ||
"data_availability" "DataAvailabilityEnum" DEFAULT 'AVAILABLE', | ||
"no2" INTEGER NOT NULL, | ||
"so2" INTEGER NOT NULL, | ||
"o3" INTEGER NOT NULL, | ||
"pm10" INTEGER NOT NULL, | ||
"pm25" INTEGER NOT NULL, | ||
"max_value" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "IndiceAtmosperic_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "AlertPollutionAtmospheric" ( | ||
"id" TEXT NOT NULL, | ||
"validity_start" TIMESTAMP(3) NOT NULL, | ||
"validity_end" TIMESTAMP(3) NOT NULL, | ||
"diffusion_date" TIMESTAMP(3) NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"municipality_insee_code" TEXT NOT NULL, | ||
"data_availability" "DataAvailabilityEnum" DEFAULT 'AVAILABLE', | ||
"state" "PollutionStateEnum" NOT NULL, | ||
"code" "PollutionCodeEnum" NOT NULL, | ||
"comment_short" TEXT NOT NULL, | ||
"comment_long" TEXT NOT NULL, | ||
|
||
CONSTRAINT "AlertPollutionAtmospheric_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_matomo_id_key" ON "User"("matomo_id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "User_push_notif_token_idx" ON "User" USING HASH ("push_notif_token"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Phenomenon" ADD CONSTRAINT "Phenomenon_weatherAlertId_fkey" FOREIGN KEY ("weatherAlertId") REFERENCES "WeatherAlert"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
17 changes: 17 additions & 0 deletions
17
api-node/prisma/migrations/20231224162212_remove_phenomenon/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the `Phenomenon` table. If the table is not empty, all the data it contains will be lost. | ||
- Added the required column `code_alert` to the `WeatherAlert` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `phenomenon` to the `WeatherAlert` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Phenomenon" DROP CONSTRAINT "Phenomenon_weatherAlertId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "WeatherAlert" ADD COLUMN "code_alert" "CodeAlertEnums" NOT NULL, | ||
ADD COLUMN "phenomenon" "PhenomenonsEnum" NOT NULL; | ||
|
||
-- DropTable | ||
DROP TABLE "Phenomenon"; |
3 changes: 3 additions & 0 deletions
3
api-node/prisma/migrations/20231224162517_remove_phenomenon/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- AlterTable | ||
ALTER TABLE "WeatherAlert" ALTER COLUMN "code_alert" DROP NOT NULL, | ||
ALTER COLUMN "phenomenon" DROP NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.