diff options
Diffstat (limited to 'workbench/database/migrations')
-rw-r--r-- | workbench/database/migrations/2025_03_27_211321_create_categories_table.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/workbench/database/migrations/2025_03_27_211321_create_categories_table.php b/workbench/database/migrations/2025_03_27_211321_create_categories_table.php new file mode 100644 index 0000000..5a75f30 --- /dev/null +++ b/workbench/database/migrations/2025_03_27_211321_create_categories_table.php @@ -0,0 +1,38 @@ +<?php + +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('categories', function (Blueprint $table) { + $table->id(); + $table->string('name'); + $table->timestamps(); + $table->softDeletes(); + }); + + Schema::table('products', function (Blueprint $table) { + $table->foreignId('category_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('categories'); + + Schema::table('products', function (Blueprint $table) { + $table->dropColumn('category_id'); + }); + + } +}; |