Files
Avtex/scripts/seed_canvas.cjs
T

43 lines
1.8 KiB
JavaScript

const { PrismaClient } = require('@prisma/client')
const { PrismaPg } = require('@prisma/adapter-pg')
const { Pool } = require('pg')
const connectionString = process.env.DATABASE_URL
const pool = new Pool({ connectionString })
const adapter = new PrismaPg(pool)
const prisma = new PrismaClient({ adapter })
async function main() {
const adminId = 'GqbpMyUW0NaxjIy5nvCiXCiQu9t2'
console.log('📦 Seeding Mindmaps to PostgreSQL...')
// 1. Создаем основную карту "Обзор Проекта XFlow"
const xflowCanvas = await prisma.canvas.upsert({
where: { id: 'xflow-project' },
update: {},
create: {
id: 'xflow-project',
name: 'Обзор Проекта XFlow',
ownerId: adminId,
isPublic: true,
nodes: [
{ id: 'arch-1', type: 'text', x: 100, y: 100, width: 320, height: 180, text: '# 🏗️ Основная Архитектура\n\n- **Nuxt 3** - Vue 3 фреймворк\n- **TailwindCSS** - Стилизация\n- **Vue Flow** - Движок канваса\n- **Firebase** - Аутентификация\n- **PostgreSQL + Prisma** - Хранение данных\n- **PWA** - Progressive Web App' },
{ id: 'be-1', type: 'text', x: 500, y: 250, width: 280, height: 160, text: '# ⚙️ Backend API\n\n- `/api/canvas/*` - Prisma CRUD\n- `/api/groups/*` - Групповой доступ\n- `/api/admin/*` - Админка\n- **Gitea Actions** - Автодеплой' }
],
edges: [
{ id: 'e1', fromNode: 'arch-1', fromSide: 'right', toNode: 'be-1', toSide: 'left' }
]
}
})
console.log('✅ Success! Mindmap "Обзор Проекта XFlow" is now in the database.')
}
main()
.catch(console.error)
.finally(async () => {
await prisma.$disconnect()
await pool.end()
})