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AA;;wBAA9B,SAA8B,CAAC;wBAC/B,qBAAM,UAAU,CAAC,KAAK,EAAE,EAAA;;wBAAxB,SAAwB,CAAC;wBAEzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC,CAAC;;;;6BAGrE,UAAU,EAAV,wBAAU;wBAAE,qBAAO,UAAyB,CAAC,KAAK,EAAE,EAAA;;wBAAxC,SAAwC,CAAC;;;wBAEzD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC;wBACvE,OAAO,CAAC,KAAK,CAAC,KAAG,CAAC,CAAC;wBACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;;;;;KAEvB;IACL,wBAAC;AAAD,CAhDA,AAgDC,IAAA;AAhDY,8CAAiB","file":"SchemaSyncCommand.js","sourcesContent":["import {createConnection} from \"../index\";\nimport {Connection} from \"../connection/Connection\";\nimport {ConnectionOptionsReader} from \"../connection/ConnectionOptionsReader\";\nimport * as yargs from \"yargs\";\nconst chalk = require(\"chalk\");\n\n/**\n * Synchronizes database schema with entities.\n */\nexport class SchemaSyncCommand implements yargs.CommandModule {\n command = \"schema:sync\";\n describe = \"Synchronizes your entities with database schema. It runs schema update queries on all connections you have. \" +\n \"To run update queries on a concrete connection use -c option.\";\n\n builder(args: yargs.Argv) {\n return args\n .option(\"c\", {\n alias: \"connection\",\n default: \"default\",\n describe: \"Name of the connection on which schema synchronization needs to to run.\"\n })\n .option(\"f\", {\n alias: \"config\",\n default: \"ormconfig\",\n describe: \"Name of the file with connection configuration.\"\n });\n }\n\n async handler(args: yargs.Arguments) {\n\n let connection: Connection|undefined = undefined;\n try {\n const connectionOptionsReader = new ConnectionOptionsReader({\n root: process.cwd(),\n configName: args.config as any\n });\n const connectionOptions = await connectionOptionsReader.get(args.connection as any);\n Object.assign(connectionOptions, {\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: [\"query\", \"schema\"]\n });\n connection = await createConnection(connectionOptions);\n await connection.synchronize();\n await connection.close();\n\n console.log(chalk.green(\"Schema syncronization finished successfully.\"));\n\n } catch (err) {\n if (connection) await (connection as Connection).close();\n\n console.log(chalk.black.bgRed(\"Error during schema synchronization:\"));\n console.error(err);\n process.exit(1);\n }\n }\n}\n"],"sourceRoot":".."}
\No newline at end of file