20 lines
594 B
TypeScript
20 lines
594 B
TypeScript
import { pgTable, text, uuid } from 'drizzle-orm/pg-core';
|
|
import { adminsTable } from './admins.ts';
|
|
import { relations } from 'drizzle-orm';
|
|
|
|
export const tokensTable = pgTable('tokens', {
|
|
id: uuid('id').defaultRandom().primaryKey(),
|
|
accessToken: text('access_token').unique(),
|
|
refreshToken: text('refresh_token').unique(),
|
|
adminId: uuid('user_id')
|
|
.notNull()
|
|
.references(() => adminsTable.id),
|
|
});
|
|
|
|
export const tokensAdmins = relations(tokensTable, ({ one }) => ({
|
|
admins: one(adminsTable, {
|
|
fields: [tokensTable.adminId],
|
|
references: [adminsTable.id],
|
|
}),
|
|
}));
|