|
|
@ -1,5 +1,5 @@ |
|
|
import { sql, relations } from 'drizzle-orm'; |
|
|
import { sql, relations } from 'drizzle-orm'; |
|
|
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'; |
|
|
import { int, sqliteTable, text, uniqueIndex } from 'drizzle-orm/sqlite-core'; |
|
|
|
|
|
|
|
|
import { wgInterface } from '#db/repositories/interface/schema'; |
|
|
import { wgInterface } from '#db/repositories/interface/schema'; |
|
|
import { oneTimeLink } from '#db/repositories/oneTimeLink/schema'; |
|
|
import { oneTimeLink } from '#db/repositories/oneTimeLink/schema'; |
|
|
@ -7,7 +7,9 @@ import { user } from '#db/repositories/user/schema'; |
|
|
|
|
|
|
|
|
/** null means use value from userConfig */ |
|
|
/** null means use value from userConfig */ |
|
|
|
|
|
|
|
|
export const client = sqliteTable('clients_table', { |
|
|
export const client = sqliteTable( |
|
|
|
|
|
'clients_table', |
|
|
|
|
|
{ |
|
|
id: int().primaryKey({ autoIncrement: true }), |
|
|
id: int().primaryKey({ autoIncrement: true }), |
|
|
userId: int('user_id') |
|
|
userId: int('user_id') |
|
|
.notNull() |
|
|
.notNull() |
|
|
@ -37,7 +39,9 @@ export const client = sqliteTable('clients_table', { |
|
|
.$type<string[]>() |
|
|
.$type<string[]>() |
|
|
.notNull(), |
|
|
.notNull(), |
|
|
// Firewall-enforced allowed IPs (null = use allowedIps)
|
|
|
// Firewall-enforced allowed IPs (null = use allowedIps)
|
|
|
firewallIps: text('firewall_ips', { mode: 'json' }).$type<string[] | null>(), |
|
|
firewallIps: text('firewall_ips', { mode: 'json' }).$type< |
|
|
|
|
|
string[] | null |
|
|
|
|
|
>(), |
|
|
persistentKeepalive: int('persistent_keepalive').notNull(), |
|
|
persistentKeepalive: int('persistent_keepalive').notNull(), |
|
|
mtu: int().notNull(), |
|
|
mtu: int().notNull(), |
|
|
jC: int('j_c'), |
|
|
jC: int('j_c'), |
|
|
@ -58,7 +62,14 @@ export const client = sqliteTable('clients_table', { |
|
|
.notNull() |
|
|
.notNull() |
|
|
.default(sql`(CURRENT_TIMESTAMP)`) |
|
|
.default(sql`(CURRENT_TIMESTAMP)`) |
|
|
.$onUpdate(() => sql`(CURRENT_TIMESTAMP)`), |
|
|
.$onUpdate(() => sql`(CURRENT_TIMESTAMP)`), |
|
|
}); |
|
|
}, |
|
|
|
|
|
(table) => [ |
|
|
|
|
|
uniqueIndex('public_key_interface_unique').on( |
|
|
|
|
|
table.publicKey, |
|
|
|
|
|
table.interfaceId |
|
|
|
|
|
), |
|
|
|
|
|
] |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
export const clientsRelations = relations(client, ({ one }) => ({ |
|
|
export const clientsRelations = relations(client, ({ one }) => ({ |
|
|
oneTimeLink: one(oneTimeLink, { |
|
|
oneTimeLink: one(oneTimeLink, { |
|
|
|