improve: prepare for coolify and general self-hosting improvements (#175)

* fix(self-hosting): improve docker compose, add healthchecks, rename env SELF_HOSTED

* improve(db): improve initial migration when no data exists

* fix(db): misstakes were made

* improve(dashboard): better curl preview depending on project type

* fix(db): fix migrations

* fix(onboarding): ensure we publish event correctly

* wip

* fix: curl preview

* add coolify template

* fix(dashboard): page -> route

* fix

* fix env
This commit is contained in:
Carl-Gerhard Lindesvärd
2025-06-23 22:21:11 +02:00
committed by GitHub
parent 4a2dbc5c4d
commit 92d62c3e5c
22 changed files with 382 additions and 60 deletions

View File

@@ -1,7 +1,8 @@
import fs from 'node:fs';
import path from 'node:path';
import { formatClickhouseDate } from '../src/clickhouse/client';
import { TABLE_NAMES, formatClickhouseDate } from '../src/clickhouse/client';
import {
chMigrationClient,
createTable,
runClickhouseMigrationCommands,
} from '../src/clickhouse/migration';
@@ -66,7 +67,7 @@ export async function up() {
}),
];
sqls.push(...createOldSessions());
sqls.push(...(await createOldSessions()));
fs.writeFileSync(
path.join(__filename.replace('.ts', '.sql')),
@@ -86,8 +87,31 @@ export async function up() {
}
}
function createOldSessions() {
let startDate = new Date('2024-03-01');
async function createOldSessions() {
async function getFirstEventAt() {
const defaultDate = new Date('2024-03-01');
try {
const res = await chMigrationClient.query({
query: `SELECT min(created_at) as created_at, count() as count FROM ${TABLE_NAMES.events}`,
format: 'JSONEachRow',
});
const json = await res.json<{ created_at: string; count: string }>();
const row = json[0];
if (!row || row.count === '0') {
return null;
}
return new Date(row.created_at);
} catch (e) {
return defaultDate;
}
}
let startDate = await getFirstEventAt();
if (!startDate) {
return [];
}
const endDate = new Date();
const sqls: string[] = [];
while (startDate <= endDate) {