Files
appraisal_center_api/alter_wechat_apps.php
2026-04-16 11:17:18 +08:00

46 lines
1.3 KiB
PHP

<?php
require __DIR__ . '/vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as Capsule;
if (file_exists(__DIR__ . '/.env')) {
$dotenv = Dotenv\Dotenv::createUnsafeImmutable(__DIR__);
$dotenv->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('wechat_apps')) {
Capsule::schema()->create('wechat_apps', function ($table) {
$table->id();
$table->string('name', 50);
$table->string('type', 20)->default('h5');
$table->string('app_id', 32)->unique();
$table->string('app_secret', 64)->nullable();
$table->tinyInteger('status')->default(1);
$table->string('remark', 255)->nullable();
$table->timestamps();
$table->index(['type']);
$table->index(['status']);
});
echo "Table 'wechat_apps' created successfully.\n";
}
echo "Alter wechat_apps completed.\n";