Compare commits

..

2 Commits

Author SHA1 Message Date
Hördle Bot
7011a24b46 Fix: Add missing fetchSpecials() calls to update special song counts 2025-11-24 09:56:56 +01:00
Hördle Bot
9a98830245 Add skip logic to migration scripts to prevent re-running 2025-11-24 09:50:19 +01:00
4 changed files with 32 additions and 1 deletions

1
.gitignore vendored
View File

@@ -49,3 +49,4 @@ next-env.d.ts
!/public/uploads/.gitkeep
/data
.release-years-migrated
.covers-migrated

View File

@@ -526,6 +526,7 @@ export default function AdminPage() {
setIsUploading(false);
fetchSongs();
fetchGenres();
fetchSpecials(); // Update special counts
// Auto-trigger categorization after uploads
const successCount = results.filter(r => r.success).length;
@@ -600,6 +601,7 @@ export default function AdminPage() {
setUploadGenreIds([]);
fetchSongs();
fetchGenres();
fetchSpecials(); // Update special counts if song was assigned to specials
setMessage(prev => prev + '\n✅ Genres assigned successfully!');
} else {
alert('Failed to assign genres');
@@ -642,6 +644,7 @@ export default function AdminPage() {
setEditingId(null);
fetchSongs();
fetchGenres();
fetchSpecials(); // Update special counts
} else {
alert('Failed to update song');
}
@@ -661,6 +664,7 @@ export default function AdminPage() {
if (res.ok) {
fetchSongs();
fetchGenres();
fetchSpecials(); // Update special counts
} else {
alert('Failed to delete song');
}

View File

@@ -1,6 +1,6 @@
import { PrismaClient } from '@prisma/client';
import { parseBuffer } from 'music-metadata';
import { readFile, writeFile, mkdir } from 'fs/promises';
import { readFile, writeFile, mkdir, access } from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
@@ -11,6 +11,16 @@ const __dirname = path.dirname(__filename);
const prisma = new PrismaClient();
async function migrate() {
// Check if migration already ran
const flagPath = path.join(process.cwd(), '.covers-migrated');
try {
await access(flagPath);
console.log('✅ Cover migration already completed (flag file exists). Skipping...');
return;
} catch {
// Flag file doesn't exist, proceed with migration
}
console.log('Starting cover art migration...');
try {
@@ -55,6 +65,10 @@ async function migrate() {
}
console.log('Migration completed.');
// Create flag file to prevent re-running
await writeFile(flagPath, new Date().toISOString());
console.log(`🏁 Created flag file: ${flagPath}`);
} catch (e) {
console.error('Migration failed:', e);
} finally {

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('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');