mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
fix(core): Support MySQL in MoveSshKeysToDatabase
migration (#9120)
This commit is contained in:
parent
284de5d6c7
commit
cf435c3311
|
@ -36,9 +36,11 @@ export class MoveSshKeysToDatabase1711390882123 implements ReversibleMigration {
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings = escape.tableName('settings');
|
const settings = escape.tableName('settings');
|
||||||
|
const key = escape.columnName('key');
|
||||||
|
const value = escape.columnName('value');
|
||||||
|
|
||||||
const rows: Array<{ value: string }> = await runQuery(
|
const rows: Array<{ value: string }> = await runQuery(
|
||||||
`SELECT value FROM ${settings} WHERE key = '${this.settingsKey}';`,
|
`SELECT value FROM ${settings} WHERE ${key} = '${this.settingsKey}';`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rows.length === 1) {
|
if (rows.length === 1) {
|
||||||
|
@ -51,13 +53,13 @@ export class MoveSshKeysToDatabase1711390882123 implements ReversibleMigration {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = JSON.stringify({
|
const settingsValue = JSON.stringify({
|
||||||
encryptedPrivateKey: this.cipher.encrypt(privateKey),
|
encryptedPrivateKey: this.cipher.encrypt(privateKey),
|
||||||
publicKey,
|
publicKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
await runQuery(
|
await runQuery(
|
||||||
`INSERT INTO ${settings} (key, value) VALUES ('${this.settingsKey}', '${value}');`,
|
`INSERT INTO ${settings} (${key}, ${value}) VALUES ('${this.settingsKey}', '${settingsValue}');`,
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -72,9 +74,10 @@ export class MoveSshKeysToDatabase1711390882123 implements ReversibleMigration {
|
||||||
|
|
||||||
async down({ escape, runQuery, logger, migrationName }: MigrationContext) {
|
async down({ escape, runQuery, logger, migrationName }: MigrationContext) {
|
||||||
const settings = escape.tableName('settings');
|
const settings = escape.tableName('settings');
|
||||||
|
const key = escape.columnName('key');
|
||||||
|
|
||||||
const rows: Array<{ value: string }> = await runQuery(
|
const rows: Array<{ value: string }> = await runQuery(
|
||||||
`SELECT value FROM ${settings} WHERE key = '${this.settingsKey}';`,
|
`SELECT value FROM ${settings} WHERE ${key} = '${this.settingsKey}';`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (rows.length !== 1) {
|
if (rows.length !== 1) {
|
||||||
|
@ -106,6 +109,6 @@ export class MoveSshKeysToDatabase1711390882123 implements ReversibleMigration {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await runQuery(`DELETE ${settings} WHERE WHERE key = 'features.sourceControl.sshKeys';`);
|
await runQuery(`DELETE FROM ${settings} WHERE ${key} = 'features.sourceControl.sshKeys';`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue