2018_03_15_232344_create_customer_subscription_table.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateCustomerSubscriptionTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::table('customers', function (Blueprint $table) {
  15. $table->string('stripe_id')->nullable()->after('status');
  16. $table->string('card_brand')->nullable()->after('stripe_id');
  17. $table->string('card_last_four')->nullable()->after('card_brand');
  18. $table->timestamp('trial_ends_at')->nullable()->after('card_last_four');
  19. });
  20. Schema::create('subscriptions', function (Blueprint $table) {
  21. $table->increments('id');
  22. $table->unsignedInteger('customer_id');
  23. $table->string('name');
  24. $table->string('stripe_id');
  25. $table->string('stripe_plan');
  26. $table->integer('quantity');
  27. $table->timestamp('trial_ends_at')->nullable();
  28. $table->timestamp('ends_at')->nullable();
  29. $table->timestamps();
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. *
  35. * @return void
  36. */
  37. public function down()
  38. {
  39. Schema::dropIfExists('subscriptions');
  40. Schema::table('customers', function (Blueprint $table) {
  41. $table->dropColumn([
  42. 'stripe_id',
  43. 'card_brand',
  44. 'card_last_four',
  45. 'trial_ends_at'
  46. ]);
  47. });
  48. }
  49. }