load(); } $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'mysql', 'host' => $_ENV['DB_HOST'] ?? '127.0.0.1', 'port' => $_ENV['DB_PORT'] ?? '3306', 'database' => $_ENV['DB_DATABASE'] ?? '', 'username' => $_ENV['DB_USERNAME'] ?? '', 'password' => $_ENV['DB_PASSWORD'] ?? '', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', ]); $capsule->setAsGlobal(); $capsule->bootEloquent(); if (!Capsule::schema()->hasTable('user_wechat_identities')) { Capsule::schema()->create('user_wechat_identities', function ($table) { $table->id(); $table->unsignedBigInteger('user_id')->index(); $table->string('app_id', 32)->index(); $table->string('openid', 64)->index(); $table->string('unionid', 64)->nullable()->index(); $table->string('scene', 20)->default('unknown')->index(); $table->timestamps(); $table->unique(['user_id', 'app_id']); $table->unique(['app_id', 'openid']); }); echo "Table 'user_wechat_identities' created successfully.\n"; } echo "Alter user_wechat_identities completed.\n";