database/migrations/2020_01_01_000004_create_plan_subscription_usage_table.php
<?php
declare(strict_types=1);
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePlanSubscriptionUsageTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create(config('rinvex.subscriptions.tables.plan_subscription_usage'), function (Blueprint $table) {
$table->increments('id');
$table->integer('subscription_id')->unsigned();
$table->integer('feature_id')->unsigned();
$table->smallInteger('used')->unsigned();
$table->dateTime('valid_until')->nullable();
$table->string('timezone')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['subscription_id', 'feature_id']);
$table->foreign('subscription_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_subscriptions'))
->onDelete('cascade')->onUpdate('cascade');
$table->foreign('feature_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_features'))
->onDelete('cascade')->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscription_usage'));
}
}