浏览代码

add migration field

父节点
当前提交
a83babb1ab

+ 11
- 0
app/Models/Topup.php 查看文件

@@ -0,0 +1,11 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Factories\HasFactory;
6
+use Illuminate\Database\Eloquent\Model;
7
+
8
+class Topup extends Model
9
+{
10
+    use HasFactory;
11
+}

+ 11
- 0
app/Models/TypeMember.php 查看文件

@@ -0,0 +1,11 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Factories\HasFactory;
6
+use Illuminate\Database\Eloquent\Model;
7
+
8
+class TypeMember extends Model
9
+{
10
+    use HasFactory;
11
+}

+ 33
- 0
database/migrations/2022_04_20_031727_create_type_members_table.php 查看文件

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     *
12
+     * @return void
13
+     */
14
+    public function up()
15
+    {
16
+        Schema::create('type_members', function (Blueprint $table) {
17
+            $table->id();
18
+            $table->string('name');
19
+            $table->unsignedInteger('price');
20
+            $table->timestamps();
21
+        });
22
+    }
23
+
24
+    /**
25
+     * Reverse the migrations.
26
+     *
27
+     * @return void
28
+     */
29
+    public function down()
30
+    {
31
+        Schema::dropIfExists('type_members');
32
+    }
33
+};

+ 1
- 0
database/migrations/2022_04_20_031728_create_members_table.php 查看文件

@@ -18,6 +18,7 @@ return new class extends Migration
18 18
             $table->string('name');
19 19
             $table->string('phone')->unique();
20 20
             $table->string('plat_number')->unique();
21
+            $table->foreignId('type_member_id')->constrained();
21 22
             $table->timestamps();
22 23
         });
23 24
     }

+ 35
- 0
database/migrations/2022_04_20_031728_create_topups_table.php 查看文件

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     *
12
+     * @return void
13
+     */
14
+    public function up()
15
+    {
16
+        Schema::create('topups', function (Blueprint $table) {
17
+            $table->id();
18
+            $table->unsignedInteger('amount');
19
+            $table->dateTime('exp_date');
20
+            $table->foreignId('member_id')->constrained();
21
+            $table->foreignId('user_id')->constrained();
22
+            $table->timestamps();
23
+        });
24
+    }
25
+
26
+    /**
27
+     * Reverse the migrations.
28
+     *
29
+     * @return void
30
+     */
31
+    public function down()
32
+    {
33
+        Schema::dropIfExists('topups');
34
+    }
35
+};

+ 1
- 0
database/migrations/2022_04_20_031729_create_mutations_table.php 查看文件

@@ -19,6 +19,7 @@ return new class extends Migration
19 19
             $table->unsignedInteger('amount');
20 20
             $table->foreignId('transaction_id')->nullable()->default(null)->constrained();
21 21
             $table->foreignId('expense_id')->nullable()->default(null)->constrained();
22
+            $table->foreignId('topup_id')->nullable()->default(null)->constrained();
22 23
             $table->timestamps();
23 24
         });
24 25
     }

+ 2
- 2
designs/diagrams/database.puml 查看文件

@@ -75,9 +75,9 @@ entity Mutation {
75 75
 entity TopUp {
76 76
   * id
77 77
   __
78
-  * member_id
79
-  * value
78
+  * amount
80 79
   * exp_date
80
+  * member_id
81 81
   * user_id
82 82
 }
83 83
 

二进制
designs/diagrams/database/Database.png 查看文件