mirror of
https://github.com/michivonah/themepark-assistant.git
synced 2025-12-22 22:16:29 +01:00
setup drizzle for d1 & create db schema
This commit is contained in:
parent
3c197d8ebe
commit
fc3b1d1af5
8 changed files with 824 additions and 12 deletions
45
api/src/db/schema.ts
Normal file
45
api/src/db/schema.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { integer, text, sqliteTable } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const attraction = sqliteTable('attraction', {
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
name: text().notNull(),
|
||||
apiCode: integer(),
|
||||
themeparkId: integer().notNull().references(() => themepark.id)
|
||||
})
|
||||
|
||||
export const attractionNotification = sqliteTable('attraction_notification', {
|
||||
id: integer().primaryKey({ autoIncrement: true}),
|
||||
userId: integer().notNull().references(() => user.id),
|
||||
attractionId: integer().notNull().references(() => attraction.id),
|
||||
notificationMethodId: integer().notNull().references(() => notificationMethod.id)
|
||||
})
|
||||
|
||||
export const logbook = sqliteTable('logbook', {
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
userId: integer().notNull().references(() => user.id),
|
||||
attractionId: integer().notNull().references(() => attraction.id),
|
||||
timestamp: integer().notNull(), // unix timecode
|
||||
expectedWaittime: integer(),
|
||||
realWaittime: integer()
|
||||
})
|
||||
|
||||
export const notificationMethod = sqliteTable('notification', {
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
webhookUrl: text().notNull(),
|
||||
shownName: text().notNull(),
|
||||
userId: integer().notNull().references(() => user.id)
|
||||
})
|
||||
|
||||
export const themepark = sqliteTable('themepark', {
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
name: text().notNull(),
|
||||
countrycode: text().notNull(),
|
||||
website: text(),
|
||||
apiName: text()
|
||||
})
|
||||
|
||||
export const user = sqliteTable('user', {
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
username: text().notNull(),
|
||||
isActive: integer({ mode: 'boolean' }).default(false)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue