45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import { integer, json, pgTable, real, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
|
|
|
export const users = pgTable("users", {
|
|
id: text().primaryKey(),
|
|
age: integer(),
|
|
username: text().notNull().unique(),
|
|
passwordHash: text().notNull(),
|
|
});
|
|
|
|
export const sessions = pgTable("sessions", {
|
|
id: text().primaryKey(),
|
|
userId: text()
|
|
.notNull()
|
|
.references(() => users.id),
|
|
expiresAt: timestamp({ withTimezone: true, mode: "date" }).notNull(),
|
|
});
|
|
|
|
export const floors = pgTable("floors", {
|
|
floor: integer().primaryKey(),
|
|
url: text().notNull(),
|
|
image: text(),
|
|
});
|
|
|
|
export const plans = pgTable("plans", {
|
|
floor: integer().primaryKey(),
|
|
plan: json().notNull(),
|
|
});
|
|
|
|
export const sensors = pgTable("sensors", {
|
|
id: text().primaryKey(),
|
|
user: text()
|
|
.references(() => users.id)
|
|
.notNull(),
|
|
});
|
|
|
|
export const sensorData = pgTable("sensor_data", {
|
|
uuid: uuid().primaryKey(),
|
|
sensor: text("sensor")
|
|
.references(() => sensors.id)
|
|
.notNull(),
|
|
temperature: real().notNull(),
|
|
humidity: real().notNull(),
|
|
pressure: real().notNull(),
|
|
altitude: real().notNull(),
|
|
});
|