Fix bootstrap-recreate: use static imports and error handling
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Elysia, t } from 'elysia';
|
||||
import { db } from '../db';
|
||||
import { tasks, projects, hammerWebhooks, users, activityLog } from '../db/schema';
|
||||
import { tasks, projects, hammerWebhooks, users, activityLog, accounts, sessions } from '../db/schema';
|
||||
import { eq, and, asc, desc, sql } from 'drizzle-orm';
|
||||
import crypto from 'crypto';
|
||||
import { auth } from '../lib/auth';
|
||||
@@ -423,10 +423,15 @@ export const hammerRoutes = new Elysia({ prefix: '/hammer' })
|
||||
where: eq(users.email, email),
|
||||
});
|
||||
if (existing) {
|
||||
const { accounts, sessions } = await import('../db/schema');
|
||||
await db.delete(accounts).where(eq(accounts.userId, existing.id));
|
||||
await db.delete(sessions).where(eq(sessions.userId, existing.id));
|
||||
await db.delete(users).where(eq(users.id, existing.id));
|
||||
try {
|
||||
await db.delete(accounts).where(eq(accounts.userId, existing.id));
|
||||
} catch(e) { console.error('accounts delete:', e); }
|
||||
try {
|
||||
await db.delete(sessions).where(eq(sessions.userId, existing.id));
|
||||
} catch(e) { console.error('sessions delete:', e); }
|
||||
try {
|
||||
await db.delete(users).where(eq(users.id, existing.id));
|
||||
} catch(e) { console.error('users delete:', e); }
|
||||
}
|
||||
const result = await auth.api.signUpEmail({
|
||||
body: { email, password, name },
|
||||
|
||||
Reference in New Issue
Block a user