Skip to content

Commit

Permalink
feat: added migration task checks
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Oct 3, 2024
1 parent da42348 commit aef3a42
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/tasks/check-organization-subscriptions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SimpleIntervalJob, Task } from 'toad-scheduler';
import { getConfig } from '../utils/config-loader.js';
import { Organization } from '../models/index.js';
import { Meta, Organization } from '../models/index.js';
import {
getOwnedStores,
getSubscriptions,
Expand All @@ -11,6 +11,21 @@ import { logger } from '../config/logger.js';
const CONFIG = getConfig();

const task = new Task('check-oranization-subscriptions', async () => {
const hasMigratedToNewSyncMethod = await Meta.findOne({
where: { metaKey: 'migratedToNewSync' },
});

const hasMigratedToGenerationIndexSync = await Meta.findOne({
where: { metaKey: 'migratedToIndexBasedSync' },
});

if (!hasMigratedToGenerationIndexSync || !hasMigratedToNewSyncMethod) {
logger.debug(
'skipping check organization subscriptions task: waiting for migration tasks to complete',
);
return;
}

logger.debug('running check organization subscriptions task');

try {
Expand Down

0 comments on commit aef3a42

Please sign in to comment.