Added solar schema

This commit is contained in:
Khalim Conn-Kowlessar 2024-07-10 10:26:27 +01:00
parent 5f22a9f193
commit d203bb9c27
5 changed files with 1766 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import * as portfolioSchema from "@/app/db/schema/portfolio";
import * as propertySchema from "@/app/db/schema/property";
import * as recommendationSchema from "@/app/db/schema/recommendations";
import * as materialSchema from "@/app/db/schema/materials";
import * as solarSchema from "@/app/db/schema/solar";
import * as Relations from "@/app/db/schema/relations";
export const pool = new Pool({
@ -22,6 +23,7 @@ const schema = {
...propertySchema,
...recommendationSchema,
...materialSchema,
...solarSchema,
...Relations,
};

View file

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS "solar" (
"id" bigserial PRIMARY KEY NOT NULL,
"longitude" real NOT NULL,
"latitude" real NOT NULL,
"uprn" text NOT NULL,
"created_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp (6) with time zone DEFAULT now() NOT NULL,
"api_response" jsonb NOT NULL
);

File diff suppressed because it is too large Load diff

View file

@ -498,6 +498,13 @@
"when": 1720563097899,
"tag": "0070_sweet_riptide",
"breakpoints": true
},
{
"idx": 71,
"version": "5",
"when": 1720603508125,
"tag": "0071_same_puppet_master",
"breakpoints": true
}
]
}

View file

@ -0,0 +1,33 @@
import {
bigserial,
text,
timestamp,
pgTable,
real,
jsonb,
} from "drizzle-orm/pg-core";
import { InferModel } from "drizzle-orm";
export const Solar = pgTable("solar", {
id: bigserial("id", { mode: "bigint" }).primaryKey(),
longitude: real("longitude").notNull(),
latitude: real("latitude").notNull(),
uprn: text("uprn").notNull(),
createdAt: timestamp("created_at", {
precision: 6,
withTimezone: true,
})
.defaultNow()
.notNull(),
updatedAt: timestamp("updated_at", {
precision: 6,
withTimezone: true,
})
.defaultNow()
.notNull(),
googleApiResponse: jsonb("api_response").notNull(),
});
// Define types for selecting and inserting data
export type ApiResponse = InferModel<typeof Solar, "select">;
export type NewApiResponse = InferModel<typeof Solar, "insert">;