Lae/database/migrations/2022_09_14_215159_create_transactions_table.php
iVampireSP.com 4918efa597
优化导入,格式化代码
分离出充值系统

修复了充值的问题
2022-11-16 13:16:56 +08:00

48 lines
1.2 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// if transaction collection exists
if (Schema::connection('mongodb')->hasTable('transactions')) {
return true;
}
Schema::connection('mongodb')->create('transactions', function (Blueprint $collection) {
$collection->unsignedBigInteger('user_id')->index();
$collection->unsignedBigInteger(
'type'
)->index();
$collection->unsignedBigInteger('payment')->index();
$collection->unsignedBigInteger(
'module_id'
)->index()->nullable();
$collection->unsignedBigInteger('host_id')->index()->nullable();
// a year
$year = 365 * 24 * 60 * 60;
$collection->expire('created_at', $year);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::connection('mongodb')->dropIfExists('transactions');
}
};