2022-08-13 06:04:47 +00:00
|
|
|
<?php
|
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
use App\Models\Module;
|
2022-08-13 08:37:17 +00:00
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2022-11-06 11:28:22 +00:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
2022-08-13 06:04:47 +00:00
|
|
|
|
2022-11-16 05:16:56 +00:00
|
|
|
return new class extends Migration {
|
2022-08-13 06:04:47 +00:00
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::create('modules', function (Blueprint $table) {
|
2022-08-14 13:57:56 +00:00
|
|
|
$table->string('id')->index()->primary()->unique();
|
2022-08-13 06:04:47 +00:00
|
|
|
|
2022-08-14 14:00:22 +00:00
|
|
|
$table->string('name')->index();
|
2022-08-13 06:04:47 +00:00
|
|
|
|
2022-08-14 13:57:56 +00:00
|
|
|
// api token
|
|
|
|
$table->string('api_token')->nullable()->unique()->index();
|
2022-08-13 06:04:47 +00:00
|
|
|
});
|
2022-08-13 08:37:17 +00:00
|
|
|
|
|
|
|
// if env is local
|
|
|
|
if (env('APP_ENV') == 'local') {
|
|
|
|
$module = [
|
2022-08-14 14:00:22 +00:00
|
|
|
'id' => 'test',
|
|
|
|
'name' => 'Example Module',
|
2022-08-14 13:57:56 +00:00
|
|
|
'api_token' => '123456'
|
2022-08-13 08:37:17 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
Module::create($module);
|
|
|
|
}
|
2022-08-13 06:04:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::dropIfExists('modules');
|
|
|
|
}
|
|
|
|
};
|