db updates

This commit is contained in:
2024-06-16 23:59:27 -04:00
parent 99e1fc4729
commit ef7bdbba41
2 changed files with 20 additions and 7 deletions
+1
View File
@@ -2,6 +2,7 @@ import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";
import "dotenv/config";
import { sql } from "drizzle-orm";
// const connectionString = process.env.DATABASE_URL as string;
const connectionString =
+19 -7
View File
@@ -1,6 +1,7 @@
import { pgEnum, pgTable, timestamp, uuid, varchar } from "drizzle-orm/pg-core";
import { pgEnum, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
import { sql } from "drizzle-orm";
export const DateTable = pgTable("date", {
export const DateTable = pgTable("dates", {
date: timestamp("date", { withTimezone: true })
.unique()
.notNull()
@@ -16,10 +17,10 @@ export const EventVariant = pgEnum("eventVariant", [
"default",
]);
export const EventTable = pgTable("event", {
export const EventsTable = pgTable("events", {
id: uuid("eventId").primaryKey().defaultRandom(),
title: varchar("title", { length: 255 }).notNull(),
companyName: varchar("companyName", { length: 128 })
title: text("title").notNull(),
companyName: text("companyName")
.notNull()
.unique()
.references(() => SymbolsTable.symbol),
@@ -31,6 +32,17 @@ export const EventTable = pgTable("event", {
});
export const SymbolsTable = pgTable("symbols", {
symbol: varchar("symbol", { length: 16 }).notNull().primaryKey().unique(),
companyName: varchar("companyName", { length: 128 }).notNull().unique(),
symbol: text("symbol").notNull().primaryKey().unique(),
companyName: text("companyName").notNull().unique(),
});
// export const ThemeMode = pgEnum("themeMode", ["light", "dark", "system"]);
// export const UserPreferencesTable = pgTable("userPreferences", {
// // userId: text("userId").primaryKey().notNull().unique().references(() => U),
// theme: ThemeMode("theme").default("dark").notNull(),
// });
// export const UsersTable = pgTable("users", {
// userId: text("userId"),
// });