fix: migration for newly created self-hosting instances

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-12-16 22:08:25 +01:00
parent 1e4f02fb5e
commit ea6b69d3ec
2 changed files with 11 additions and 2 deletions

View File

@@ -100,6 +100,9 @@ async function createOldSessions() {
if (!row || row.count === '0') {
return null;
}
if (row.created_at.startsWith('1970')) {
return null;
}
return new Date(row.created_at);
} catch (e) {
return defaultDate;

View File

@@ -139,7 +139,10 @@ export async function up() {
const firstEventDateJson = await firstEventDateResponse.json<{
created_at: string;
}>();
if (firstEventDateJson[0]?.created_at) {
if (
firstEventDateJson[0]?.created_at &&
!firstEventDateJson[0]?.created_at.startsWith('1970')
) {
const firstEventDate = new Date(firstEventDateJson[0]?.created_at);
// Step 2: Copy data from old tables to new tables (partitioned by month for efficiency)
// Set endDate to first of next month to ensure we capture all data in the current month
@@ -174,7 +177,10 @@ export async function up() {
created_at: string;
}>();
if (firstSessionDateJson[0]?.created_at) {
if (
firstSessionDateJson[0]?.created_at &&
!firstSessionDateJson[0]?.created_at.startsWith('1970')
) {
const firstSessionDate = new Date(
firstSessionDateJson[0]?.created_at ?? '',
);