47 lines
1.5 KiB
PHP
47 lines
1.5 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_merchants')) {
|
|
echo "Table 'wechat_merchants' not found.\n";
|
|
exit(1);
|
|
}
|
|
|
|
if (!Capsule::schema()->hasColumn('wechat_merchants', 'apiclient_cert_path')) {
|
|
Capsule::schema()->table('wechat_merchants', function ($table) {
|
|
$table->string('apiclient_cert_path', 255)->nullable()->after('private_key_pem');
|
|
});
|
|
echo "Added 'apiclient_cert_path' to wechat_merchants.\n";
|
|
}
|
|
if (!Capsule::schema()->hasColumn('wechat_merchants', 'apiclient_key_path')) {
|
|
Capsule::schema()->table('wechat_merchants', function ($table) {
|
|
$table->string('apiclient_key_path', 255)->nullable()->after('apiclient_cert_path');
|
|
});
|
|
echo "Added 'apiclient_key_path' to wechat_merchants.\n";
|
|
}
|
|
|
|
echo "Alter wechat_merchants_cert_files completed.\n";
|
|
|