Files
sst_site/.history/scripts/init-db_20251019202258.js
2025-10-22 21:22:44 +09:00

496 lines
25 KiB
JavaScript

#!/usr/bin/env node
/**
* Database initialization script for SmartSolTech
* Creates initial admin user and sample data for PostgreSQL
*/
const { sequelize } = require('../config/database');
require('dotenv').config();
// Import models
const { User, Service, Portfolio, SiteSettings } = require('../models');
// Configuration
const ADMIN_EMAIL = process.env.ADMIN_EMAIL || 'admin@smartsoltech.kr';
const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD || 'admin123456';
async function initializeDatabase() {
try {
console.log('🔄 Connecting to PostgreSQL...');
await sequelize.authenticate();
console.log('✅ Connected to PostgreSQL');
// Sync database (create tables)
console.log('🔄 Syncing database schema...');
await sequelize.sync({ force: false });
console.log('✅ Database schema synchronized');
// Create admin user
await createAdminUser();
// Create sample services
await createSampleServices();
// Create sample portfolio items
await createSamplePortfolio();
// Create site settings
await createSiteSettings();
console.log('🎉 Database initialization completed successfully!');
console.log(`📧 Admin login: ${ADMIN_EMAIL}`);
console.log(`🔑 Admin password: ${ADMIN_PASSWORD}`);
console.log('⚠️ Please change the admin password after first login!');
} catch (error) {
console.error('❌ Database initialization failed:', error);
process.exit(1);
} finally {
await sequelize.close();
console.log('🔌 Database connection closed');
process.exit(0);
}
}
async function createAdminUser() {
try {
const existingAdmin = await User.findOne({
where: { email: ADMIN_EMAIL }
});
if (existingAdmin) {
console.log('👤 Admin user already exists, skipping...');
return;
}
const adminUser = await User.create({
name: 'Administrator',
email: ADMIN_EMAIL,
password: ADMIN_PASSWORD,
role: 'admin',
isActive: true
});
console.log('✅ Admin user created successfully');
} catch (error) {
console.error('❌ Error creating admin user:', error);
throw error;
}
}
async function createSampleServices() {
try {
const existingServices = await Service.count();
if (existingServices > 0) {
console.log('🛠️ Services already exist, skipping...');
return;
}
const services = [
{
name: '웹 개발',
description: '현대적이고 반응형인 웹사이트와 웹 애플리케이션을 개발합니다. React, Node.js, MongoDB 등 최신 기술 스택을 활용하여 성능과 사용자 경험을 최적화합니다.',
shortDescription: '현대적이고 반응형 웹사이트 및 웹 애플리케이션 개발',
icon: 'fas fa-code',
category: 'development',
features: [
{ name: '반응형 디자인', description: '모든 디바이스에서 완벽하게 작동', included: true },
{ name: 'SEO 최적화', description: '검색엔진 최적화로 더 많은 방문자 유치', included: true },
{ name: '성능 최적화', description: '빠른 로딩 속도와 원활한 사용자 경험', included: true },
{ name: '보안 강화', description: '최신 보안 기술로 안전한 웹사이트', included: true },
{ name: '유지보수', description: '6개월 무료 유지보수 지원', included: true }
],
pricing: {
basePrice: 500000,
currency: 'KRW',
priceType: 'project',
priceRange: { min: 500000, max: 5000000 }
},
estimatedTime: { min: 2, max: 8, unit: 'weeks' },
featured: true,
isActive: true,
order: 1,
tags: ['React', 'Node.js', 'MongoDB', 'Express', 'JavaScript', 'HTML', 'CSS']
},
{
name: '모바일 앱 개발',
description: 'iOS와 Android 플랫폼을 위한 네이티브 및 크로스플랫폼 모바일 애플리케이션을 개발합니다. React Native, Flutter 등을 활용하여 효율적인 개발을 진행합니다.',
shortDescription: 'iOS/Android 네이티브 및 크로스플랫폼 앱 개발',
icon: 'fas fa-mobile-alt',
category: 'development',
features: [
{ name: '크로스플랫폼 개발', description: 'iOS와 Android 동시 지원', included: true },
{ name: '네이티브 성능', description: '최적화된 성능과 사용자 경험', included: true },
{ name: '푸시 알림', description: '실시간 푸시 알림 시스템', included: true },
{ name: '오프라인 지원', description: '인터넷 연결 없이도 기본 기능 사용 가능', included: false },
{ name: '앱스토어 등록', description: '앱스토어 및 플레이스토어 등록 지원', included: true }
],
pricing: {
basePrice: 800000,
currency: 'KRW',
priceType: 'project',
priceRange: { min: 800000, max: 8000000 }
},
estimatedTime: { min: 4, max: 16, unit: 'weeks' },
featured: true,
isActive: true,
order: 2,
tags: ['React Native', 'Flutter', 'iOS', 'Android', 'Swift', 'Kotlin', 'JavaScript']
},
{
name: 'UI/UX 디자인',
description: '사용자 중심의 직관적이고 아름다운 인터페이스를 디자인합니다. 사용자 경험 연구와 프로토타이핑을 통해 최적의 디자인 솔루션을 제공합니다.',
shortDescription: '사용자 중심의 직관적이고 아름다운 인터페이스 디자인',
icon: 'fas fa-palette',
category: 'design',
features: [
{ name: '사용자 경험 연구', description: '타겟 사용자 분석 및 페르소나 설정', included: true },
{ name: '와이어프레임', description: '정보 구조와 레이아웃 설계', included: true },
{ name: '프로토타이핑', description: '인터랙티브 프로토타입 제작', included: true },
{ name: '비주얼 디자인', description: '브랜드에 맞는 시각적 디자인', included: true },
{ name: '디자인 시스템', description: '일관된 디자인을 위한 가이드라인', included: false }
],
pricing: {
basePrice: 300000,
currency: 'KRW',
priceType: 'project',
priceRange: { min: 300000, max: 2000000 }
},
estimatedTime: { min: 1, max: 6, unit: 'weeks' },
featured: true,
isActive: true,
order: 3,
tags: ['Figma', 'Sketch', 'Adobe XD', 'Photoshop', 'Illustrator', 'Prototyping']
},
{
name: '디지털 마케팅',
description: 'SEO, 소셜미디어 마케팅, 온라인 광고를 통해 디지털 마케팅 전략을 수립하고 실행합니다. 데이터 분석을 통한 지속적인 최적화를 제공합니다.',
shortDescription: 'SEO, 소셜미디어, 온라인 광고를 통한 디지털 마케팅',
icon: 'fas fa-chart-line',
category: 'marketing',
features: [
{ name: 'SEO 최적화', description: '검색엔진 상위 노출을 위한 최적화', included: true },
{ name: '소셜미디어 관리', description: '페이스북, 인스타그램, 유튜브 관리', included: true },
{ name: '구글 광고', description: '구글 애즈를 통한 타겟 광고', included: true },
{ name: '콘텐츠 마케팅', description: '블로그 및 콘텐츠 제작', included: false },
{ name: '분석 및 리포팅', description: '마케팅 성과 분석 및 보고서', included: true }
],
pricing: {
basePrice: 200000,
currency: 'KRW',
priceType: 'project',
priceRange: { min: 200000, max: 1500000 }
},
estimatedTime: { min: 2, max: 12, unit: 'weeks' },
featured: true,
isActive: true,
order: 4,
tags: ['SEO', 'Google Ads', 'Facebook Ads', 'Analytics', 'Social Media', 'Content Marketing']
},
{
name: '브랜딩',
description: '기업의 정체성을 반영하는 로고, 브랜드 가이드라인, 마케팅 자료를 디자인합니다. 일관된 브랜드 이미지로 브랜드 가치를 높입니다.',
shortDescription: '로고, 브랜드 가이드라인, 마케팅 자료 디자인',
icon: 'fas fa-copyright',
category: 'design',
features: [
{ name: '로고 디자인', description: '기업 정체성을 반영한 로고 제작', included: true },
{ name: '브랜드 가이드라인', description: '색상, 폰트, 사용법 가이드', included: true },
{ name: '명함 디자인', description: '브랜드에 맞는 명함 디자인', included: true },
{ name: '브로슈어 디자인', description: '회사 소개 브로슈어 제작', included: false },
{ name: '웹 브랜딩', description: '웹사이트 브랜딩 요소 적용', included: false }
],
pricing: {
basePrice: 400000,
currency: 'KRW',
priceType: 'project',
priceRange: { min: 400000, max: 2500000 }
},
estimatedTime: { min: 2, max: 8, unit: 'weeks' },
featured: false,
isActive: true,
order: 5,
tags: ['Logo Design', 'Brand Identity', 'Graphic Design', 'Corporate Design']
},
{
name: '기술 컨설팅',
description: '기업의 디지털 전환과 기술 도입을 위한 전문적인 컨설팅을 제공합니다. 기술 아키텍처 설계부터 구현 전략까지 포괄적으로 지원합니다.',
shortDescription: '디지털 전환 및 기술 도입을 위한 전문 컨설팅',
icon: 'fas fa-lightbulb',
category: 'consulting',
features: [
{ name: '기술 분석', description: '현재 기술 스택 분석 및 개선안 제시', included: true },
{ name: '아키텍처 설계', description: '확장 가능한 시스템 아키텍처 설계', included: true },
{ name: '개발 프로세스 개선', description: '효율적인 개발 워크플로우 구축', included: true },
{ name: '팀 교육', description: '개발팀 대상 기술 교육', included: false },
{ name: '지속적인 지원', description: '프로젝트 완료 후 지속적인 기술 지원', included: false }
],
pricing: {
basePrice: 150000,
currency: 'KRW',
priceType: 'hourly',
priceRange: { min: 150000, max: 500000 }
},
estimatedTime: { min: 1, max: 4, unit: 'weeks' },
featured: false,
isActive: true,
order: 6,
tags: ['Architecture', 'Strategy', 'Process', 'Training', 'Consultation']
}
];
await Service.bulkCreate(services);
console.log('✅ Sample services created successfully');
} catch (error) {
console.error('❌ Error creating sample services:', error);
throw error;
}
}
async function createSamplePortfolio() {
try {
const existingPortfolio = await Portfolio.count();
if (existingPortfolio > 0) {
console.log('🎨 Portfolio items already exist, skipping...');
return;
}
const portfolioItems = [
{
title: 'E-commerce 플랫폼',
description: '현대적인 온라인 쇼핑몰 플랫폼을 개발했습니다. React와 Node.js를 활용하여 높은 성능과 사용자 경험을 제공하며, 결제 시스템과 재고 관리 기능을 포함합니다.',
shortDescription: '반응형 온라인 쇼핑몰 플랫폼 개발',
category: 'web-development',
technologies: ['React', 'Node.js', 'MongoDB', 'Express', 'Stripe', 'AWS'],
images: [
{ url: '/images/portfolio/ecommerce-1.jpg', alt: 'E-commerce 메인페이지', isPrimary: true },
{ url: '/images/portfolio/ecommerce-2.jpg', alt: '상품 상세페이지', isPrimary: false },
{ url: '/images/portfolio/ecommerce-3.jpg', alt: '장바구니 페이지', isPrimary: false }
],
clientName: '패션 브랜드 ABC',
projectUrl: 'https://example-ecommerce.com',
status: 'completed',
featured: true,
publishedAt: new Date('2024-01-15'),
completedAt: new Date('2024-01-10'),
isPublished: true,
viewCount: 150,
likes: 25,
order: 1,
seo: {
metaTitle: 'E-commerce 플랫폼 개발 프로젝트',
metaDescription: '현대적인 온라인 쇼핑몰 플랫폼 개발 사례',
keywords: ['E-commerce', 'React', 'Node.js', '온라인쇼핑몰']
}
},
{
title: '모바일 피트니스 앱',
description: 'React Native를 사용하여 크로스플랫폼 피트니스 애플리케이션을 개발했습니다. 운동 계획, 칼로리 추적, 소셜 기능을 포함하여 사용자들의 건강한 라이프스타일을 지원합니다.',
shortDescription: '건강 관리를 위한 크로스플랫폼 모바일 앱',
category: 'mobile-app',
technologies: ['React Native', 'Redux', 'Firebase', 'Node.js', 'PostgreSQL'],
images: [
{ url: '/images/portfolio/fitness-1.jpg', alt: '피트니스 앱 메인화면', isPrimary: true },
{ url: '/images/portfolio/fitness-2.jpg', alt: '운동 계획 화면', isPrimary: false },
{ url: '/images/portfolio/fitness-3.jpg', alt: '통계 화면', isPrimary: false }
],
clientName: '헬스케어 스타트업 FIT',
status: 'completed',
featured: true,
publishedAt: new Date('2024-02-20'),
completedAt: new Date('2024-02-15'),
isPublished: true,
viewCount: 200,
likes: 35,
order: 2,
seo: {
metaTitle: '모바일 피트니스 앱 개발 프로젝트',
metaDescription: 'React Native로 개발한 크로스플랫폼 피트니스 앱',
keywords: ['Mobile App', 'React Native', 'Fitness', '헬스케어']
}
},
{
title: '기업 웹사이트 리뉴얼',
description: '기업의 브랜드 아이덴티티를 반영한 웹사이트 리뉴얼 프로젝트입니다. 사용자 경험을 개선하고 모던한 디자인을 적용하여 브랜드 가치를 높였습니다.',
shortDescription: '브랜드 아이덴티티를 반영한 기업 웹사이트 리뉴얼',
category: 'ui-ux-design',
technologies: ['Figma', 'React', 'Sass', 'Framer Motion', 'Contentful'],
images: [
{ url: '/images/portfolio/corporate-1.jpg', alt: '기업 웹사이트 메인페이지', isPrimary: true },
{ url: '/images/portfolio/corporate-2.jpg', alt: '회사소개 페이지', isPrimary: false },
{ url: '/images/portfolio/corporate-3.jpg', alt: '서비스 페이지', isPrimary: false }
],
clientName: '기술 기업 TechCorp',
projectUrl: 'https://example-corp.com',
status: 'completed',
featured: true,
publishedAt: new Date('2024-03-10'),
completedAt: new Date('2024-03-05'),
isPublished: true,
viewCount: 120,
likes: 18,
order: 3,
seo: {
metaTitle: '기업 웹사이트 리뉴얼 프로젝트',
metaDescription: '모던한 디자인과 향상된 UX의 기업 웹사이트',
keywords: ['Web Design', 'Corporate', 'UI/UX', '웹사이트리뉴얼']
}
},
{
title: '레스토랑 예약 시스템',
description: '레스토랑을 위한 온라인 예약 시스템을 개발했습니다. 실시간 테이블 현황, 예약 관리, 고객 관리 기능을 포함하여 레스토랑 운영 효율성을 높였습니다.',
shortDescription: '실시간 테이블 예약 및 관리 시스템',
category: 'web-development',
technologies: ['Vue.js', 'Laravel', 'MySQL', 'Socket.io', 'Bootstrap'],
images: [
{ url: '/images/portfolio/restaurant-1.jpg', alt: '예약 시스템 메인', isPrimary: true },
{ url: '/images/portfolio/restaurant-2.jpg', alt: '예약 현황 관리', isPrimary: false }
],
clientName: '레스토랑 델리셔스',
status: 'completed',
featured: false,
publishedAt: new Date('2024-04-05'),
completedAt: new Date('2024-04-01'),
isPublished: true,
viewCount: 85,
likes: 12,
order: 4,
seo: {
metaTitle: '레스토랑 예약 시스템 개발',
metaDescription: '실시간 테이블 예약 및 관리 웹 시스템',
keywords: ['Reservation System', 'Vue.js', 'Laravel', '예약시스템']
}
},
{
title: '교육 플랫폼 앱',
description: '온라인 교육을 위한 모바일 애플리케이션입니다. 동영상 강의, 퀴즈, 진도 관리 기능을 포함하여 효과적인 학습 환경을 제공합니다.',
shortDescription: '온라인 학습을 위한 교육 플랫폼 모바일 앱',
category: 'mobile-app',
technologies: ['Flutter', 'Dart', 'Firebase', 'FFmpeg', 'AWS S3'],
images: [
{ url: '/images/portfolio/education-1.jpg', alt: '교육 앱 메인화면', isPrimary: true },
{ url: '/images/portfolio/education-2.jpg', alt: '강의 재생 화면', isPrimary: false }
],
clientName: '온라인 교육 기업 EduTech',
status: 'completed',
featured: false,
publishedAt: new Date('2024-05-12'),
completedAt: new Date('2024-05-08'),
isPublished: true,
viewCount: 95,
likes: 20,
order: 5,
seo: {
metaTitle: '교육 플랫폼 모바일 앱 개발',
metaDescription: 'Flutter로 개발한 온라인 교육 모바일 앱',
keywords: ['Education App', 'Flutter', 'E-learning', '교육앱']
}
},
{
title: 'IoT 대시보드',
description: 'IoT 디바이스들을 모니터링하고 제어할 수 있는 웹 대시보드를 개발했습니다. 실시간 데이터 시각화와 알림 기능을 포함합니다.',
shortDescription: 'IoT 디바이스 모니터링 및 제어 웹 대시보드',
category: 'web-development',
technologies: ['React', 'D3.js', 'Node.js', 'MQTT', 'InfluxDB', 'Docker'],
images: [
{ url: '/images/portfolio/iot-1.jpg', alt: 'IoT 대시보드 메인', isPrimary: true }
],
clientName: 'IoT 솔루션 기업 SmartDevice',
status: 'in-progress',
featured: false,
publishedAt: new Date('2024-06-01'),
isPublished: true,
viewCount: 45,
likes: 8,
order: 6,
seo: {
metaTitle: 'IoT 대시보드 개발 프로젝트',
metaDescription: '실시간 IoT 디바이스 모니터링 웹 대시보드',
keywords: ['IoT', 'Dashboard', 'Real-time', 'Monitoring']
}
}
];
await Portfolio.insertMany(portfolioItems);
console.log('✅ Sample portfolio items created successfully');
} catch (error) {
console.error('❌ Error creating sample portfolio:', error);
throw error;
}
}
async function createSiteSettings() {
try {
const existingSettings = await SiteSettings.findOne();
if (existingSettings) {
console.log('⚙️ Site settings already exist, skipping...');
return;
}
const settings = new SiteSettings({
siteName: 'SmartSolTech',
siteDescription: '혁신적인 기술 솔루션으로 비즈니스의 성장을 지원합니다',
logo: '/images/logo.png',
favicon: '/images/favicon.ico',
contact: {
email: 'info@smartsoltech.kr',
phone: '+82-10-1234-5678',
address: 'Seoul, South Korea'
},
social: {
facebook: 'https://facebook.com/smartsoltech',
twitter: 'https://twitter.com/smartsoltech',
linkedin: 'https://linkedin.com/company/smartsoltech',
instagram: 'https://instagram.com/smartsoltech',
github: 'https://github.com/smartsoltech'
},
telegram: {
isEnabled: false
},
seo: {
metaTitle: 'SmartSolTech - 혁신적인 기술 솔루션',
metaDescription: '웹 개발, 모바일 앱, UI/UX 디자인, 디지털 마케팅 전문 기업. 한국에서 최고의 기술 솔루션을 제공합니다.',
keywords: '웹 개발, 모바일 앱, UI/UX 디자인, 디지털 마케팅, 기술 솔루션, 한국, SmartSolTech'
},
hero: {
title: 'Smart Technology Solutions',
subtitle: '혁신적인 웹 개발, 모바일 앱, UI/UX 디자인으로 비즈니스의 디지털 전환을 이끌어갑니다',
backgroundImage: '/images/hero-bg.jpg',
ctaText: '프로젝트 시작하기',
ctaLink: '/contact'
},
about: {
title: 'SmartSolTech 소개',
description: '우리는 최신 기술과 창의적인 아이디어로 고객의 비즈니스 성장을 지원하는 전문 개발팀입니다. 웹 개발부터 모바일 앱, UI/UX 디자인까지 포괄적인 디지털 솔루션을 제공합니다.',
image: '/images/about.jpg'
},
maintenance: {
isEnabled: false,
message: '현재 시스템 점검 중입니다. 잠시 후 다시 접속해 주세요.'
}
});
await settings.save();
console.log('✅ Site settings created successfully');
} catch (error) {
console.error('❌ Error creating site settings:', error);
throw error;
}
}
// Run the initialization
if (require.main === module) {
initializeDatabase();
}
module.exports = {
initializeDatabase,
createAdminUser,
createSampleServices,
createSamplePortfolio,
createSiteSettings
};