diff options
| author | Sam Light <samlight1994@gmail.com> | 2026-02-10 00:21:10 +0000 |
|---|---|---|
| committer | Sam Light <samlight1994@gmail.com> | 2026-02-10 00:21:10 +0000 |
| commit | ad1c06ee1819b3512e2443d5cbe06199a0ae9bad (patch) | |
| tree | b873596f86173c70c29decc301397d716ad7ca8d /workbench/database/migrations | |
| parent | 47c3c4b4e772c30dac12169300e20346fa47b71f (diff) | |
Created order tables and models
Diffstat (limited to 'workbench/database/migrations')
| -rw-r--r-- | workbench/database/migrations/2025_04_01_000000_create_orders_table.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/workbench/database/migrations/2025_04_01_000000_create_orders_table.php b/workbench/database/migrations/2025_04_01_000000_create_orders_table.php new file mode 100644 index 0000000..838349c --- /dev/null +++ b/workbench/database/migrations/2025_04_01_000000_create_orders_table.php @@ -0,0 +1,40 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; +use Workbench\App\Enums\OrderStatus; + +return new class extends Migration +{ + /** + * Run the migrations. + */ + public function up(): void + { + Schema::create('orders', function (Blueprint $table) { + $table->id(); + $table->enum('status', OrderStatus::cases()); + $table->decimal('total', total: 10, places: 2); + $table->timestamps(); + }); + + Schema::create('order_product', function (Blueprint $table) { + $table->id(); + $table->foreignId('order_id')->constrained()->cascadeOnDelete(); + $table->foreignId('product_id')->constrained()->cascadeOnDelete(); + $table->unsignedInteger('quantity'); + $table->decimal('price', total: 8, places: 2); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('order_product'); + Schema::dropIfExists('orders'); + } +}; |
