Remove api permissions table

This commit is contained in:
Dane Everitt 2018-01-14 12:05:18 -06:00
parent b566630311
commit 7aa540b895
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
12 changed files with 17 additions and 449 deletions

View file

@ -13,6 +13,8 @@ class AddApiKeyPermissionColumns extends Migration
*/
public function up()
{
Schema::dropIfExists('api_permissions');
Schema::table('api_keys', function (Blueprint $table) {
$table->unsignedTinyInteger('r_servers')->default(0);
$table->unsignedTinyInteger('r_nodes')->default(0);
@ -33,6 +35,14 @@ class AddApiKeyPermissionColumns extends Migration
*/
public function down()
{
Schema::create('api_permissions', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('key_id');
$table->string('permission');
$table->foreign('key_id')->references('id')->on('keys')->onDelete('cascade');
});
Schema::table('api_keys', function (Blueprint $table) {
$table->dropColumn([
'r_servers',

View file

@ -25,15 +25,6 @@ class SetupTableForKeyEncryption extends Migration
Schema::table('api_keys', function (Blueprint $table) {
$table->text('token')->change();
});
DB::transaction(function () {
foreach (DB::table('api_keys')->cursor() as $key) {
DB::table('api_keys')->where('id', $key->id)->update([
'identifier' => str_random(16),
'token' => Crypt::encrypt($key->token),
]);
}
});
}
/**
@ -45,15 +36,6 @@ class SetupTableForKeyEncryption extends Migration
*/
public function down()
{
/* @var \Pterodactyl\Models\APIKey $key */
DB::transaction(function () {
foreach (DB::table('api_keys')->cursor() as $key) {
DB::table('api_keys')->where('id', $key->id)->update([
'token' => Crypt::decrypt($key->token),
]);
}
});
Schema::table('api_keys', function (Blueprint $table) {
$table->dropColumn('identifier');
$table->string('token', 32)->unique()->change();

View file

@ -14,6 +14,7 @@ class AddLastUsedAtColumn extends Migration
public function up()
{
Schema::table('api_keys', function (Blueprint $table) {
$table->unsignedTinyInteger('key_type')->after('user_id')->default(0);
$table->timestamp('last_used_at')->after('memo')->nullable();
$table->dropColumn('expires_at');
});
@ -28,7 +29,7 @@ class AddLastUsedAtColumn extends Migration
{
Schema::table('api_keys', function (Blueprint $table) {
$table->timestamp('expires_at')->after('memo')->nullable();
$table->dropColumn('last_used_at');
$table->dropColumn('last_used_at', 'key_type');
});
}
}