Quellcode durchsuchen

KeyValues 表初始化

ANG YU vor 5 Jahren
Ursprung
Commit
5211fd952f

+ 11 - 0
app/KeyValues.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class KeyValues extends Model
+{
+    //
+    protected $fillable = ['key', 'value',];
+}

+ 33 - 0
database/migrations/2020_11_20_101212_create_key_values_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateKeyValuesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('key_values', function (Blueprint $table) {
+            $table->id();
+            $table->string('key');
+            $table->timestamp('value', 0)->nullable()->index();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('key_values');
+    }
+}

+ 53 - 0
database/migrations/2020_11_20_101353_seed_key_values_table.php

@@ -0,0 +1,53 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class SeedKeyValuesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        \App\KeyValues::create([
+            'key' => 'order_last_created_sync_at',
+            'value' => null,
+        ]);
+        \App\KeyValues::create([
+            'key' => 'order_last_updated_sync_at',
+            'value' => null,
+        ]);
+
+        \App\KeyValues::create([
+            'key' => 'commodity_last_created_sync_at',
+            'value' => null,
+        ]);
+        \App\KeyValues::create([
+            'key' => 'commodity_last_updated_sync_at',
+            'value' => null,
+        ]);
+
+        \App\KeyValues::create([
+            'key' => 'asn_last_created_sync_at',
+            'value' => null,
+        ]);
+        \App\KeyValues::create([
+            'key' => 'asn_last_updated_sync_at',
+            'value' => null,
+        ]);
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}