Private
Public Access
1
0
Files
Kanban/prisma/seed.ts
T
Catherine Renelle 6ed0349507 Phase 7: Search, filters, templates, and archive UI
Add full-text card search (PostgreSQL tsvector + GIN index) with navbar
SearchBar, client-side board filters (label/assignee/due date), board
templates (3 system templates + save-as-template API), and archive
toggle for both board listing and board view.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 00:42:20 -05:00

104 lines
2.3 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
import bcrypt from 'bcrypt';
const prisma = new PrismaClient();
async function main() {
console.log('Seeding database...');
// The app auto-creates a tenant on first request,
// but the seed ensures an admin user exists.
let tenant = await prisma.tenant.findFirst();
if (!tenant) {
tenant = await prisma.tenant.create({
data: {
name: 'Pounce',
slug: 'default'
}
});
console.log(` Created tenant: ${tenant.name} (${tenant.id})`);
} else {
console.log(` Existing tenant: ${tenant.name} (${tenant.id})`);
}
// Create admin user
const passwordHash = await bcrypt.hash('admin123', 12);
await prisma.user.upsert({
where: { tenantId_email: { tenantId: tenant.id, email: 'admin@example.com' } },
update: {},
create: {
tenantId: tenant.id,
email: 'admin@example.com',
name: 'Admin',
passwordHash,
globalRole: 'SITE_ADMIN',
tenantRole: 'ADMIN'
}
});
// Seed system templates (tenantId: null)
const systemTemplates = [
{
name: 'Basic Kanban',
description: 'Simple three-column workflow',
template: { columns: [{ title: 'To Do' }, { title: 'In Progress' }, { title: 'Done' }] }
},
{
name: 'Scrum Sprint',
description: 'Sprint-based agile workflow',
template: {
columns: [
{ title: 'Backlog' },
{ title: 'Sprint' },
{ title: 'In Review' },
{ title: 'Done' }
]
}
},
{
name: 'Bug Tracker',
description: 'Issue lifecycle tracking',
template: {
columns: [
{ title: 'New' },
{ title: 'Confirmed' },
{ title: 'In Progress' },
{ title: 'Resolved' },
{ title: 'Closed' }
]
}
}
];
for (const tpl of systemTemplates) {
const existing = await prisma.boardTemplate.findFirst({
where: { tenantId: null, name: tpl.name }
});
if (!existing) {
await prisma.boardTemplate.create({
data: {
tenantId: null,
name: tpl.name,
description: tpl.description,
template: tpl.template
}
});
console.log(` Created system template: ${tpl.name}`);
} else {
console.log(` System template exists: ${tpl.name}`);
}
}
console.log('Seed complete.');
console.log(' Admin: admin@example.com / admin123');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});