diff --git a/database/migrations/2024_08_03_080116_create_bill_bill_table.php b/database/migrations/2024_08_03_080116_create_bill_bill_table.php index d7952d0..47314bf 100644 --- a/database/migrations/2024_08_03_080116_create_bill_bill_table.php +++ b/database/migrations/2024_08_03_080116_create_bill_bill_table.php @@ -16,7 +16,7 @@ public function up(): void $table->string('title'); $table->char('bill_no', 100); - $table->foreignId('partner_id')->constrained('partner_partner')->onDelete('cascade')->index('bill_bill_partner_id'); + $table->foreignId('partner_id')->nullable()->constrained('partner_partner')->onDelete('set null'); $table->date('due_date'); $table->string('module')->default('Account'); $table->string('model')->default('Invoice'); @@ -25,7 +25,12 @@ public function up(): void $table->tinyInteger('is_posted')->default(0); $table->decimal('total', 20, 2)->nullable(); + $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null'); + $table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null'); + $table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null'); + $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2024_08_03_080127_create_bill_item_table.php b/database/migrations/2024_08_03_080127_create_bill_item_table.php index 0e1ca27..0ae5488 100644 --- a/database/migrations/2024_08_03_080127_create_bill_item_table.php +++ b/database/migrations/2024_08_03_080127_create_bill_item_table.php @@ -15,8 +15,8 @@ public function up(): void $table->id(); $table->string('title'); - $table->foreignId('bill_id')->constrained('bill_bill')->onDelete('cascade')->index('bill_bill_bill_id'); - $table->foreignId('ledger_id')->constrained('account_ledger')->onDelete('cascade')->index('bill_bill_ledger_id'); + $table->foreignId('bill_id')->nullable()->constrained('bill_bill')->onDelete('set null'); + $table->foreignId('ledger_id')->nullable()->constrained('account_ledger')->onDelete('set null'); $table->decimal('price', 20, 2)->default(0.00); $table->decimal('amount', 20, 2)->default(0.00); $table->string('module')->nullable(); @@ -24,7 +24,12 @@ public function up(): void $table->bigInteger('item_id')->nullable(); $table->integer('quantity')->nullable(); + $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null'); + $table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null'); + $table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null'); + $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2024_08_03_080133_create_bill_item_rate_table.php b/database/migrations/2024_08_03_080133_create_bill_item_rate_table.php index adf50ad..e5e75f8 100644 --- a/database/migrations/2024_08_03_080133_create_bill_item_rate_table.php +++ b/database/migrations/2024_08_03_080133_create_bill_item_rate_table.php @@ -16,15 +16,20 @@ public function up(): void $table->string('title'); $table->string('slug'); - $table->foreignId('rate_id')->constrained('account_rate')->onDelete('cascade')->index('bill_item_rate_rate_id'); - $table->foreignId('bill_item_id')->constrained('bill_item')->onDelete('cascade')->index('bill_item_rate_bill_item_id'); + $table->foreignId('rate_id')->nullable()->constrained('account_rate')->onDelete('set null'); + $table->foreignId('bill_item_id')->nullable()->constrained('bill_item')->onDelete('set null'); $table->enum('method', ['+', '+%', '-', '-%'])->default('+'); $table->decimal('value', 20, 2)->default(0.00); $table->string('params')->nullable(); $table->tinyInteger('ordering')->nullable(); $table->tinyInteger('on_total')->default(false); + $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null'); + $table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null'); + $table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null'); + $table->timestamps(); + $table->softDeletes(); }); } diff --git a/database/migrations/2024_09_03_132429_add_deleted_at_to_bill_bill_table.php b/database/migrations/2024_09_03_132429_add_deleted_at_to_bill_bill_table.php deleted file mode 100644 index 8caa38b..0000000 --- a/database/migrations/2024_09_03_132429_add_deleted_at_to_bill_bill_table.php +++ /dev/null @@ -1,28 +0,0 @@ -softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('bill_bill', function (Blueprint $table) { - $table->dropColumn('deleted_at'); - }); - } -}; diff --git a/database/migrations/2024_09_03_132436_add_deleted_at_to_bill_item_table.php b/database/migrations/2024_09_03_132436_add_deleted_at_to_bill_item_table.php deleted file mode 100644 index 53919b0..0000000 --- a/database/migrations/2024_09_03_132436_add_deleted_at_to_bill_item_table.php +++ /dev/null @@ -1,28 +0,0 @@ -softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('bill_item', function (Blueprint $table) { - $table->dropColumn('deleted_at'); - }); - } -}; diff --git a/database/migrations/2024_09_03_132441_add_deleted_at_to_bill_item_rate_table.php b/database/migrations/2024_09_03_132441_add_deleted_at_to_bill_item_rate_table.php deleted file mode 100644 index b0b2f5a..0000000 --- a/database/migrations/2024_09_03_132441_add_deleted_at_to_bill_item_rate_table.php +++ /dev/null @@ -1,28 +0,0 @@ -softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('bill_item_rate', function (Blueprint $table) { - $table->dropColumn('deleted_at'); - }); - } -};