load(); \support\App::loadAllConfig(['route']); use plugin\saiadmin\app\model\water\WaterAgent; $schema=(new WaterAgent())->getConnection()->getSchemaBuilder(); if (!in_array('--apply',$argv,true)) { echo "Plan: add nullable parent_id to water agents; existing levels remain unconfigured.\n"; exit; } if (!$schema->hasColumn('sa_water_agent','parent_id')) { $schema->table('sa_water_agent',function (\Illuminate\Database\Schema\Blueprint $table) { $table->unsignedBigInteger('parent_id')->nullable()->index()->comment('NULL未设置,0一级代理,其余为上级供水代理ID'); }); } echo "Applied: agent parent_id available; existing accounts, permissions and business data preserved.\n";