Skip to content

Commit 7d6dd32

Browse files
chore: truncate fix global autonumber truncation needed in standard model as entities from package
1 parent c0d06fe commit 7d6dd32

File tree

5 files changed

+35
-22
lines changed

5 files changed

+35
-22
lines changed

src/commands/omnistudio/migration/migrate.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,14 @@ export default class Migrate extends OmniStudioBaseCommand {
180180
const debugTimer = DebugTimer.getInstance();
181181
// We need to truncate the standard objects first (in reverse order for cleanup)
182182
let objectMigrationResults;
183-
const IS_STANDARD_DATA_MODEL = isStandardDataModel();
184183

185-
if (!IS_STANDARD_DATA_MODEL) {
186-
objectMigrationResults = await this.truncateObjects([...migrationObjects].reverse(), debugTimer);
187-
const allTruncateComplete = objectMigrationResults.length === 0;
184+
objectMigrationResults = await this.truncateObjects([...migrationObjects].reverse(), debugTimer);
185+
const allTruncateComplete = objectMigrationResults.length === 0;
188186

189-
// Log truncation errors if any exist
190-
if (!allTruncateComplete) {
191-
this.logTruncationErrors(objectMigrationResults);
192-
return;
193-
}
187+
// Log truncation errors if any exist
188+
if (!allTruncateComplete) {
189+
this.logTruncationErrors(objectMigrationResults);
190+
return;
194191
}
195192

196193
objectMigrationResults = await this.migrateObjects(migrationObjects, debugTimer, namespace);

src/migration/dataraptor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
5656
}
5757

5858
async truncate(): Promise<void> {
59+
if (this.IS_STANDARD_DATA_MODEL) {
60+
return;
61+
}
5962
await super.truncate(DataRaptorMigrationTool.OMNIDATATRANSFORM_NAME);
6063
}
6164

src/migration/flexcard.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
6464

6565
// Perform Delete of OmniUiCard Records to start migration from scratch
6666
async truncate(): Promise<void> {
67+
if (this.IS_STANDARD_DATA_MODEL) {
68+
return;
69+
}
6770
const objectName = CardMigrationTool.OMNIUICARD_NAME;
6871
DebugTimer.getInstance().lap('Truncating ' + objectName);
6972

src/migration/omniscript.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
118118
}
119119

120120
async truncate(): Promise<void> {
121+
// Truncation is needed when we migrate from custom to standard data model, when on custom data model, no truncation is required
122+
if (this.IS_STANDARD_DATA_MODEL) {
123+
return;
124+
}
125+
121126
const objectName = OmniScriptMigrationTool.OMNIPROCESS_NAME;
122127
const allIds = await this.deactivateRecord(objectName);
123128
await this.truncateElements(objectName, allIds.os.parents);

src/utils/resultsbuilder/index.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ export class ResultsBuilder {
113113
// Determine which rollback flag to use based on component type
114114
let rollbackFlagNames: string[] = [];
115115
const componentName = result.name.toLowerCase();
116+
const isGlobalAutoNumber =
117+
componentName.includes('global auto number') || componentName.includes('globalautonumber');
118+
116119
if (componentName.includes('datamapper') || componentName.includes('data mapper')) {
117120
rollbackFlagNames = ['RollbackDRChanges'];
118121
} else if (componentName.includes('omniscript') || componentName.includes('integration procedure')) {
119122
rollbackFlagNames = ['RollbackOSChanges', 'RollbackIPChanges'];
120-
} else if (componentName.includes('global auto number') || componentName.includes('globalautonumber')) {
123+
} else if (isGlobalAutoNumber) {
121124
rollbackFlagNames = ['RollbackDRChanges', 'RollbackIPChanges'];
122125
}
123126
const rollbackFlags = orgDetails.rollbackFlags || [];
@@ -134,15 +137,15 @@ export class ResultsBuilder {
134137
assessmentDate: new Date().toLocaleString(),
135138
total: result.data?.length || 0,
136139
filterGroups: [...this.getStatusFilterGroup(result.data?.map((item) => item.status) || [])],
137-
headerGroups: [...this.getHeaderGroupsForReport(componentName)],
140+
headerGroups: [...this.getHeaderGroupsForReport(componentName, isGlobalAutoNumber)],
138141
rows: [
139142
...(result.data || []).map((item) => ({
140143
rowId: `${this.rowClass}${this.rowId++}`,
141144
data: [
142145
createRowDataParam('id', item.id, false, 1, 1, true, `${instanceUrl}/${item.id}`),
143146
createRowDataParam('name', item.name, true, 1, 1, false),
144-
// Only include migratedId for custom data model
145-
...(isStandardDataModel()
147+
// Include migratedId for custom data model OR Global Auto Number
148+
...(isStandardDataModel() && !isGlobalAutoNumber
146149
? []
147150
: [
148151
createRowDataParam(
@@ -198,9 +201,12 @@ export class ResultsBuilder {
198201
fs.writeFileSync(path.join(resultsDir, result.name.replace(/ /g, '_').replace(/\//g, '_') + '.html'), html);
199202
}
200203

201-
private static getHeaderGroupsForReport(componentName: string): ReportHeaderGroupParam[] {
204+
private static getHeaderGroupsForReport(
205+
componentName: string,
206+
isGlobalAutoNumber: boolean
207+
): ReportHeaderGroupParam[] {
202208
const firstRowHeaders = [
203-
...this.getNameHeaders(componentName),
209+
...this.getNameHeaders(componentName, isGlobalAutoNumber),
204210
{ name: 'Status', colspan: 1, rowspan: 2 },
205211
{ name: 'Errors', colspan: 1, rowspan: 2 },
206212
{ name: 'Summary', colspan: 1, rowspan: 2 },
@@ -221,19 +227,18 @@ export class ResultsBuilder {
221227
{ name: nameLabel, colspan: 1, rowspan: 1 },
222228
];
223229

224-
if (isStandardDataModel()) {
230+
// Global Auto Number always needs 4 columns (Managed Package + Standard), even in standard data model
231+
if (isStandardDataModel() && !isGlobalAutoNumber) {
225232
return [{ header: firstRowHeaders }, { header: secondRowHeadersForStandard }];
226233
} else {
227234
return [{ header: firstRowHeaders }, { header: secondRowHeadersForCustom }];
228235
}
229236
}
230237

231-
private static getNameHeaders(componentName: string): Array<{ name: string; colspan: number; rowspan: number }> {
232-
let isGlobalAutoNumber = false;
233-
if (componentName.includes('global auto number') || componentName.includes('globalautonumber')) {
234-
isGlobalAutoNumber = true;
235-
}
236-
238+
private static getNameHeaders(
239+
componentName: string,
240+
isGlobalAutoNumber: boolean
241+
): Array<{ name: string; colspan: number; rowspan: number }> {
237242
if (isStandardDataModel() && !isGlobalAutoNumber) {
238243
return [{ name: 'Standard', colspan: 3, rowspan: 1 }];
239244
} else {

0 commit comments

Comments
 (0)