690322:2123 Fixing Deployment Errors
This commit is contained in:
@@ -13,14 +13,12 @@ async function migrateStorage() {
|
||||
await dataSource.initialize();
|
||||
|
||||
try {
|
||||
// console.log('🚀 Starting Storage Migration v2...');
|
||||
const attachmentRepo = dataSource.getRepository(Attachment);
|
||||
|
||||
// Find all permanent attachments
|
||||
const attachments = await attachmentRepo.find({
|
||||
where: { isTemporary: false },
|
||||
});
|
||||
// console.log(`Found ${attachments.length} permanent attachments.`);
|
||||
|
||||
let _movedCount = 0;
|
||||
let _errorCount = 0;
|
||||
@@ -32,8 +30,6 @@ async function migrateStorage() {
|
||||
process.env.UPLOAD_PERMANENT_DIR ||
|
||||
path.join(process.cwd(), 'uploads', 'permanent');
|
||||
|
||||
// console.log(`Target Permanent Directory: ${permanentBaseDir}`);
|
||||
|
||||
if (!fs.existsSync(permanentBaseDir)) {
|
||||
// console.warn(
|
||||
// `Base directory not found: ${permanentBaseDir}. Creating it...`
|
||||
@@ -49,7 +45,6 @@ async function migrateStorage() {
|
||||
|
||||
const currentPath = att.filePath;
|
||||
if (!fs.existsSync(currentPath)) {
|
||||
// console.warn(`File not found on disk: ${currentPath} (ID: ${att.id})`);
|
||||
_errorCount++;
|
||||
continue;
|
||||
}
|
||||
@@ -67,7 +62,6 @@ async function migrateStorage() {
|
||||
? new Date(att.referenceDate)
|
||||
: new Date(att.createdAt);
|
||||
if (isNaN(refDate.getTime())) {
|
||||
// console.warn(`Invalid date for ID ${att.id}, skipping.`);
|
||||
_errorCount++;
|
||||
continue;
|
||||
}
|
||||
@@ -97,22 +91,11 @@ async function migrateStorage() {
|
||||
}
|
||||
await attachmentRepo.save(att);
|
||||
_movedCount++;
|
||||
// if (movedCount % 100 === 0) console.log(`Moved ${movedCount} files...`);
|
||||
} catch (_err: unknown) {
|
||||
// console.error(
|
||||
// `Failed to move file ID ${att.id}:`,
|
||||
// (err as Error).message
|
||||
// );
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(`Migration completed.`);
|
||||
// console.log(`Moved: ${movedCount}`);
|
||||
// console.log(`Skipped: ${skippedCount}`);
|
||||
// console.log(`Errors: ${errorCount}`);
|
||||
} catch (_error) {
|
||||
// console.error('Migration failed:', error);
|
||||
} finally {
|
||||
await dataSource.destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user