1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Database\Migrations\Migration;
- class CreateCustomerSubscriptionTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::table('customers', function (Blueprint $table) {
- $table->string('stripe_id')->nullable()->after('status');
- $table->string('card_brand')->nullable()->after('stripe_id');
- $table->string('card_last_four')->nullable()->after('card_brand');
- $table->timestamp('trial_ends_at')->nullable()->after('card_last_four');
- });
- Schema::create('subscriptions', function (Blueprint $table) {
- $table->increments('id');
- $table->unsignedInteger('customer_id');
- $table->string('name');
- $table->string('stripe_id');
- $table->string('stripe_plan');
- $table->integer('quantity');
- $table->timestamp('trial_ends_at')->nullable();
- $table->timestamp('ends_at')->nullable();
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('subscriptions');
- Schema::table('customers', function (Blueprint $table) {
- $table->dropColumn([
- 'stripe_id',
- 'card_brand',
- 'card_last_four',
- 'trial_ends_at'
- ]);
- });
- }
- }
|