2022-09-14 14:19:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
2022-11-16 05:16:56 +00:00
|
|
|
return new class extends Migration {
|
2022-09-14 14:19:28 +00:00
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
2022-09-15 04:13:37 +00:00
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
// if transaction collection exists
|
|
|
|
if (Schema::connection('mongodb')->hasTable('transactions')) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-15 04:13:37 +00:00
|
|
|
Schema::connection('mongodb')->create('transactions', function (Blueprint $collection) {
|
|
|
|
$collection->unsignedBigInteger('user_id')->index();
|
2022-09-15 05:28:04 +00:00
|
|
|
$collection->unsignedBigInteger(
|
|
|
|
'type'
|
|
|
|
)->index();
|
|
|
|
$collection->unsignedBigInteger('payment')->index();
|
2022-09-15 05:38:50 +00:00
|
|
|
$collection->unsignedBigInteger(
|
|
|
|
'module_id'
|
|
|
|
)->index()->nullable();
|
|
|
|
$collection->unsignedBigInteger('host_id')->index()->nullable();
|
2022-09-15 04:32:15 +00:00
|
|
|
|
|
|
|
// a year
|
|
|
|
$year = 365 * 24 * 60 * 60;
|
|
|
|
$collection->expire('created_at', $year);
|
2022-09-14 14:19:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
2022-09-15 04:13:37 +00:00
|
|
|
Schema::connection('mongodb')->dropIfExists('transactions');
|
2022-09-14 14:19:28 +00:00
|
|
|
}
|
|
|
|
};
|