From d73371c175cc589559e261e6e4cb25da2adcf368 Mon Sep 17 00:00:00 2001 From: casulit Date: Thu, 31 Oct 2024 16:22:09 +0800 Subject: [PATCH] refactor(database): Cast price as BIGINT and change column type to NUMERIC(15,2) --- config/deno-kv.ts | 2 +- schema.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/deno-kv.ts b/config/deno-kv.ts index 538393e..530a062 100644 --- a/config/deno-kv.ts +++ b/config/deno-kv.ts @@ -188,7 +188,7 @@ export async function listenQueue(kv: Deno.Kv) { (json_data->'dataLayer'->'attributes'->>'other_features')::jsonb AS property_features, json_data->'dataLayer'->'attributes'->>'listing_address' AS address, json_data->'dataLayer'->'attributes'->>'project_name' AS project_name, - json_data->'dataLayer'->'attributes'->>'price' AS price, + (json_data->'dataLayer'->'attributes'->>'price')::BIGINT AS price, json_data->'dataLayer'->'attributes'->>'price_formatted' AS price_formatted, json_data->'dataLayer'->'description'->>'text' AS description, CONCAT('https://lamudi.com.ph/', json_data->'dataLayer'->'attributes'->>'urlkey_details') AS full_url, diff --git a/schema.sql b/schema.sql index bf42c65..1660373 100644 --- a/schema.sql +++ b/schema.sql @@ -124,7 +124,7 @@ CREATE TABLE Listing ( is_scraped BOOLEAN NOT NULL DEFAULT FALSE, address VARCHAR(255), price_formatted VARCHAR(255), - price DOUBLE PRECISION NOT NULL CHECK (price >= 0), + price NUMERIC(15,2) NOT NULL CHECK (price >= 0), price_not_shown BOOLEAN default false, offer_type_id INT NOT NULL REFERENCES Listing_Type(listing_type_id), property_id INT NOT NULL REFERENCES Property(id) ON DELETE CASCADE,