浏览代码

feat: ✨ Added Migration -> Column Billing Period

IceToast 3 年之前
父节点
当前提交
8f38b9e023
共有 1 个文件被更改,包括 35 次插入0 次删除
  1. 35 0
      database/migrations/2022_06_16_092704_add_billing_period_to_products.php

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

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
+
+class AddBillingPeriodToProducts extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('products', function (Blueprint $table) {
+            $table->string('billing_period')->default("hourly");
+        });
+
+        DB::statement('UPDATE products SET billing_period="hourly"');
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('products', function (Blueprint $table) {
+            $table->dropColumn('billing_period');
+        });
+    }
+}