Add skip logic to migration scripts to prevent re-running

This commit is contained in:
Hördle Bot
2025-11-24 09:50:19 +01:00
parent 3630745169
commit 9a98830245
3 changed files with 28 additions and 1 deletions

View File

@@ -122,6 +122,18 @@ async function getReleaseYear(artist, title) {
// --- Migration Logic ---
async function migrate() {
// Check if migration already ran
const flagPath = path.join(process.cwd(), '.release-years-migrated');
try {
const { access } = await import('fs/promises');
await access(flagPath);
console.log('✅ Release year migration already completed (flag file exists). Skipping...');
await prisma.$disconnect();
return;
} catch {
// Flag file doesn't exist, proceed with migration
}
console.log('🎵 Starting release year migration...');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');