@@ -139,8 +139,8 @@ export async function up() {
139139 const firstEventDateJson = await firstEventDateResponse . json < {
140140 created_at : string ;
141141 } > ( ) ;
142- const firstEventDate = new Date ( firstEventDateJson [ 0 ] ?. created_at ?? '' ) ;
143- if ( firstEventDate ) {
142+ if ( firstEventDateJson [ 0 ] ?. created_at ) {
143+ const firstEventDate = new Date ( firstEventDateJson [ 0 ] ?. created_at ) ;
144144 // Step 2: Copy data from old tables to new tables (partitioned by month for efficiency)
145145 // Set endDate to first of next month to ensure we capture all data in the current month
146146 const endDate = new Date ( ) ;
@@ -174,8 +174,10 @@ export async function up() {
174174 created_at : string ;
175175 } > ( ) ;
176176
177- const firstSessionDate = new Date ( firstSessionDateJson [ 0 ] ?. created_at ?? '' ) ;
178- if ( firstSessionDate ) {
177+ if ( firstSessionDateJson [ 0 ] ?. created_at ) {
178+ const firstSessionDate = new Date (
179+ firstSessionDateJson [ 0 ] ?. created_at ?? '' ,
180+ ) ;
179181 // Set endDate to first of next month to ensure we capture all data in the current month
180182 const endDate = new Date ( ) ;
181183 endDate . setMonth ( endDate . getMonth ( ) + 1 ) ;
@@ -249,11 +251,11 @@ export async function up() {
249251 if ( isClustered && sessionTables [ 1 ] && eventTables [ 1 ] ) {
250252 sqls . push (
251253 // Drop temporary DISTRIBUTED tables (will be recreated)
252- ' DROP TABLE IF EXISTS events_new_20251123 ON CLUSTER " {cluster}"' ,
253- ' DROP TABLE IF EXISTS sessions_new_20251123 ON CLUSTER " {cluster}"' ,
254+ ` DROP TABLE IF EXISTS events_new_20251123 ON CLUSTER ' {cluster}'` ,
255+ ` DROP TABLE IF EXISTS sessions_new_20251123 ON CLUSTER ' {cluster}'` ,
254256 // Rename new tables to correct names
255- ' RENAME TABLE events_new_20251123_replicated TO events_replicated ON CLUSTER " {cluster}"' ,
256- ' RENAME TABLE sessions_new_20251123_replicated TO sessions_replicated ON CLUSTER " {cluster}"' ,
257+ ` RENAME TABLE events_new_20251123_replicated TO events_replicated ON CLUSTER ' {cluster}'` ,
258+ ` RENAME TABLE sessions_new_20251123_replicated TO sessions_replicated ON CLUSTER ' {cluster}'` ,
257259 // Create new distributed tables
258260 eventTables [ 1 ] . replaceAll ( 'events_new_20251123' , 'events' ) , // creates a new distributed table
259261 sessionTables [ 1 ] . replaceAll ( 'sessions_new_20251123' , 'sessions' ) , // creates a new distributed table
0 commit comments