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.
30 lines
870 B
30 lines
870 B
import { sql, relations } from 'drizzle-orm';
|
|
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
|
|
|
import { client } from '../../schema';
|
|
|
|
export const oneTimeLink = sqliteTable('one_time_links_table', {
|
|
/** same as `client.id` */
|
|
id: int()
|
|
.primaryKey()
|
|
.references(() => client.id, {
|
|
onDelete: 'cascade',
|
|
onUpdate: 'cascade',
|
|
}),
|
|
oneTimeLink: text('one_time_link').notNull().unique(),
|
|
expiresAt: text('expires_at').notNull(),
|
|
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(oneTimeLink, ({ one }) => ({
|
|
client: one(client, {
|
|
fields: [oneTimeLink.id],
|
|
references: [client.id],
|
|
}),
|
|
}));
|
|
|