use lodash.once instead of memoize, and skip unnecessary PK index
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -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');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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');
|
||||
};
|
||||
|
||||
@@ -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';
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user