refactor(db): added timezone check in so it comes over correct based on the backend timezone
This commit is contained in:
@@ -17,15 +17,15 @@ export const alplaPurchaseHistory = pgTable("alpla_purchase_history", {
|
|||||||
status: integer("status"),
|
status: integer("status"),
|
||||||
statusText: text("status_text"),
|
statusText: text("status_text"),
|
||||||
journalNum: integer("journal_num"),
|
journalNum: integer("journal_num"),
|
||||||
add_date: timestamp("add_date").defaultNow(),
|
add_date: timestamp("add_date", { withTimezone: true }).defaultNow(),
|
||||||
add_user: text("add_user"),
|
add_user: text("add_user"),
|
||||||
upd_user: text("upd_user"),
|
upd_user: text("upd_user"),
|
||||||
upd_date: timestamp("upd_date").defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
|
||||||
remark: text("remark"),
|
remark: text("remark"),
|
||||||
approvedStatus: text("approved_status").default("new"),
|
approvedStatus: text("approved_status").default("new"),
|
||||||
position: jsonb("position").default([]),
|
position: jsonb("position").default([]),
|
||||||
createdAt: timestamp("created_at").defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
updatedAt: timestamp("updated_at").defaultNow(),
|
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const alplaPurchaseHistorySchema =
|
export const alplaPurchaseHistorySchema =
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import { integer, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
|||||||
export const analytics = pgTable("analytics", {
|
export const analytics = pgTable("analytics", {
|
||||||
id: uuid("id").defaultRandom().primaryKey(),
|
id: uuid("id").defaultRandom().primaryKey(),
|
||||||
|
|
||||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
|
|
||||||
method: text("method").notNull(),
|
method: text("method").notNull(),
|
||||||
routePattern: text("route_pattern").notNull(),
|
routePattern: text("route_pattern").notNull(),
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ export const jobAuditLog = pgTable(
|
|||||||
id: uuid("id").defaultRandom().primaryKey(),
|
id: uuid("id").defaultRandom().primaryKey(),
|
||||||
jobName: text("job_name"),
|
jobName: text("job_name"),
|
||||||
startedAt: timestamp("start_at"),
|
startedAt: timestamp("start_at"),
|
||||||
finishedAt: timestamp("finished_at"),
|
finishedAt: timestamp("finished_at", { withTimezone: true }),
|
||||||
durationMs: integer("duration_ms"),
|
durationMs: integer("duration_ms"),
|
||||||
status: text("status"), //success | error
|
status: text("status"), //success | error
|
||||||
errorMessage: text("error_message"),
|
errorMessage: text("error_message"),
|
||||||
errorStack: text("error_stack"),
|
errorStack: text("error_stack"),
|
||||||
metadata: jsonb("meta_data"),
|
metadata: jsonb("meta_data"),
|
||||||
createdAt: timestamp("created_at").defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
},
|
},
|
||||||
(table) => {
|
(table) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const user = pgTable("user", {
|
|||||||
emailVerified: boolean("email_verified").default(false).notNull(),
|
emailVerified: boolean("email_verified").default(false).notNull(),
|
||||||
image: text("image"),
|
image: text("image"),
|
||||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||||
updatedAt: timestamp("updated_at")
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
||||||
.defaultNow()
|
.defaultNow()
|
||||||
.$onUpdate(() => /* @__PURE__ */ new Date())
|
.$onUpdate(() => /* @__PURE__ */ new Date())
|
||||||
.notNull(),
|
.notNull(),
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ export const deploymentHistory = pgTable("deployment_history", {
|
|||||||
buildNumber: integer("build_number").notNull(),
|
buildNumber: integer("build_number").notNull(),
|
||||||
status: text("status").notNull(), // started, success, failed
|
status: text("status").notNull(), // started, success, failed
|
||||||
message: text("message"),
|
message: text("message"),
|
||||||
createdAt: timestamp("created_at").defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,11 +28,15 @@ export const analyticsDaily = pgTable(
|
|||||||
avgDurationMs: integer("avg_duration_ms").notNull(),
|
avgDurationMs: integer("avg_duration_ms").notNull(),
|
||||||
maxDurationMs: integer("max_duration_ms").notNull(),
|
maxDurationMs: integer("max_duration_ms").notNull(),
|
||||||
|
|
||||||
firstHitAt: timestamp("first_hit_at").notNull(),
|
firstHitAt: timestamp("first_hit_at", { withTimezone: true }).notNull(),
|
||||||
lastHitAt: timestamp("last_hit_at").notNull(),
|
lastHitAt: timestamp("last_hit_at", { withTimezone: true }).notNull(),
|
||||||
|
|
||||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
||||||
|
.defaultNow()
|
||||||
|
.notNull(),
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
unique("analytics_daily_business_route_unique").on(
|
unique("analytics_daily_business_route_unique").on(
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ export const datamart = pgTable("datamart", {
|
|||||||
active: boolean("active").default(true),
|
active: boolean("active").default(true),
|
||||||
options: text("options").default(""),
|
options: text("options").default(""),
|
||||||
public: boolean("public_access").default(false),
|
public: boolean("public_access").default(false),
|
||||||
add_date: timestamp("add_date").defaultNow(),
|
add_date: timestamp("add_date", { withTimezone: true }).defaultNow(),
|
||||||
add_user: text("add_user").default("lst-system"),
|
add_user: text("add_user").default("lst-system"),
|
||||||
upd_date: timestamp("upd_date").defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
|
||||||
upd_user: text("upd_user").default("lst-system"),
|
upd_user: text("upd_user").default("lst-system"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ export const dockDoorScanners = pgTable("dock_door_scanners", {
|
|||||||
dockId: text("dock_id"),
|
dockId: text("dock_id"),
|
||||||
active: boolean("active").default(true),
|
active: boolean("active").default(true),
|
||||||
currentLoadingOrder: text("current_loading_order").default(""),
|
currentLoadingOrder: text("current_loading_order").default(""),
|
||||||
add_date: timestamp("add_date").defaultNow(),
|
add_date: timestamp("add_date", { withTimezone: true }).defaultNow(),
|
||||||
add_user: text("add_user").default("lst-system"),
|
add_user: text("add_user").default("lst-system"),
|
||||||
upd_date: timestamp("upd_date").defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
|
||||||
upd_user: text("upd_user").default("lst-system"),
|
upd_user: text("upd_user").default("lst-system"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const invHistoricalData = pgTable("inv_historical_data", {
|
|||||||
whseId: text("whse_id").default(""),
|
whseId: text("whse_id").default(""),
|
||||||
whseName: text("whse_name").default("missing whseName"),
|
whseName: text("whse_name").default("missing whseName"),
|
||||||
upd_user: text("upd_user").default("lst-system"),
|
upd_user: text("upd_user").default("lst-system"),
|
||||||
upd_date: timestamp("upd_date").defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const invHistoricalDataSchema = createSelectSchema(invHistoricalData);
|
export const invHistoricalDataSchema = createSelectSchema(invHistoricalData);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const logs = pgTable("logs", {
|
|||||||
stack: jsonb("stack").default([]),
|
stack: jsonb("stack").default([]),
|
||||||
checked: boolean("checked").default(false),
|
checked: boolean("checked").default(false),
|
||||||
hostname: text("hostname"),
|
hostname: text("hostname"),
|
||||||
createdAt: timestamp("created_at").defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const logSchema = createSelectSchema(logs);
|
export const logSchema = createSelectSchema(logs);
|
||||||
|
|||||||
@@ -17,8 +17,12 @@ export const opendockApt = pgTable(
|
|||||||
release: integer("release").notNull().unique("opendock_apt_release_unique"),
|
release: integer("release").notNull().unique("opendock_apt_release_unique"),
|
||||||
openDockAptId: text("open_dock_apt_id").notNull(),
|
openDockAptId: text("open_dock_apt_id").notNull(),
|
||||||
appointment: jsonb("appointment").notNull().default([]),
|
appointment: jsonb("appointment").notNull().default([]),
|
||||||
upd_date: timestamp("upd_date").notNull().defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true })
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
openDockAptIdIdx: index("opendock_apt_opendock_id_idx").on(
|
openDockAptIdIdx: index("opendock_apt_opendock_id_idx").on(
|
||||||
|
|||||||
@@ -22,9 +22,13 @@ export const opendockArticleSetup = pgTable(
|
|||||||
customerDescription: text("customer_description").notNull(),
|
customerDescription: text("customer_description").notNull(),
|
||||||
loadType: loadTypeEnum("load_type").notNull().default("drop"),
|
loadType: loadTypeEnum("load_type").notNull().default("drop"),
|
||||||
dock: text("dock").notNull(),
|
dock: text("dock").notNull(),
|
||||||
upd_date: timestamp("upd_date").notNull().defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true })
|
||||||
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
upd_user: text("upd_user").notNull().default("lst-system"),
|
upd_user: text("upd_user").notNull().default("lst-system"),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
add_user: text("add_user").notNull().default("lst-system"),
|
add_user: text("add_user").notNull().default("lst-system"),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ export const opendockDockSetup = pgTable("opendock_dock_setup", {
|
|||||||
id: uuid("id").defaultRandom().primaryKey(),
|
id: uuid("id").defaultRandom().primaryKey(),
|
||||||
name: text("name").notNull(),
|
name: text("name").notNull(),
|
||||||
dockID: text("dock_id").notNull(),
|
dockID: text("dock_id").notNull(),
|
||||||
upd_date: timestamp("upd_date").notNull().defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true })
|
||||||
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
upd_user: text("upd_user").notNull().default("lst-system"),
|
upd_user: text("upd_user").notNull().default("lst-system"),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true })
|
||||||
|
.notNull()
|
||||||
|
.defaultNow(),
|
||||||
add_user: text("add_user").notNull().default("lst-system"),
|
add_user: text("add_user").notNull().default("lst-system"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,5 +7,5 @@ export const printerLog = pgTable("printer_log", {
|
|||||||
printerSN: text("printer_sn"),
|
printerSN: text("printer_sn"),
|
||||||
condition: text("condition").notNull(),
|
condition: text("condition").notNull(),
|
||||||
message: text("message"),
|
message: text("message"),
|
||||||
createdAt: timestamp("created_at").defaultNow(),
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ export const printerData = pgTable(
|
|||||||
printDelay: integer("printDelay").default(90),
|
printDelay: integer("printDelay").default(90),
|
||||||
processes: jsonb("processes").default([]),
|
processes: jsonb("processes").default([]),
|
||||||
printDelayOverride: boolean("print_delay_override").default(false), // this will be more for if we have the lot time active but want to over ride this single line for some reason
|
printDelayOverride: boolean("print_delay_override").default(false), // this will be more for if we have the lot time active but want to over ride this single line for some reason
|
||||||
add_Date: timestamp("add_Date").defaultNow(),
|
add_Date: timestamp("add_Date", { withTimezone: true }).defaultNow(),
|
||||||
upd_date: timestamp("upd_date").defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
//uniqueIndex("emailUniqueIndex").on(sql`lower(${table.email})`),
|
//uniqueIndex("emailUniqueIndex").on(sql`lower(${table.email})`),
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ export const scanUser = pgTable(
|
|||||||
role: mobileRoleEnum("role").notNull().default("user"),
|
role: mobileRoleEnum("role").notNull().default("user"),
|
||||||
active: boolean("active").default(true),
|
active: boolean("active").default(true),
|
||||||
lastScan: timestamp("last_scan").defaultNow(),
|
lastScan: timestamp("last_scan").defaultNow(),
|
||||||
add_Date: timestamp("add_Date").defaultNow(),
|
add_Date: timestamp("add_Date", { withTimezone: true }).defaultNow(),
|
||||||
upd_date: timestamp("upd_date").defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
userNotificationUnique: unique("scan_user_unique").on(
|
userNotificationUnique: unique("scan_user_unique").on(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const scanLog = pgTable("scan_log", {
|
|||||||
status: text("status"),
|
status: text("status"),
|
||||||
scannerVersion: text("scanner_version").default("0"),
|
scannerVersion: text("scanner_version").default("0"),
|
||||||
lines: jsonb("lines").default([]),
|
lines: jsonb("lines").default([]),
|
||||||
add_Date: timestamp("add_date").defaultNow(),
|
add_Date: timestamp("add_date", { withTimezone: true }).defaultNow(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const scanLogSchema = createSelectSchema(scanLog);
|
export const scanLogSchema = createSelectSchema(scanLog);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const serverData = pgTable(
|
|||||||
contactPhone: text("contact_phone"),
|
contactPhone: text("contact_phone"),
|
||||||
active: boolean("active").default(true),
|
active: boolean("active").default(true),
|
||||||
serverLoc: text("server_loc"),
|
serverLoc: text("server_loc"),
|
||||||
lastUpdated: timestamp("last_updated").defaultNow(),
|
lastUpdated: timestamp("last_updated", { withTimezone: true }).defaultNow(),
|
||||||
buildNumber: integer("build_number"),
|
buildNumber: integer("build_number"),
|
||||||
isUpgrading: boolean("is_upgrading").default(false),
|
isUpgrading: boolean("is_upgrading").default(false),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ export const settings = pgTable(
|
|||||||
settingType: settingType(),
|
settingType: settingType(),
|
||||||
seedVersion: integer("seed_version").default(1), // this is intended for if we want to update the settings.
|
seedVersion: integer("seed_version").default(1), // this is intended for if we want to update the settings.
|
||||||
add_User: text("add_User").default("LST_System").notNull(),
|
add_User: text("add_User").default("LST_System").notNull(),
|
||||||
add_Date: timestamp("add_Date").defaultNow(),
|
add_Date: timestamp("add_Date", { withTimezone: true }).defaultNow(),
|
||||||
upd_user: text("upd_User").default("LST_System").notNull(),
|
upd_user: text("upd_User").default("LST_System").notNull(),
|
||||||
upd_date: timestamp("upd_date").defaultNow(),
|
upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ import type z from "zod";
|
|||||||
export const appStats = pgTable("app_stats", {
|
export const appStats = pgTable("app_stats", {
|
||||||
id: text("id").primaryKey().default("primary"),
|
id: text("id").primaryKey().default("primary"),
|
||||||
currentBuild: integer("current_build").notNull().default(1),
|
currentBuild: integer("current_build").notNull().default(1),
|
||||||
lastBuildAt: timestamp("last_build_at"),
|
lastBuildAt: timestamp("last_build_at", { withTimezone: true }),
|
||||||
lastDeployAt: timestamp("last_deploy_at"),
|
lastDeployAt: timestamp("last_deploy_at", { withTimezone: true }),
|
||||||
building: boolean("building").notNull().default(false),
|
building: boolean("building").notNull().default(false),
|
||||||
updating: boolean("updating").notNull().default(false),
|
updating: boolean("updating").notNull().default(false),
|
||||||
lastUpdated: timestamp("last_updated").defaultNow(),
|
lastUpdated: timestamp("last_updated", { withTimezone: true }).defaultNow(),
|
||||||
meta: jsonb("meta").$type<Record<string, unknown>>().default({}),
|
meta: jsonb("meta").$type<Record<string, unknown>>().default({}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user