add remove columns in relation option
This commit is contained in:
parent
9315b4a992
commit
18482ebb55
@ -24,6 +24,7 @@ export default interface IGenerationOptions {
|
||||
indexFile: boolean;
|
||||
exportType: "named" | "default";
|
||||
skipNonPrimaryKeyIndexes: boolean;
|
||||
removeColumnsInRelation: boolean;
|
||||
}
|
||||
|
||||
export const eolConverter = {
|
||||
@ -51,6 +52,7 @@ export function getDefaultGenerationOptions(): IGenerationOptions {
|
||||
indexFile: false,
|
||||
exportType: "named",
|
||||
skipNonPrimaryKeyIndexes: false,
|
||||
removeColumnsInRelation: true,
|
||||
};
|
||||
return generationOptions;
|
||||
}
|
||||
|
@ -89,7 +89,11 @@ export default function modelCustomizationPhase(
|
||||
}
|
||||
namingStrategy.enablePluralization(generationOptions.pluralizeNames);
|
||||
let retVal = removeIndicesGeneratedByTypeorm(dbModel);
|
||||
retVal = removeColumnsInRelation(dbModel);
|
||||
|
||||
if (generationOptions.removeColumnsInRelation) {
|
||||
retVal = removeColumnsInRelation(dbModel);
|
||||
}
|
||||
|
||||
retVal = applyNamingStrategy(namingStrategy, dbModel);
|
||||
retVal = addImportsAndGenerationOptions(retVal, generationOptions);
|
||||
retVal = removeColumnDefaultProperties(retVal, defaultValues);
|
||||
|
16
src/index.ts
16
src/index.ts
@ -281,7 +281,12 @@ function checkYargsParameters(options: options): options {
|
||||
boolean: true,
|
||||
default: options.generationOptions.skipNonPrimaryKeyIndexes,
|
||||
describe: "Skip generation of non-primary key indexes",
|
||||
},
|
||||
},
|
||||
removeColumnsInRelation: {
|
||||
boolean: true,
|
||||
default: options.generationOptions.removeColumnsInRelation,
|
||||
describe: "Remove columns in relation",
|
||||
},
|
||||
tables: {
|
||||
string: true,
|
||||
default: options.connectionOptions.onlyTables.join(","),
|
||||
@ -348,6 +353,7 @@ function checkYargsParameters(options: options): options {
|
||||
options.generationOptions.relationIds = argv.relationIds;
|
||||
options.generationOptions.skipSchema = argv.skipSchema;
|
||||
options.generationOptions.skipNonPrimaryKeyIndexes = argv.skipNonPrimaryKeyIndexes;
|
||||
options.generationOptions.removeColumnsInRelation = argv.removeColumnsInRelation;
|
||||
options.generationOptions.resultsPath = argv.o;
|
||||
options.generationOptions.pluralizeNames = !argv.disablePluralization;
|
||||
options.generationOptions.strictMode =
|
||||
@ -625,7 +631,12 @@ async function useInquirer(options: options): Promise<options> {
|
||||
name: "Skip generation of non-primary key indexes",
|
||||
value: "skipNonPrimaryKeyIndexes",
|
||||
checked: options.generationOptions.skipNonPrimaryKeyIndexes,
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Remove columns in relation",
|
||||
value: "removeColumnsInRelation",
|
||||
checked: options.generationOptions.removeColumnsInRelation,
|
||||
}
|
||||
],
|
||||
message: "Available customizations",
|
||||
name: "selected",
|
||||
@ -679,6 +690,7 @@ async function useInquirer(options: options): Promise<options> {
|
||||
? "default"
|
||||
: "named";
|
||||
options.generationOptions.skipNonPrimaryKeyIndexes = customizations.includes("skipNonPrimaryKeyIndexes");
|
||||
options.generationOptions.removeColumnsInRelation = customizations.includes("removeColumnsInRelation");
|
||||
|
||||
if (customizations.includes("namingStrategy")) {
|
||||
const namingStrategyPath = (
|
||||
|
Loading…
Reference in New Issue
Block a user