mirror of https://github.com/wg-easy/wg-easy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
880 B
27 lines
880 B
import { sql, relations } from 'drizzle-orm';
|
|
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
|
|
|
import { clients } from '../../schema';
|
|
|
|
export const oneTimeLinks = sqliteTable('one_time_links_table', {
|
|
id: int().primaryKey({ autoIncrement: true }),
|
|
oneTimeLink: text('one_time_link').notNull(),
|
|
expiresAt: text('expires_at').notNull(),
|
|
clientId: int()
|
|
.notNull()
|
|
.references(() => clients.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
|
|
createdAt: text('created_at')
|
|
.notNull()
|
|
.default(sql`(CURRENT_TIMESTAMP)`),
|
|
updatedAt: text('updated_at')
|
|
.notNull()
|
|
.default(sql`(CURRENT_TIMESTAMP)`)
|
|
.$onUpdate(() => sql`(CURRENT_TIMESTAMP)`),
|
|
});
|
|
|
|
export const oneTimeLinksRelations = relations(oneTimeLinks, ({ one }) => ({
|
|
client: one(clients, {
|
|
fields: [oneTimeLinks.clientId],
|
|
references: [clients.id],
|
|
}),
|
|
}));
|
|
|