diff --git a/database/migrations/2023_04_01_000000_create_payment_methods_table.php b/database/migrations/2023_04_01_000000_create_payment_methods_table.php new file mode 100644 index 0000000..9954270 --- /dev/null +++ b/database/migrations/2023_04_01_000000_create_payment_methods_table.php @@ -0,0 +1,36 @@ +<?php + +use Illuminate\Support\Facades\Schema; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreatePaymentMethodsTable extends Migration +{ + /** + * Run the migrations. + */ + public function up() + { + Schema::create('payment_methods', function (Blueprint $table) { + $table->id(); + $table->unsignedBigInteger('user_id'); + $table->string('name'); + $table->text('details'); + $table->boolean('is_default')->default(false); + + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::table('payment_methods', function (Blueprint $table) { + $table->dropForeign(['user_id']); + }); + Schema::dropIfExists('payment_methods'); + } +}