CreateTransactionsTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 15
nc 1
nop 0
dl 0
loc 18
c 3
b 0
f 0
cc 1
rs 9.7666
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateTransactionsTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('transactions', function (Blueprint $table) {
17
            $table->bigIncrements('id');
18
            $table->unsignedBigInteger('donator_id');
19
            $table->unsignedBigInteger('campaign_id');
20
            $table->unsignedBigInteger('subscription_id')->nullable();
21
            $table->string('payment_gateway');
22
            $table->string('payment_gateway_transaction_id')->comment('Native trsanction ID on PG');
23
            $table->unsignedBigInteger('amount')->comment('Amount in cents');
24
            $table->string('currency', 3);
25
            $table->string('status');
26
            $table->string('status_message');
27
            $table->timestamps();
28
29
            $table->foreign('donator_id')->references('id')->on('donators');
30
            $table->foreign('campaign_id')->references('id')->on('campaigns');
31
            $table->foreign('subscription_id')->references('id')->on('subscriptions');
32
        });
33
    }
34
35
    /**
36
     * Reverse the migrations.
37
     *
38
     * @return void
39
     */
40
    public function down()
41
    {
42
        Schema::dropIfExists('transactions');
43
    }
44
}
45