feat: migrate to existing config value (#16030)
This commit is contained in:
parent
557239da80
commit
3dde7f1ac4
|
@ -3,13 +3,17 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {loadConfig} from "./js/migration-config.js";
|
||||||
|
|
||||||
export class MigrateSomeConfigFileSettingsToMeta1746949539915 {
|
export class MigrateSomeConfigFileSettingsToMeta1746949539915 {
|
||||||
name = 'MigrateSomeConfigFileSettingsToMeta1746949539915'
|
name = 'MigrateSomeConfigFileSettingsToMeta1746949539915'
|
||||||
|
|
||||||
async up(queryRunner) {
|
async up(queryRunner) {
|
||||||
await queryRunner.query(`ALTER TABLE "meta" ADD "proxyRemoteFiles" boolean NOT NULL DEFAULT true`);
|
const config = loadConfig();
|
||||||
await queryRunner.query(`ALTER TABLE "meta" ADD "signToActivityPubGet" boolean NOT NULL DEFAULT true`);
|
// $1 cannot be used in ALTER TABLE queries
|
||||||
await queryRunner.query(`ALTER TABLE "meta" ADD "allowExternalApRedirect" boolean NOT NULL DEFAULT true`);
|
await queryRunner.query(`ALTER TABLE "meta" ADD "proxyRemoteFiles" boolean NOT NULL DEFAULT ${config.proxyRemoteFiles}`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "signToActivityPubGet" boolean NOT NULL DEFAULT ${config.signToActivityPubGet}`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "allowExternalApRedirect" boolean NOT NULL DEFAULT ${!config.disallowExternalApRedirect}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async down(queryRunner) {
|
async down(queryRunner) {
|
||||||
|
|
|
@ -3,6 +3,29 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { path as configYamlPath } from '../../built/config.js';
|
||||||
|
import * as yaml from 'js-yaml';
|
||||||
|
import fs from "node:fs";
|
||||||
|
|
||||||
export function isConcurrentIndexMigrationEnabled() {
|
export function isConcurrentIndexMigrationEnabled() {
|
||||||
return process.env.MISSKEY_MIGRATION_CREATE_INDEX_CONCURRENTLY === '1';
|
return process.env.MISSKEY_MIGRATION_CREATE_INDEX_CONCURRENTLY === '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let loadedConfigCache = undefined;
|
||||||
|
|
||||||
|
function loadConfigInternal() {
|
||||||
|
const config = yaml.load(fs.readFileSync(configYamlPath, 'utf-8'));
|
||||||
|
|
||||||
|
return {
|
||||||
|
disallowExternalApRedirect: Boolean(config.disallowExternalApRedirect ?? false),
|
||||||
|
proxyRemoteFiles: Boolean(config.proxyRemoteFiles ?? false),
|
||||||
|
signToActivityPubGet: Boolean(config.signToActivityPubGet ?? true),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadConfig() {
|
||||||
|
if (loadedConfigCache === undefined) {
|
||||||
|
loadedConfigCache = loadConfigInternal();
|
||||||
|
}
|
||||||
|
return loadedConfigCache;
|
||||||
|
}
|
||||||
|
|
|
@ -222,7 +222,7 @@ const dir = `${_dirname}/../../../.config`;
|
||||||
/**
|
/**
|
||||||
* Path of configuration file
|
* Path of configuration file
|
||||||
*/
|
*/
|
||||||
const path = process.env.MISSKEY_CONFIG_YML
|
export const path = process.env.MISSKEY_CONFIG_YML
|
||||||
? resolve(dir, process.env.MISSKEY_CONFIG_YML)
|
? resolve(dir, process.env.MISSKEY_CONFIG_YML)
|
||||||
: process.env.NODE_ENV === 'test'
|
: process.env.NODE_ENV === 'test'
|
||||||
? resolve(dir, 'test.yml')
|
? resolve(dir, 'test.yml')
|
||||||
|
|
Loading…
Reference in New Issue