Initial implementation: multi-tenant Kanban board (Phase 1)
Complete Phase 1 foundation with working board, column, and card CRUD: - SvelteKit + TypeScript + Tailwind CSS v4 + adapter-node - Full Prisma schema with 18 tables (tenants, users, boards, columns, cards, etc.) - Multi-tenant architecture with hostname-based tenant resolution - Email/password auth with bcrypt + session cookies - Board/Column/Card API routes with full CRUD - Fractional indexing for drag-and-drop ordering - Board view with svelte-dnd-action for column and card drag-and-drop - Card modal with inline editing - Auth pages (login, register) - Board listing with create form - RLS policies SQL script for tenant isolation - Prisma RLS client extensions (forTenant/bypassRLS) - Permission helpers (canEditBoard, canManageMembers, etc.) - Socket.IO server setup (dev Vite plugin + production Express server) - Client-side socket store for real-time updates - Docker Compose (app + PostgreSQL 16) + multi-stage Dockerfile - Database seed script (default tenant + admin user) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('Seeding database...');
|
||||
|
||||
// Create default tenant
|
||||
const tenant = await prisma.tenant.upsert({
|
||||
where: { slug: 'default' },
|
||||
update: {},
|
||||
create: {
|
||||
name: 'Default Workspace',
|
||||
slug: 'default'
|
||||
}
|
||||
});
|
||||
|
||||
// Map localhost to default tenant
|
||||
const hostnames = ['localhost', '127.0.0.1'];
|
||||
for (const hostname of hostnames) {
|
||||
await prisma.tenantHostname.upsert({
|
||||
where: { hostname },
|
||||
update: {},
|
||||
create: {
|
||||
hostname,
|
||||
tenantId: tenant.id,
|
||||
isPrimary: hostname === 'localhost'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 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'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Seed complete.');
|
||||
console.log(` Tenant: ${tenant.name} (${tenant.id})`);
|
||||
console.log(' Hostnames: localhost, 127.0.0.1');
|
||||
console.log(' Admin: admin@example.com / admin123');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user