690322:2123 Fixing Deployment Errors
CI / CD Pipeline / build (push) Failing after 7m56s
CI / CD Pipeline / release (push) Has been skipped
CI / CD Pipeline / deploy (push) Has been skipped

This commit is contained in:
2026-03-22 21:23:08 +07:00
parent 5dad7ab7c1
commit 4dc14aba5b
28 changed files with 324 additions and 67 deletions
-17
View File
@@ -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();
}