1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?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('items', function (Blueprint $table) {
- $table->id();
- $table->foreignId('company_id')->constrained()->cascadeOnDelete();
- $table->string('type'); // product, service
- $table->string('name');
- $table->string('sku')->unique();
- $table->string('description')->nullable();
- $table->decimal('sale_price', 15, 4);
- $table->decimal('purchase_price', 15, 4);
- $table->integer('quantity')->default(1);
- $table->foreignId('category_id')->default(1)->constrained()->restrictOnDelete();
- $table->foreignId('tax_id')->nullable()->constrained()->nullOnDelete();
- $table->foreignId('discount_id')->nullable()->constrained()->nullOnDelete();
- $table->boolean('enabled')->default(true);
- $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
- $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
- $table->timestamps();
- });
- }
-
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- Schema::dropIfExists('items');
- }
- };
|