fix: migration for newly created self-hosting instances
This commit is contained in:
@@ -100,6 +100,9 @@ async function createOldSessions() {
|
|||||||
if (!row || row.count === '0') {
|
if (!row || row.count === '0') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (row.created_at.startsWith('1970')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new Date(row.created_at);
|
return new Date(row.created_at);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return defaultDate;
|
return defaultDate;
|
||||||
|
|||||||
@@ -139,7 +139,10 @@ export async function up() {
|
|||||||
const firstEventDateJson = await firstEventDateResponse.json<{
|
const firstEventDateJson = await firstEventDateResponse.json<{
|
||||||
created_at: string;
|
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);
|
const firstEventDate = new Date(firstEventDateJson[0]?.created_at);
|
||||||
// Step 2: Copy data from old tables to new tables (partitioned by month for efficiency)
|
// 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
|
// 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;
|
created_at: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
if (firstSessionDateJson[0]?.created_at) {
|
if (
|
||||||
|
firstSessionDateJson[0]?.created_at &&
|
||||||
|
!firstSessionDateJson[0]?.created_at.startsWith('1970')
|
||||||
|
) {
|
||||||
const firstSessionDate = new Date(
|
const firstSessionDate = new Date(
|
||||||
firstSessionDateJson[0]?.created_at ?? '',
|
firstSessionDateJson[0]?.created_at ?? '',
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user