Skip to main content
Glama
simple-migrate.jsโ€ข6.14 kB
#!/usr/bin/env node /** * Simple Document Management System Migration */ import sqlite3 from 'sqlite3'; import { open } from 'sqlite'; import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Database path const DB_PATH = path.resolve(__dirname, '../../data/workflow.db'); async function simpleMigrate() { console.log('๐Ÿš€ Simple Document Management Migration...'); if (!fs.existsSync(DB_PATH)) { console.error('โŒ Database not found:', DB_PATH); process.exit(1); } const db = await open({ filename: DB_PATH, driver: sqlite3.Database }); try { await db.exec('PRAGMA foreign_keys = ON'); console.log('๐Ÿ”ง Creating documents table...'); // Create documents table await db.exec(` CREATE TABLE IF NOT EXISTS documents ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT NOT NULL, content TEXT NOT NULL, doc_type TEXT NOT NULL, category TEXT, file_path TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, version INTEGER DEFAULT 1, created_by TEXT, tags TEXT, summary TEXT, status TEXT DEFAULT 'draft' ) `); console.log('๐Ÿ”ง Creating document_links table...'); // Create document_links table await db.exec(` CREATE TABLE IF NOT EXISTS document_links ( id INTEGER PRIMARY KEY AUTOINCREMENT, document_id INTEGER NOT NULL, linked_entity_type TEXT NOT NULL, linked_entity_id TEXT NOT NULL, link_type TEXT DEFAULT 'notes', created_at DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (document_id) REFERENCES documents(id) ON DELETE CASCADE ) `); console.log('๐Ÿ“Š Verifying tables...'); const tables = await db.all(` SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%document%' `); console.log('๐Ÿ“‹ Created tables:'); tables.forEach(table => { console.log(` โœ… ${table.name}`); }); console.log('๐Ÿ“ Importing test documents...'); // Import documents const testGuidePath = path.resolve(__dirname, '../../docs/PHASE_2.6_TEST_GUIDE.md'); if (fs.existsSync(testGuidePath)) { const content = fs.readFileSync(testGuidePath, 'utf8'); const result = await db.run(` INSERT INTO documents (title, content, doc_type, category, file_path, tags, summary, status, created_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) `, [ 'Phase 2.6 SvelteKit Dashboard ํ…Œ์ŠคํŠธ ๊ฐ€์ด๋“œ', content, 'test_guide', 'phase_2.6', testGuidePath, JSON.stringify(['testing', 'sveltekit', 'phase_2.6', 'dashboard']), 'SvelteKit ์›น ๋Œ€์‹œ๋ณด๋“œ์˜ ๋ชจ๋“  ๊ธฐ๋Šฅ์„ ๊ฒ€์ฆํ•˜๊ณ  SQLite ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€์˜ ์—ฐ๋™ ํ…Œ์ŠคํŠธ', 'approved', 'migration' ]); console.log(`โœ… Imported test guide (ID: ${result.lastID})`); } // Import test results const testResultsPath = path.resolve(__dirname, '../../docs/PHASE_2.6_TEST_RESULTS.md'); if (fs.existsSync(testResultsPath)) { const content = fs.readFileSync(testResultsPath, 'utf8'); const result = await db.run(` INSERT INTO documents (title, content, doc_type, category, file_path, tags, summary, status, created_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) `, [ 'Phase 2.6 SvelteKit Dashboard ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ ๋ณด๊ณ ์„œ', content, 'test_results', 'phase_2.6', testResultsPath, JSON.stringify(['testing', 'results', 'phase_2.6', 'sveltekit']), 'ํ†ต๊ณผ์œจ 85.7%๋กœ ํ•ต์‹ฌ ๊ธฐ๋Šฅ์ด ๋ชจ๋‘ ์ •์ƒ ์ž‘๋™ํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธ', 'approved', 'migration' ]); console.log(`โœ… Imported test results (ID: ${result.lastID})`); } // Import checklist const checklistPath = path.resolve(__dirname, '../../docs/QUICK_TEST_CHECKLIST.md'); if (fs.existsSync(checklistPath)) { const content = fs.readFileSync(checklistPath, 'utf8'); const result = await db.run(` INSERT INTO documents (title, content, doc_type, category, file_path, tags, summary, status, created_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) `, [ 'Phase 2.6 ๋น ๋ฅธ ํ…Œ์ŠคํŠธ ์ฒดํฌ๋ฆฌ์ŠคํŠธ', content, 'checklist', 'phase_2.6', checklistPath, JSON.stringify(['testing', 'checklist', 'quick_test']), '5๋ถ„ ๋‚ด ํ•ต์‹ฌ ๊ธฐ๋Šฅ ํ™•์ธ์„ ์œ„ํ•œ 10๊ฐœ ์ฒดํฌํฌ์ธํŠธ', 'approved', 'migration' ]); console.log(`โœ… Imported checklist (ID: ${result.lastID})`); } // Show final count const count = await db.get('SELECT COUNT(*) as total FROM documents'); console.log(`๐Ÿ“Š Total documents: ${count.total}`); console.log('๐ŸŽ‰ Document management system ready!'); return true; } catch (error) { console.error('โŒ Migration failed:', error); return false; } finally { await db.close(); } } simpleMigrate().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/foswmine/workflow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server