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