Skip to content

Commit

Permalink
feat(migrations): ✨ add migration for orders table
Browse files Browse the repository at this point in the history
This commit adds a migration file `2024_08_26_200728_create_orders_table.php` under the `database/migrations` directory. The migration creates the `orders` table with columns for `total_price`, `status`, `session_id`, and foreign keys for `UserAddress`, `created_by`, and `updated_by`. This migration is necessary to support the functionality related to orders in the application.
  • Loading branch information
samiulislamsharan committed Aug 27, 2024
1 parent d2a6f54 commit 6c3d5a0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions database/migrations/2024_08_26_200728_create_orders_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use App\Models\User;
use App\Models\UserAddress;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->decimal('total_price', 20, 2);
$table->string('status', 45);
$table->string('session_id', 225);
$table->foreignIdFor(UserAddress::class)->constrained()->cascadeOnUpdate()->cascadeOnDelete();
$table->foreignIdFor(User::class, 'created_by')->nullable();
$table->foreignIdFor(User::class, 'updated_by')->nullable();

$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('orders');
}
};

0 comments on commit 6c3d5a0

Please sign in to comment.