Browse Source

fix: ✨ Updated Migration to calculate hourly price from existing products

IceToast 3 years ago
parent
commit
950278c948

+ 8 - 0
database/migrations/2022_06_16_092704_add_billing_period_to_products.php

@@ -19,6 +19,14 @@ class AddBillingPeriodToProducts extends Migration
         });
 
         DB::statement('UPDATE products SET billing_period="hourly"');
+
+        $products = DB::table('products')->get();
+        foreach ($products as $product) {
+            $price = $product->price;
+            $price = $price / 30 / 24;
+            DB::table('products')->where('id', $product->id)->update(['price' => $price]);
+        }
+
     }
 
     /**