Skip to content

Commit

Permalink
feature(database): add user credential schema
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfriesen committed Jan 8, 2025
1 parent a1b7e5d commit 6c3c5c3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/timer/server/database/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { sessions } from './session';
export { users } from './user';
export { userCredentials } from './user-credential';

export { times } from './time';
export { projects } from './project';
Expand Down
26 changes: 26 additions & 0 deletions apps/timer/server/database/user-credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
boolean,
integer,
json,
pgTable,
text,
unique,
uuid,
} from 'drizzle-orm/pg-core';

import { users } from './user';

export const userCredentials = pgTable(
'user_credential',
{
id: text('id').notNull().unique(),
userId: uuid('user_id')
.references(() => users.id, { onDelete: 'cascade' })
.notNull(),
publicKey: text('public_key').notNull(),
counter: integer('counter').notNull(),
backedUp: boolean('backed_up').notNull(),
transports: json('transports').notNull().$type<object[]>(),
},
(table) => [unique().on(table.userId, table.id)]
);

0 comments on commit 6c3c5c3

Please sign in to comment.