whoami7 - Manager
:
/
home
/
kckglobal
/
.trash
/
database
/
migrations
/
Upload File:
files >> /home/kckglobal/.trash/database/migrations/2022_12_29_084526_create_subscriptions_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use App\Models\Company; use App\Models\GlobalSetting; return new class extends Migration { public function up() { if (!Schema::hasColumn('users', 'stripe_id')) { Schema::table('users', function (Blueprint $table) { $table->string('stripe_id')->nullable()->index(); $table->string('pm_type')->nullable(); $table->string('pm_last_four', 4)->nullable(); $table->timestamp('trial_ends_at')->nullable(); }); } if (!Schema::hasTable('subscriptions')) { Schema::create('subscriptions', function (Blueprint $table) { $table->id(); $table->integer('company_id')->unsigned()->nullable(); $table->foreign('company_id') ->references('id') ->on('companies') ->onDelete('cascade') ->onUpdate('cascade'); $table->integer('user_id')->unsigned()->nullable(); $table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL')->onUpdate('cascade'); $table->string('name'); $table->string('stripe_id')->unique(); $table->string('stripe_status'); $table->string('stripe_price')->nullable(); $table->integer('quantity')->nullable(); $table->timestamp('trial_ends_at')->nullable(); $table->timestamp('ends_at')->nullable(); $table->timestamps(); $table->index(['user_id', 'stripe_status']); }); Schema::create('subscription_items', function (Blueprint $table) { $table->id(); $table->foreignId('subscription_id'); $table->string('stripe_id')->unique(); $table->string('stripe_product'); $table->string('stripe_price'); $table->integer('quantity')->nullable(); $table->timestamps(); $table->unique(['subscription_id', 'stripe_price']); }); } if (!Schema::hasColumn('subscriptions', 'company_id')) { Schema::table('subscriptions', function (Blueprint $table) { $table->integer('company_id')->unsigned()->nullable()->after('id'); $table->foreign('company_id') ->references('id') ->on('companies') ->onDelete('cascade') ->onUpdate('cascade'); }); } } public function down() { Schema::dropIfExists('subscriptions'); Schema::dropIfExists('subscription_items'); } };
Copyright ©2021 || Defacer Indonesia