diff --git a/CHANGELOG.md b/CHANGELOG.md index 36312c0..ed1cf36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ Pre-1.0 versions treat MINOR as feature releases and PATCH as bug fixes. --- +## [0.6.6] — 2026-04-12 + +### Bug Fixes +- **`seed.ts` skips admin on re-run** — `findUnique` + `create` meant re-running the seed after a failed install left the admin password in `.env` out of sync with the hashed password in the database. Changed to `upsert` so the seed always writes the current `.env` password, making re-runs safe. + +--- + ## [0.6.5] — 2026-04-12 ### Bug Fixes diff --git a/package.json b/package.json index d68b49b..a3ff1a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nixpanel-server", - "version": "0.6.5", + "version": "0.6.6", "private": true, "workspaces": [ "server", diff --git a/server/src/app.ts b/server/src/app.ts index 9c430ad..1d2d499 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -73,7 +73,7 @@ export async function buildApp() { fastify.get('/api/health', async () => ({ status: 'ok', - version: '0.6.5', + version: '0.6.6', timestamp: new Date().toISOString(), })) diff --git a/server/src/db/seed.ts b/server/src/db/seed.ts index c315aac..d272896 100644 --- a/server/src/db/seed.ts +++ b/server/src/db/seed.ts @@ -7,19 +7,14 @@ const prisma = new PrismaClient() async function main() { console.log('Seeding database...') - // Admin user - const existing = await prisma.adminUser.findUnique({ where: { username: config.admin.username } }) - if (!existing) { - const hash = await bcrypt.hash(config.admin.password, 12) - await prisma.adminUser.create({ - data: { - username: config.admin.username, - passwordHash: hash, - email: config.admin.email, - }, - }) - console.log(`Created admin user: ${config.admin.username}`) - } + // Admin user — upsert so re-runs always sync the password from .env + const hash = await bcrypt.hash(config.admin.password, 12) + await prisma.adminUser.upsert({ + where: { username: config.admin.username }, + update: { passwordHash: hash, email: config.admin.email }, + create: { username: config.admin.username, passwordHash: hash, email: config.admin.email }, + }) + console.log(`Admin user ready: ${config.admin.username}`) // Default packages const packages = [