Compare commits
2 Commits
3630745169
...
7011a24b46
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7011a24b46 | ||
|
|
9a98830245 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -49,3 +49,4 @@ next-env.d.ts
|
|||||||
!/public/uploads/.gitkeep
|
!/public/uploads/.gitkeep
|
||||||
/data
|
/data
|
||||||
.release-years-migrated
|
.release-years-migrated
|
||||||
|
.covers-migrated
|
||||||
|
|||||||
@@ -526,6 +526,7 @@ export default function AdminPage() {
|
|||||||
setIsUploading(false);
|
setIsUploading(false);
|
||||||
fetchSongs();
|
fetchSongs();
|
||||||
fetchGenres();
|
fetchGenres();
|
||||||
|
fetchSpecials(); // Update special counts
|
||||||
|
|
||||||
// Auto-trigger categorization after uploads
|
// Auto-trigger categorization after uploads
|
||||||
const successCount = results.filter(r => r.success).length;
|
const successCount = results.filter(r => r.success).length;
|
||||||
@@ -600,6 +601,7 @@ export default function AdminPage() {
|
|||||||
setUploadGenreIds([]);
|
setUploadGenreIds([]);
|
||||||
fetchSongs();
|
fetchSongs();
|
||||||
fetchGenres();
|
fetchGenres();
|
||||||
|
fetchSpecials(); // Update special counts if song was assigned to specials
|
||||||
setMessage(prev => prev + '\n✅ Genres assigned successfully!');
|
setMessage(prev => prev + '\n✅ Genres assigned successfully!');
|
||||||
} else {
|
} else {
|
||||||
alert('Failed to assign genres');
|
alert('Failed to assign genres');
|
||||||
@@ -642,6 +644,7 @@ export default function AdminPage() {
|
|||||||
setEditingId(null);
|
setEditingId(null);
|
||||||
fetchSongs();
|
fetchSongs();
|
||||||
fetchGenres();
|
fetchGenres();
|
||||||
|
fetchSpecials(); // Update special counts
|
||||||
} else {
|
} else {
|
||||||
alert('Failed to update song');
|
alert('Failed to update song');
|
||||||
}
|
}
|
||||||
@@ -661,6 +664,7 @@ export default function AdminPage() {
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
fetchSongs();
|
fetchSongs();
|
||||||
fetchGenres();
|
fetchGenres();
|
||||||
|
fetchSpecials(); // Update special counts
|
||||||
} else {
|
} else {
|
||||||
alert('Failed to delete song');
|
alert('Failed to delete song');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
import { parseBuffer } from 'music-metadata';
|
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 path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
@@ -11,6 +11,16 @@ const __dirname = path.dirname(__filename);
|
|||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
async function migrate() {
|
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...');
|
console.log('Starting cover art migration...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -55,6 +65,10 @@ async function migrate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Migration completed.');
|
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) {
|
} catch (e) {
|
||||||
console.error('Migration failed:', e);
|
console.error('Migration failed:', e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -122,6 +122,18 @@ async function getReleaseYear(artist, title) {
|
|||||||
// --- Migration Logic ---
|
// --- Migration Logic ---
|
||||||
|
|
||||||
async function migrate() {
|
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('🎵 Starting release year migration...');
|
||||||
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user