mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added --print-dependencies
to data generator
refs https://github.com/TryGhost/DevOps/issues/119 - this allows you to debug the dependency chain to understand why a particular table is being generated
This commit is contained in:
parent
ff34a98b94
commit
db16e565bc
2 changed files with 13 additions and 1 deletions
|
@ -10,6 +10,7 @@ module.exports = class DataGeneratorCommand extends Command {
|
||||||
this.argument('--clear-database', {type: 'boolean', defaultValue: false, desc: 'Clear all entries in the database before importing'});
|
this.argument('--clear-database', {type: 'boolean', defaultValue: false, desc: 'Clear all entries in the database before importing'});
|
||||||
this.argument('--tables', {type: 'string', desc: 'Only import the specified list of tables, where quantities can be specified by appending a colon followed by the quantity for each table. Example: --tables=members:1000,posts,tags,members_login_events'});
|
this.argument('--tables', {type: 'string', desc: 'Only import the specified list of tables, where quantities can be specified by appending a colon followed by the quantity for each table. Example: --tables=members:1000,posts,tags,members_login_events'});
|
||||||
this.argument('--with-default', {type: 'boolean', defaultValue: false, desc: 'Include default tables as well as those specified (simply override quantities)'});
|
this.argument('--with-default', {type: 'boolean', defaultValue: false, desc: 'Include default tables as well as those specified (simply override quantities)'});
|
||||||
|
this.argument('--print-dependencies', {type: 'boolean', defaultValue: false, desc: 'Prints the dependency tree for the data generator and exits'});
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeContext(context) {
|
initializeContext(context) {
|
||||||
|
@ -51,7 +52,8 @@ module.exports = class DataGeneratorCommand extends Command {
|
||||||
baseUrl: config.getSiteUrl(),
|
baseUrl: config.getSiteUrl(),
|
||||||
clearDatabase: argv['clear-database'],
|
clearDatabase: argv['clear-database'],
|
||||||
tables,
|
tables,
|
||||||
withDefault: argv['with-default']
|
withDefault: argv['with-default'],
|
||||||
|
printDependencies: argv['print-dependencies']
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await dataGenerator.importData();
|
await dataGenerator.importData();
|
||||||
|
|
|
@ -18,6 +18,7 @@ class DataGenerator {
|
||||||
baseDataPack = '',
|
baseDataPack = '',
|
||||||
baseUrl,
|
baseUrl,
|
||||||
logger,
|
logger,
|
||||||
|
printDependencies,
|
||||||
withDefault
|
withDefault
|
||||||
}) {
|
}) {
|
||||||
this.knex = knex;
|
this.knex = knex;
|
||||||
|
@ -28,6 +29,7 @@ class DataGenerator {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.withDefault = withDefault;
|
this.withDefault = withDefault;
|
||||||
|
this.printDependencies = printDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
sortTableList() {
|
sortTableList() {
|
||||||
|
@ -158,6 +160,14 @@ class DataGenerator {
|
||||||
|
|
||||||
this.sortTableList();
|
this.sortTableList();
|
||||||
|
|
||||||
|
if (this.printDependencies) {
|
||||||
|
this.logger.info('Table dependencies:');
|
||||||
|
for (const table of this.tableList) {
|
||||||
|
this.logger.info(`\t${table.name}: ${table.dependencies.join(', ')}`);
|
||||||
|
}
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.willClearData) {
|
if (this.willClearData) {
|
||||||
await this.clearData(transaction);
|
await this.clearData(transaction);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue