59 lines
1.9 KiB
PHP
59 lines
1.9 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', 'serial_no')) {
|
|
Capsule::schema()->table('wechat_merchants', function ($table) {
|
|
$table->string('serial_no', 64)->nullable()->after('app_id');
|
|
});
|
|
echo "Added 'serial_no' to wechat_merchants.\n";
|
|
}
|
|
if (!Capsule::schema()->hasColumn('wechat_merchants', 'api_v3_key')) {
|
|
Capsule::schema()->table('wechat_merchants', function ($table) {
|
|
$table->string('api_v3_key', 64)->nullable()->after('serial_no');
|
|
});
|
|
echo "Added 'api_v3_key' to wechat_merchants.\n";
|
|
}
|
|
if (!Capsule::schema()->hasColumn('wechat_merchants', 'private_key_pem')) {
|
|
Capsule::schema()->table('wechat_merchants', function ($table) {
|
|
$table->text('private_key_pem')->nullable()->after('api_v3_key');
|
|
});
|
|
echo "Added 'private_key_pem' to wechat_merchants.\n";
|
|
}
|
|
if (!Capsule::schema()->hasColumn('wechat_merchants', 'notify_url')) {
|
|
Capsule::schema()->table('wechat_merchants', function ($table) {
|
|
$table->string('notify_url', 255)->nullable()->after('private_key_pem');
|
|
});
|
|
echo "Added 'notify_url' to wechat_merchants.\n";
|
|
}
|
|
|
|
echo "Alter wechat_merchants_pay completed.\n";
|
|
|