const { PrismaClient } = require("@prisma/client"); const prisma = new PrismaClient(); async function createComponentTable() { try { console.log("πŸ”§ component_standards ν…Œμ΄λΈ” 생성 쀑..."); // ν…Œμ΄λΈ” 생성 SQL await prisma.$executeRaw` CREATE TABLE IF NOT EXISTS component_standards ( component_code VARCHAR(50) PRIMARY KEY, component_name VARCHAR(100) NOT NULL, component_name_eng VARCHAR(100), description TEXT, category VARCHAR(50) NOT NULL, icon_name VARCHAR(50), default_size JSON, component_config JSON NOT NULL, preview_image VARCHAR(255), sort_order INTEGER DEFAULT 0, is_active CHAR(1) DEFAULT 'Y', is_public CHAR(1) DEFAULT 'Y', company_code VARCHAR(50) NOT NULL, created_date TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP, created_by VARCHAR(50), updated_date TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP, updated_by VARCHAR(50) ) `; console.log("βœ… component_standards ν…Œμ΄λΈ” 생성 μ™„λ£Œ"); // 인덱슀 생성 await prisma.$executeRaw` CREATE INDEX IF NOT EXISTS idx_component_standards_category ON component_standards (category) `; await prisma.$executeRaw` CREATE INDEX IF NOT EXISTS idx_component_standards_company ON component_standards (company_code) `; console.log("βœ… 인덱슀 생성 μ™„λ£Œ"); // ν…Œμ΄λΈ” μ½”λ©˜νŠΈ μΆ”κ°€ await prisma.$executeRaw` COMMENT ON TABLE component_standards IS 'UI μ»΄ν¬λ„ŒνŠΈ ν‘œμ€€ 정보λ₯Ό μ €μž₯ν•˜λŠ” ν…Œμ΄λΈ”' `; console.log("βœ… ν…Œμ΄λΈ” μ½”λ©˜νŠΈ μΆ”κ°€ μ™„λ£Œ"); } catch (error) { console.error("❌ ν…Œμ΄λΈ” 생성 μ‹€νŒ¨:", error); throw error; } finally { await prisma.$disconnect(); } } // μ‹€ν–‰ if (require.main === module) { createComponentTable() .then(() => { console.log("πŸŽ‰ ν…Œμ΄λΈ” 생성 μ™„λ£Œ!"); process.exit(0); }) .catch((error) => { console.error("πŸ’₯ ν…Œμ΄λΈ” 생성 μ‹€νŒ¨:", error); process.exit(1); }); } module.exports = { createComponentTable };