CreatePlanSubscriptionUsageTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
use Illuminate\Database\Schema\Blueprint;
6
use Illuminate\Database\Migrations\Migration;
7
8
class CreatePlanSubscriptionUsageTable extends Migration
9
{
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up(): void
16
    {
17
        Schema::create(config('rinvex.subscriptions.tables.plan_subscription_usage'), function (Blueprint $table) {
18
            $table->increments('id');
19
            $table->integer('subscription_id')->unsigned();
20
            $table->integer('feature_id')->unsigned();
21
            $table->smallInteger('used')->unsigned();
22
            $table->dateTime('valid_until')->nullable();
23
            $table->string('timezone')->nullable();
24
            $table->timestamps();
25
            $table->softDeletes();
26
27
            $table->unique(['subscription_id', 'feature_id']);
28
            $table->foreign('subscription_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_subscriptions'))
29
                  ->onDelete('cascade')->onUpdate('cascade');
30
            $table->foreign('feature_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_features'))
31
                  ->onDelete('cascade')->onUpdate('cascade');
32
        });
33
    }
34
35
    /**
36
     * Reverse the migrations.
37
     *
38
     * @return void
39
     */
40
    public function down(): void
41
    {
42
        Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscription_usage'));
43
    }
44
}
45