|
|
@ -1,5 +1,6 @@ |
|
|
|
import { sql } from 'drizzle-orm'; |
|
|
|
import { sql, relations } from 'drizzle-orm'; |
|
|
|
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'; |
|
|
|
|
|
|
|
import { oneTimeLinks } from './oneTimeLinks'; |
|
|
|
|
|
|
|
export const clients = sqliteTable('clients_table', { |
|
|
@ -11,12 +12,13 @@ export const clients = sqliteTable('clients_table', { |
|
|
|
publicKey: text('public_key').notNull(), |
|
|
|
preSharedKey: text('pre_shared_key').notNull(), |
|
|
|
expiresAt: text('expires_at'), |
|
|
|
allowedIps: text('allowed_ips', { mode: 'json' }).notNull(), |
|
|
|
serverAllowedIps: text('server_allowed_ips', { mode: 'json' }).notNull(), |
|
|
|
oneTimeLink: int('one_time_link').references(() => oneTimeLinks.id), |
|
|
|
allowedIps: text('allowed_ips', { mode: 'json' }).$type<string[]>().notNull(), |
|
|
|
serverAllowedIps: text('server_allowed_ips', { mode: 'json' }) |
|
|
|
.$type<string[]>() |
|
|
|
.notNull(), |
|
|
|
persistentKeepalive: int('persistent_keepalive').notNull(), |
|
|
|
mtu: int().notNull(), |
|
|
|
dns: text({ mode: 'json' }).notNull(), |
|
|
|
dns: text({ mode: 'json' }).$type<string[]>().notNull(), |
|
|
|
enabled: int({ mode: 'boolean' }).notNull(), |
|
|
|
createdAt: text('created_at') |
|
|
|
.notNull() |
|
|
@ -26,3 +28,10 @@ export const clients = sqliteTable('clients_table', { |
|
|
|
.default(sql`(CURRENT_TIMESTAMP)`) |
|
|
|
.$onUpdate(() => sql`(CURRENT_TIMESTAMP)`), |
|
|
|
}); |
|
|
|
|
|
|
|
export const clientsRelations = relations(clients, ({ one }) => ({ |
|
|
|
oneTimeLink: one(oneTimeLinks, { |
|
|
|
fields: [clients.id], |
|
|
|
references: [oneTimeLinks.clientId], |
|
|
|
}), |
|
|
|
})); |
|
|
|