Forráskód Böngészése

fix trying to updates visits with user_id when there are no visits to update

Pouria Ezzati 1 éve
szülő
commit
f6a8d7a325
1 módosított fájl, 5 hozzáadás és 2 törlés
  1. 5 2
      server/migrations/20241223103044_visits_user_id.js

+ 5 - 2
server/migrations/20241223103044_visits_user_id.js

@@ -20,8 +20,11 @@ async function up(knex) {
   });
 
   const [{ count }] = await knex("visits").count("* as count");
-  
-  if (count < 1_000_000) {
+
+  const count_number = parseInt(count);
+  if (Number.isNaN(count_number) || count_number === 0) return;
+    
+  if (count_number < 1_000_000) {
     const last_visit = await knex("visits").orderBy("id", "desc").first();
 
     const size = 100_000;