Skip to content

Commit

Permalink
perf(api): optimize db schema
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfriesen committed Jan 8, 2025
1 parent 6c3c5c3 commit 096df00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions apps/timer/server/database/user-credential.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
boolean,
integer,
json,
jsonb,
pgTable,
primaryKey,
text,
unique,
uuid,
} from 'drizzle-orm/pg-core';

Expand All @@ -20,7 +20,7 @@ export const userCredentials = pgTable(
publicKey: text('public_key').notNull(),
counter: integer('counter').notNull(),
backedUp: boolean('backed_up').notNull(),
transports: json('transports').notNull().$type<object[]>(),
transports: jsonb('transports').notNull().$type<object[]>(),
},
(table) => [unique().on(table.userId, table.id)]
(table) => [primaryKey({ columns: [table.userId, table.id] })]
);
11 changes: 5 additions & 6 deletions apps/timer/server/database/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
pgTable,
uuid,
varchar,
boolean,
uniqueIndex,
timestamp,
} from 'drizzle-orm/pg-core';
import { timestampColumns } from './common';

Expand All @@ -14,13 +14,12 @@ export const users = pgTable(
id: uuid('id').defaultRandom().notNull().primaryKey(),

name: varchar('name', { length: 150 }).notNull(),
description: text('description').notNull().default(''),

email: text('email').notNull().unique(),
emailVerified: boolean('email_verified').notNull().default(false),

passwordHash: text('password_hash').notNull(),
passwordSalt: text('password_salt').notNull(),
emailVerified: timestamp('email_verified', {
mode: 'date',
withTimezone: true,
}),

...timestampColumns(),
},
Expand Down

0 comments on commit 096df00

Please sign in to comment.