Merge pull request #1474 from balena-io/1468-db-deadlock

Fix supervisor deadlock during migration
This commit is contained in:
bulldozer-balena[bot] 2020-09-29 08:06:55 +00:00 committed by GitHub
commit 74058b973e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,3 @@
import { generateScopedKey } from '../lib/api-keys';
export async function up(knex) {
// Create a new table to hold the api keys
await knex.schema.createTable('apiSecret', (table) => {
@ -13,18 +11,6 @@ export async function up(knex) {
// Delete any existing API secrets
await knex('config').where({ key: 'apiSecret' }).del();
// Add an api secret per service in the db
const apps = await knex('app');
for (const app of apps) {
const appId = app.appId;
const services = JSON.parse(app.services);
for (const service of services) {
const serviceId = service.id;
await generateScopedKey(appId, serviceId);
}
}
}
export function down() {