Skip to content

Commit

Permalink
use lodash.once instead of memoize, and skip unnecessary PK index
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
freben committed Nov 11, 2021
1 parent e72d9ba commit 3f447ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 0 additions & 4 deletions packages/backend-tasks/migrations/20210928160613_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ exports.up = async function up(knex) {
.dateTime('current_run_expires_at')
.nullable()
.comment('The time that the current task run will time out');
table.index(['id'], 'backstage_backend_tasks__tasks__id_idx');
});
};

Expand All @@ -61,8 +60,5 @@ exports.down = async function down(knex) {
//
// tasks
//
await knex.schema.alterTable('backstage_backend_tasks__tasks', table => {
table.dropIndex([], 'backstage_backend_tasks__tasks__id_idx');
});
await knex.schema.dropTable('backstage_backend_tasks__tasks');
};
4 changes: 2 additions & 2 deletions packages/backend-tasks/src/tasks/TaskScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { DatabaseManager, getRootLogger } from '@backstage/backend-common';
import { Config } from '@backstage/config';
import { memoize } from 'lodash';
import { once } from 'lodash';
import { Duration } from 'luxon';
import { Logger } from 'winston';
import { migrateBackendTasks } from '../database/migrateBackendTasks';
Expand Down Expand Up @@ -57,7 +57,7 @@ export class TaskScheduler {
* @returns A {@link PluginTaskScheduler} instance
*/
forPlugin(pluginId: string): PluginTaskScheduler {
const databaseFactory = memoize(async () => {
const databaseFactory = once(async () => {
const knex = await this.databaseManager.forPlugin(pluginId).getClient();

await migrateBackendTasks(knex);
Expand Down

0 comments on commit 3f447ec

Please sign in to comment.