Migrate video metadata to PostgreSQL for improved data management

Introduces a new video migration service to transfer video metadata from Bunny.net to PostgreSQL. Updates storage logic to prioritize PostgreSQL, removes redundant fields from the video schema, and adds database migration functionality to the server startup.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/i1Fg8VZ
This commit is contained in:
sebastjanartic
2025-08-28 17:23:05 +00:00
parent 443d92804e
commit f658b64b56
4 changed files with 99 additions and 26 deletions
+4 -15
View File
@@ -801,33 +801,22 @@ class BunnyStorage implements IStorage {
}
}
// Storage selection logic - choose DatabaseStorage if PostgreSQL is available
// Storage selection logic - use PostgreSQL for video metadata
let storage: IStorage;
const hasDatabase = process.env.DATABASE_URL;
const hasBunnyConfig = process.env.BUNNY_API_KEY && process.env.BUNNY_LIBRARY_ID && process.env.BUNNY_HOSTNAME;
// Prioritize Bunny.net storage for user's video content
if (hasBunnyConfig) {
try {
storage = new BunnyStorage();
console.log('✅ Using Bunny.net storage with library ID:', process.env.BUNNY_LIBRARY_ID);
} catch (error) {
console.error('❌ Failed to initialize Bunny.net storage:', error);
console.log('📁 Falling back to memory storage');
storage = new MemStorage();
}
} else if (hasDatabase) {
if (hasDatabase) {
try {
storage = new DatabaseStorage();
console.log('✅ Using PostgreSQL database storage');
console.log('✅ Using PostgreSQL database for video metadata storage');
} catch (error) {
console.error('❌ Failed to initialize database storage:', error);
console.log('📁 Falling back to memory storage');
storage = new MemStorage();
}
} else {
console.log('📁 Using memory storage (no database or Bunny.net config found)');
console.log('📁 Using memory storage (no database found)');
storage = new MemStorage();
}