Skip to content

Commit c28e074

Browse files
committed
fix: remove manualStep count tracking
1 parent 877306a commit c28e074

File tree

7 files changed

+25
-66
lines changed

7 files changed

+25
-66
lines changed

meteor/server/coreSystem/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async function initializeCoreSystem() {
8484
if (!isRunningInJest()) {
8585
// Check what migration has to provide:
8686
const migration = await prepareMigration(true)
87-
if (migration.migrationNeeded && migration.manualStepCount === 0 && migration.chunks.length <= 1) {
87+
if (migration.migrationNeeded && migration.chunks.length <= 1) {
8888
// Since we've determined that the migration can be done automatically, and we have a fresh system, just do the migration automatically:
8989
await runMigration(migration.chunks, migration.hash)
9090
}

meteor/server/migration/__tests__/migrations.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { clearMigrationSteps, addMigrationSteps, prepareMigration, PreparedMigra
55
import { CURRENT_SYSTEM_VERSION } from '../currentSystemVersion'
66
import { RunMigrationResult, GetMigrationStatusResult } from '@sofie-automation/meteor-lib/dist/api/migration'
77
import { protectString } from '@sofie-automation/corelib/dist/protectedString'
8-
import { MigrationStepCore } from '@sofie-automation/blueprints-integration'
8+
import { MigrationStepCore } from '@sofie-automation/meteor-lib/dist/migrations'
99
import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio'
1010
import { MeteorCall } from '../../api/methods'
1111
import { wrapDefaultObject } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
@@ -47,11 +47,8 @@ describe('Migrations', () => {
4747
migrationNeeded: true,
4848

4949
migration: {
50-
canDoAutomaticMigration: true,
51-
// manualInputs: [],
5250
hash: expect.stringContaining(''),
5351
automaticStepCount: expect.any(Number),
54-
manualStepCount: expect.any(Number),
5552
ignoredStepCount: expect.any(Number),
5653
partialMigration: true,
5754
// chunks: expect.any(Array)
@@ -258,8 +255,7 @@ describe('Migrations', () => {
258255
const migrationStatus: GetMigrationStatusResult = await MeteorCall.migration.getMigrationStatus()
259256
const migrationResult: RunMigrationResult = await MeteorCall.migration.runMigration(
260257
migrationStatus.migration.chunks,
261-
migrationStatus.migration.hash,
262-
userInput(migrationStatus)
258+
migrationStatus.migration.hash
263259
)
264260

265261
expect(migrationResult.migrationCompleted).toEqual(true)

meteor/server/migration/databaseMigration.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export interface PreparedMigration {
8585
steps: MigrationStepInternal[]
8686
migrationNeeded: boolean
8787
automaticStepCount: number
88-
manualStepCount: number
8988
ignoredStepCount: number
9089
partialMigration: boolean
9190
}
@@ -148,7 +147,6 @@ export async function prepareMigration(returnAllChunks?: boolean): Promise<Prepa
148147
})
149148

150149
let automaticStepCount = 0
151-
let manualStepCount = 0
152150
let ignoredStepCount = 0
153151

154152
let partialMigration = false
@@ -224,11 +222,8 @@ export async function prepareMigration(returnAllChunks?: boolean): Promise<Prepa
224222
for (const step of Object.values<MigrationStepInternal>(migrationSteps)) {
225223
stepsHash.push(step.id)
226224
step.chunk._steps.push(step.id)
227-
if (!step.canBeRunAutomatically) {
228-
manualStepCount++
229-
} else {
230-
automaticStepCount++
231-
}
225+
226+
automaticStepCount++
232227
}
233228

234229
// Only return the chunks which has steps in them:
@@ -249,7 +244,6 @@ export async function prepareMigration(returnAllChunks?: boolean): Promise<Prepa
249244
steps: steps,
250245
migrationNeeded: migrationNeeded,
251246
automaticStepCount: automaticStepCount,
252-
manualStepCount: manualStepCount,
253247
ignoredStepCount: ignoredStepCount,
254248
partialMigration: partialMigration,
255249
}
@@ -320,9 +314,7 @@ export async function runMigration(
320314
}
321315
}
322316

323-
logger.info(
324-
`Migration: ${migration.automaticStepCount} automatic and ${migration.manualStepCount} manual steps (${migration.ignoredStepCount} ignored).`
325-
)
317+
logger.info(`Migration: ${migration.automaticStepCount} steps (${migration.ignoredStepCount} ignored).`)
326318

327319
for (const step of migration.steps) {
328320
try {
@@ -365,12 +357,12 @@ export async function runMigration(
365357

366358
let migrationCompleted = false
367359

368-
if (migration.manualStepCount === 0 && !warningMessages.length) {
360+
if (!warningMessages.length) {
369361
// continue automatically with the next batch
370362
logger.info('Migration: Automatically continuing with next batch..')
371363
migration.partialMigration = false
372364
const s = await getMigrationStatus()
373-
if (s.migration.automaticStepCount > 0 || s.migration.manualStepCount > 0) {
365+
if (s.migration.automaticStepCount > 0) {
374366
try {
375367
const res = await runMigration(s.migration.chunks, s.migration.hash, false, chunksLeft - 1)
376368
if (res.migrationCompleted) {
@@ -424,13 +416,10 @@ export async function getMigrationStatus(): Promise<GetMigrationStatusResult> {
424416
migrationNeeded: migration.migrationNeeded,
425417

426418
migration: {
427-
canDoAutomaticMigration: migration.manualStepCount === 0,
428-
429419
hash: migration.hash,
430420
chunks: migration.chunks,
431421

432422
automaticStepCount: migration.automaticStepCount,
433-
manualStepCount: migration.manualStepCount,
434423
ignoredStepCount: migration.ignoredStepCount,
435424
partialMigration: migration.partialMigration,
436425
},

meteor/server/migration/steps/X_X_X/ContainerIdsToObjectWithOverridesMigrationStep.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MigrationStepCore } from '@sofie-automation/blueprints-integration'
1+
import { MigrationStepCore } from '@sofie-automation/meteor-lib/dist/migrations'
22
import { Studios } from '../../../collections'
33
import {
44
convertObjectIntoOverrides,

packages/meteor-lib/src/api/migration.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@ export interface GetMigrationStatusResult {
101101
migrationNeeded: boolean
102102

103103
migration: {
104-
canDoAutomaticMigration: boolean
105104
hash: string
106105
automaticStepCount: number
107-
manualStepCount: number
108106
ignoredStepCount: number
109107
partialMigration: boolean
110108
chunks: Array<MigrationChunk>

packages/meteor-lib/src/migrations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface MigrationStepBase<TValidate extends ValidateFunction, TMigrate
1313
/**
1414
* The validate function determines whether the step is to be applied
1515
* (it can for example check that some value in the database is present)
16-
* The function should return falsy if step is fullfilled (ie truthy if migrate function should be applied, return value could then be a string describing why)
16+
* The function should return falsy if step is fulfilled (ie truthy if migrate function should be applied, return value could then be a string describing why)
1717
* The function is also run after the migration-script has been applied (and should therefore return false if all is good)
1818
*/
1919
validate: TValidate

packages/webui/src/client/ui/Settings/Migration.tsx

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ interface IState {
2424
showAllSteps: boolean
2525

2626
migration?: {
27-
canDoAutomaticMigration: boolean
2827
hash: string
2928
chunks: Array<MigrationChunk>
3029
automaticStepCount: number
3130
ignoredStepCount: number
32-
manualStepCount: number
3331
partialMigration: boolean
3432
}
3533
warnings: Array<string>
@@ -218,9 +216,10 @@ export const MigrationView = translateWithTracker<IProps, IState, ITrackedProps>
218216
<h2 className="my-4">{t('Migrate database')}</h2>
219217

220218
<p>
221-
{t(
222-
`This migration consists of ${this.state.migration.automaticStepCount} automatic steps and ${this.state.migration.manualStepCount} manual steps (${this.state.migration.ignoredStepCount} steps are ignored).`
223-
)}
219+
{t(`This migration consists of {{stepCount}} steps ({{ignoredStepCount}} steps are ignored).`, {
220+
stepCount: this.state.migration.automaticStepCount,
221+
ignoredStepCount: this.state.migration.ignoredStepCount,
222+
})}
224223
</p>
225224

226225
<table className="table expando migration-steps-table">
@@ -264,40 +263,17 @@ export const MigrationView = translateWithTracker<IProps, IState, ITrackedProps>
264263
)}
265264
</p>
266265
) : null}
267-
{this.state.migration.canDoAutomaticMigration ? (
268-
<div>
269-
<p>{t('The migration can be completed automatically.')}</p>
270-
<Button
271-
onClick={() => {
272-
this.runMigration()
273-
}}
274-
>
275-
<FontAwesomeIcon icon={faDatabase} className="me-2" />
276-
<span>{t('Run automatic migration procedure')}</span>
277-
</Button>
278-
</div>
279-
) : (
280-
<div>
281-
<p className="my-2">
282-
{t('The migration procedure needs some help from you in order to complete, see below:')}
283-
</p>
284-
<button
285-
className="btn btn-primary mt-4"
286-
onClick={() => {
287-
doModalDialog({
288-
title: t('Double-check Values'),
289-
message: t('Are you sure the values you have entered are correct?'),
290-
onAccept: () => {
291-
this.runMigration()
292-
},
293-
})
294-
}}
295-
>
296-
<FontAwesomeIcon icon={faClipboardCheck} className="me-2" />
297-
<span>{t('Run Migration Procedure')}</span>
298-
</button>
299-
</div>
300-
)}
266+
<div>
267+
<p>{t('The migration can be completed automatically.')}</p>
268+
<Button
269+
onClick={() => {
270+
this.runMigration()
271+
}}
272+
>
273+
<FontAwesomeIcon icon={faDatabase} className="me-2" />
274+
<span>{t('Run automatic migration procedure')}</span>
275+
</Button>
276+
</div>
301277

302278
{this.state.warnings.length ? (
303279
<div>

0 commit comments

Comments
 (0)