2018-01-12 04:49:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
class AddApiKeyPermissionColumns extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function up(): void
|
2018-01-12 04:49:46 +00:00
|
|
|
{
|
2018-01-14 18:05:18 +00:00
|
|
|
Schema::dropIfExists('api_permissions');
|
|
|
|
|
2018-01-12 04:49:46 +00:00
|
|
|
Schema::table('api_keys', function (Blueprint $table) {
|
|
|
|
$table->unsignedTinyInteger('r_servers')->default(0);
|
|
|
|
$table->unsignedTinyInteger('r_nodes')->default(0);
|
|
|
|
$table->unsignedTinyInteger('r_allocations')->default(0);
|
|
|
|
$table->unsignedTinyInteger('r_users')->default(0);
|
|
|
|
$table->unsignedTinyInteger('r_locations')->default(0);
|
|
|
|
$table->unsignedTinyInteger('r_nests')->default(0);
|
|
|
|
$table->unsignedTinyInteger('r_eggs')->default(0);
|
2018-01-26 03:26:06 +00:00
|
|
|
$table->unsignedTinyInteger('r_database_hosts')->default(0);
|
|
|
|
$table->unsignedTinyInteger('r_server_databases')->default(0);
|
2018-01-12 04:49:46 +00:00
|
|
|
$table->unsignedTinyInteger('r_packs')->default(0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function down(): void
|
2018-01-12 04:49:46 +00:00
|
|
|
{
|
2018-01-14 18:05:18 +00:00
|
|
|
Schema::create('api_permissions', function (Blueprint $table) {
|
|
|
|
$table->increments('id');
|
|
|
|
$table->unsignedInteger('key_id');
|
|
|
|
$table->string('permission');
|
|
|
|
|
2018-03-04 21:21:54 +00:00
|
|
|
$table->foreign('key_id')->references('id')->on('api_keys')->onDelete('cascade');
|
2018-01-14 18:05:18 +00:00
|
|
|
});
|
|
|
|
|
2018-01-12 04:49:46 +00:00
|
|
|
Schema::table('api_keys', function (Blueprint $table) {
|
|
|
|
$table->dropColumn([
|
|
|
|
'r_servers',
|
|
|
|
'r_nodes',
|
|
|
|
'r_allocations',
|
|
|
|
'r_users',
|
|
|
|
'r_locations',
|
|
|
|
'r_nests',
|
|
|
|
'r_eggs',
|
2018-01-26 03:26:06 +00:00
|
|
|
'r_database_hosts',
|
|
|
|
'r_server_databases',
|
2018-01-12 04:49:46 +00:00
|
|
|
'r_packs',
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|