@@ -1,7 +1,7 @@
|
||||
import { sql, relations } from 'drizzle-orm';
|
||||
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
||||
|
||||
import { oneTimeLink, user } from '../../schema';
|
||||
import { oneTimeLink, user, wgInterface } from '../../schema';
|
||||
|
||||
/** null means use value from userConfig */
|
||||
|
||||
@@ -13,6 +13,12 @@ export const client = sqliteTable('clients_table', {
|
||||
onDelete: 'restrict',
|
||||
onUpdate: 'cascade',
|
||||
}),
|
||||
interfaceId: text('interface_id')
|
||||
.notNull()
|
||||
.references(() => wgInterface.name, {
|
||||
onDelete: 'cascade',
|
||||
onUpdate: 'cascade',
|
||||
}),
|
||||
name: text().notNull(),
|
||||
ipv4Address: text('ipv4_address').notNull().unique(),
|
||||
ipv6Address: text('ipv6_address').notNull().unique(),
|
||||
@@ -51,4 +57,8 @@ export const clientsRelations = relations(client, ({ one }) => ({
|
||||
fields: [client.userId],
|
||||
references: [user.id],
|
||||
}),
|
||||
interface: one(wgInterface, {
|
||||
fields: [client.interfaceId],
|
||||
references: [wgInterface.name],
|
||||
}),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user