From 79f7d0403dd04c8f1de0875768b90243f761c275 Mon Sep 17 00:00:00 2001 From: Aashish Dhakal <85501584+dhakalaashish@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:36:39 +0545 Subject: [PATCH 1/2] Updated view_siteAlert migration --- .../migration.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql diff --git a/apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql b/apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql new file mode 100644 index 00000000..c54df054 --- /dev/null +++ b/apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql @@ -0,0 +1,17 @@ +-- Update SiteAlert View +CREATE OR REPLACE VIEW view_siteAlert AS +SELECT + "id", + "siteId", + "type", + "latitude", + "longitude", + "eventDate", + "detectedBy", + "confidence" +FROM + "SiteAlert" +WHERE + "deletedAt" IS NULL + AND "eventDate" > CURRENT_TIMESTAMP - INTERVAL '30 days'; + From 0b83e22730171e30643d9af5ce24c9fb53a23ecc Mon Sep 17 00:00:00 2001 From: Aashish Dhakal <85501584+dhakalaashish@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:47:07 +0545 Subject: [PATCH 2/2] Filter by current_date instead of current_timestamp --- .../migrations/20240404000000_create_view copy/migration.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql b/apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql index c54df054..a27c54eb 100644 --- a/apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql +++ b/apps/server/prisma/migrations/20240404000000_create_view copy/migration.sql @@ -13,5 +13,5 @@ FROM "SiteAlert" WHERE "deletedAt" IS NULL - AND "eventDate" > CURRENT_TIMESTAMP - INTERVAL '30 days'; + AND "eventDate" >= CURRENT_DATE - INTERVAL '30 days';