Skip to content

Commit

Permalink
fix(tools): fix backup not using correct connection
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Oct 29, 2023
1 parent e6a28d4 commit b23b9f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const argv = yargs(hideBin(process.argv))
import { getMigrationType } from '../dest/helpers/getMigrationType.js';

async function main() {
const type = process.env.TYPEORM_AppDataSource;
const type = process.env.TYPEORM_CONNECTION;
const migrationsRun = argv._[0] === 'restore';

const MySQLDataSourceOptions = {
Expand Down Expand Up @@ -109,9 +109,9 @@ async function main() {
};

let AppDataSource;
if (process.env.TYPEORM_AppDataSource === 'mysql' || process.env.TYPEORM_AppDataSource === 'mariadb') {
if (process.env.TYPEORM_CONNECTION === 'mysql' || process.env.TYPEORM_CONNECTION === 'mariadb') {
AppDataSource = new DataSource(MySQLDataSourceOptions);
} else if (process.env.TYPEORM_AppDataSource === 'postgres') {
} else if (process.env.TYPEORM_CONNECTION === 'postgres') {
AppDataSource = new DataSource(PGDataSourceOptions);
} else {
AppDataSource = new DataSource(SQLiteDataSourceOptions);
Expand All @@ -123,6 +123,7 @@ async function main() {
mysql: 'MySQL/MariaDB',
postgres: 'PostgreSQL',
};
console.log({type})
console.log(`Initialized ${typeToLog[type]} database (${normalize(String(AppDataSource.options.database))})`);
if (argv._[0] === 'backup') {
const metadatas = AppDataSource.entityMetadatas;
Expand Down

0 comments on commit b23b9f2

Please sign in to comment.