ante-erp-cli 1.11.46 → 1.11.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -3,8 +3,12 @@ import chalk from 'chalk';
|
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
import { execa } from 'execa';
|
|
5
5
|
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
6
|
-
import { join } from 'path';
|
|
6
|
+
import { join, dirname } from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
7
8
|
import os from 'os';
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = dirname(__filename);
|
|
8
12
|
import Conf from 'conf';
|
|
9
13
|
import Table from 'cli-table3';
|
|
10
14
|
import { backup } from './backup.js';
|
|
@@ -522,8 +526,8 @@ async function setupCronJob(schedule) {
|
|
|
522
526
|
.split('\n')
|
|
523
527
|
.filter(line => !line.includes('ante-daily-backup-runner'));
|
|
524
528
|
|
|
525
|
-
// Add new cron job
|
|
526
|
-
const runnerPath = join(
|
|
529
|
+
// Add new cron job - use the actual module location, not process.cwd()
|
|
530
|
+
const runnerPath = join(__dirname, 'daily-backup-runner.js');
|
|
527
531
|
const logFile = join(os.homedir(), '.ante-cli-backup.log');
|
|
528
532
|
const cronLine = `${schedule} /usr/bin/node ${runnerPath} >> ${logFile} 2>&1`;
|
|
529
533
|
|
package/src/commands/restore.js
CHANGED
|
@@ -6,7 +6,7 @@ import { existsSync, mkdirSync, readdirSync, statSync, readFileSync, createWrite
|
|
|
6
6
|
import { execa } from 'execa';
|
|
7
7
|
import Conf from 'conf';
|
|
8
8
|
import { getInstallDir } from '../utils/config.js';
|
|
9
|
-
import { execInContainer, stopServices, startServices, waitForHealthy } from '../utils/docker.js';
|
|
9
|
+
import { execInContainer, stopServices, startServices, waitForHealthy, runMigrations } from '../utils/docker.js';
|
|
10
10
|
import { createS3Client, listS3Backups } from '../utils/s3-client.js';
|
|
11
11
|
import { decryptFields } from '../utils/crypto.js';
|
|
12
12
|
import { GetObjectCommand } from '@aws-sdk/client-s3';
|
|
@@ -368,6 +368,19 @@ export async function restore(backupFile, options = {}) {
|
|
|
368
368
|
spinner.text = 'Starting all services...';
|
|
369
369
|
await startServices(composeFile);
|
|
370
370
|
|
|
371
|
+
// Wait for backend to be healthy before running migrations
|
|
372
|
+
spinner.text = 'Waiting for backend service...';
|
|
373
|
+
await waitForHealthy(composeFile, ['backend'], 120);
|
|
374
|
+
|
|
375
|
+
// Run database migrations to sync schema with current code
|
|
376
|
+
spinner.text = 'Running database migrations...';
|
|
377
|
+
const migrationResult = await runMigrations(composeFile);
|
|
378
|
+
|
|
379
|
+
if (!migrationResult.success) {
|
|
380
|
+
spinner.warn(chalk.yellow('Migrations completed with warnings'));
|
|
381
|
+
console.log(chalk.gray(migrationResult.output));
|
|
382
|
+
}
|
|
383
|
+
|
|
371
384
|
// Cleanup
|
|
372
385
|
spinner.text = 'Cleaning up...';
|
|
373
386
|
await execa('rm', ['-rf', tempDir]);
|
|
@@ -382,6 +395,7 @@ export async function restore(backupFile, options = {}) {
|
|
|
382
395
|
|
|
383
396
|
console.log(chalk.white('\n✓ PostgreSQL database restored'));
|
|
384
397
|
console.log(chalk.white('✓ MongoDB database restored'));
|
|
398
|
+
console.log(chalk.white('✓ Database migrations applied'));
|
|
385
399
|
console.log(chalk.white('✓ All services started'));
|
|
386
400
|
|
|
387
401
|
console.log(chalk.cyan('\nANTE is now running with restored database data'));
|