refactor: update database setup and remove skills migration API
- Changed migration commands in DATABASE_SETUP.md to use `pnpm run sync-skills` and `pnpm run sync-teams`. - Removed the skills migration API endpoint in route.ts, streamlining the migration process. - Updated MIGRATION_UUID.md to reflect changes in migration steps and removed the old skills migration script. - Added new sync scripts for skills and teams in package.json. - Cleaned up init.sql by removing old teams data insertion and adjusted comments for clarity.
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { SkillsService } from "@/services";
|
||||
import { loadSkillCategoriesFromFiles } from "@/lib/skill-file-loader";
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
console.log("🚀 Starting skills migration via API...");
|
||||
|
||||
// Load all skill categories from JSON files
|
||||
const skillCategories = loadSkillCategoriesFromFiles();
|
||||
|
||||
console.log(`📊 Found ${skillCategories.length} categories`);
|
||||
|
||||
const totalSkills = skillCategories.reduce(
|
||||
(sum, cat) => sum + cat.skills.length,
|
||||
0
|
||||
);
|
||||
console.log(`🎯 Total skills to migrate: ${totalSkills}`);
|
||||
|
||||
// Bulk insert into database
|
||||
await SkillsService.bulkInsertSkillsFromJSON(skillCategories);
|
||||
|
||||
console.log("✅ Skills migration completed successfully!");
|
||||
|
||||
// Verify the migration
|
||||
const categoriesFromDb = await SkillsService.getSkillCategories();
|
||||
const totalSkillsInDb = categoriesFromDb.reduce(
|
||||
(sum, cat) => sum + cat.skills.length,
|
||||
0
|
||||
);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Skills migration completed successfully",
|
||||
stats: {
|
||||
categoriesMigrated: skillCategories.length,
|
||||
skillsMigrated: totalSkills,
|
||||
categoriesInDb: categoriesFromDb.length,
|
||||
skillsInDb: totalSkillsInDb,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("❌ Migration failed:", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: "Failed to migrate skills",
|
||||
details: error instanceof Error ? error.message : "Unknown error",
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user