| 1234567891011121314 |
- <?php
- /** Add explicit water-agent hierarchy without inferring legacy organizational levels. */
- require dirname(__DIR__).'/vendor/autoload.php';
- \Dotenv\Dotenv::createUnsafeMutable(dirname(__DIR__))->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";
|