Преглед изворни кода

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

Pouria Ezzati пре 1 година
родитељ
комит
f6a8d7a325
1 измењених фајлова са 5 додато и 2 уклоњено
  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;