fix: option to allow cluster migrations without relying on self hosting env
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
renameTable,
|
||||
runClickhouseMigrationCommands,
|
||||
} from '../src/clickhouse/migration';
|
||||
import { getIsSelfHosting, printBoxMessage } from './helpers';
|
||||
import { getIsCluster, getIsSelfHosting, printBoxMessage } from './helpers';
|
||||
|
||||
export async function up() {
|
||||
const replicatedVersion = '1';
|
||||
@@ -31,7 +31,7 @@ export async function up() {
|
||||
);
|
||||
|
||||
const isSelfHosting = getIsSelfHosting();
|
||||
const isClustered = !isSelfHosting;
|
||||
const isClustered = getIsCluster();
|
||||
|
||||
const isSelfHostingPostCluster =
|
||||
existingTables.includes('events_replicated') && isSelfHosting;
|
||||
@@ -58,7 +58,7 @@ export async function up() {
|
||||
return renameTable({
|
||||
from: table,
|
||||
to: `${table}_tmp`,
|
||||
isClustered: false,
|
||||
isClustered,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -16,11 +16,11 @@ export function printBoxMessage(title: string, lines: (string | unknown)[]) {
|
||||
|
||||
export function getIsCluster() {
|
||||
const args = process.argv;
|
||||
const noClusterArg = args.includes('--no-cluster');
|
||||
if (noClusterArg) {
|
||||
return false;
|
||||
}
|
||||
return !getIsSelfHosting();
|
||||
return (
|
||||
args.includes('--cluster') ||
|
||||
process.env.CLICKHOUSE_CLUSTER === 'true' ||
|
||||
process.env.CLICKHOUSE_CLUSTER === '1'
|
||||
);
|
||||
}
|
||||
|
||||
export function getIsSelfHosting() {
|
||||
|
||||
@@ -6,7 +6,12 @@ import { fileURLToPath } from 'node:url';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
import { db } from '../index';
|
||||
import { getIsDry, getIsSelfHosting, printBoxMessage } from './helpers';
|
||||
import {
|
||||
getIsCluster,
|
||||
getIsDry,
|
||||
getIsSelfHosting,
|
||||
printBoxMessage,
|
||||
} from './helpers';
|
||||
|
||||
async function migrate() {
|
||||
const args = process.argv.slice(2);
|
||||
@@ -39,6 +44,11 @@ async function migrate() {
|
||||
.map((migration) => `\t- ${migration}`),
|
||||
]);
|
||||
|
||||
printBoxMessage('🤝 Config', [
|
||||
`isClustered: ${getIsCluster()}`,
|
||||
`isSelfHosting: ${getIsSelfHosting()}`,
|
||||
]);
|
||||
|
||||
printBoxMessage('🌍 Environment', [
|
||||
`POSTGRES: ${process.env.DATABASE_URL}`,
|
||||
`CLICKHOUSE: ${process.env.CLICKHOUSE_URL}`,
|
||||
|
||||
Reference in New Issue
Block a user