Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class MakeContractFilePathNullableOnClientContractsTable extends Migration
{
public function up()
{
Schema::table('client_contracts', function (Blueprint $table) {
$table->string('contract_file_path')->nullable()->change();
});
}

public function down()
{
Schema::table('client_contracts', function (Blueprint $table) {
$table->string('contract_file_path')->nullable(false)->change();
});
Comment on lines +16 to +20
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Rollback can fail if existing rows contain NULL contract_file_path

On Line 19, reverting to NOT NULL will error if any row has contract_file_path = NULL (which up() explicitly permits). Backfill nulls before altering the constraint.

Suggested fix
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\DB;
@@
     public function down()
     {
+        DB::table('client_contracts')
+            ->whereNull('contract_file_path')
+            ->update(['contract_file_path' => '']);
+
         Schema::table('client_contracts', function (Blueprint $table) {
             $table->string('contract_file_path')->nullable(false)->change();
         });
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@Modules/Client/Database/Migrations/2026_05_08_190600_make_contract_file_path_nullable_on_client_contracts_table.php`
around lines 16 - 20, The down() migration currently changes contract_file_path
to NOT NULL but doesn't handle existing NULLs; update any rows with NULL
contract_file_path to a non-null default (e.g., empty string or a sensible
placeholder) before calling Schema::table so the alter won't fail. In other
words, in the down() method, run a DB update targeting the client_contracts
table to backfill NULL contract_file_path values, then proceed with the existing
Schema::table('client_contracts', function (Blueprint $table) {
$table->string('contract_file_path')->nullable(false)->change(); }); to enforce
NOT NULL.

}
}
2 changes: 2 additions & 0 deletions database/Seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Seeder;
use Modules\HR\Database\Seeders\HrDesignationTableSeeder;
use Modules\HR\Database\Seeders\HrDomainTableSeeder;
use Modules\Report\Database\Seeders\ReportDatabaseSeeder;

class DatabaseSeeder extends Seeder
{
Expand All @@ -26,6 +27,7 @@ public function run()
$this->call(UserDatabaseSeeder::class);
$this->call(BooksPermissionsSeeder::class);
$this->call(BookCategoriesTableSeeder::class);
$this->call(ReportDatabaseSeeder::class);

return true;
}
Expand Down
Loading