sveltekit-bsky-handles/src/lib/server/db/schema.ts
2025-04-06 20:15:45 +03:00

28 lines
819 B
TypeScript

import { sql } from 'drizzle-orm';
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
export const user = sqliteTable('user', {
id: text('id').primaryKey(),
did: text('did').notNull(),
handle: text('handle').notNull(),
created_at: text('created_at')
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
updated_at: text('updated_at')
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
username: text('username').notNull().unique(),
passwordHash: text('password_hash').notNull()
});
export const session = sqliteTable('session', {
id: text('id').primaryKey(),
userId: text('user_id')
.notNull()
.references(() => user.id),
expiresAt: integer('expires_at', { mode: 'timestamp' }).notNull()
});
export type Session = typeof session.$inferSelect;
export type User = typeof user.$inferSelect;