diff options
author | Sam Light <samlight1994@gmail.com> | 2025-03-28 01:07:59 +0000 |
---|---|---|
committer | Sam Light <samlight1994@gmail.com> | 2025-03-28 01:07:59 +0000 |
commit | 80a183a94bd344c3ac08109019fdc7d341a57a6e (patch) | |
tree | 94430858a1a39219fe73f83b4c85e0f5cd3a0b1c /workbench/database/migrations | |
parent | 1f81ce361cb454b1655d6e2a7ac031bc1e3b2ede (diff) |
Setup categories table, model and factory
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'); + }); + + } +}; |