This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccount/database/migrations/2019_04_18_125654_new_app_config.php

89 lines
3.2 KiB
PHP
Raw Normal View History

2019-04-24 18:46:41 +00:00
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class NewAppConfig extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('app_access', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('user_id');
$table->unsignedInteger('app_id');
$table->enum("status", ["created", "allowed", "disabled"]);
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('app_id')->references('id')->on('apps');
});
Schema::table('apps', function (Blueprint $table) {
$table->boolean('auto_accept')->default(false)->comment('User dont have to click login, if the user is logged in he/she will immediately redirected back.');
$table->boolean('testing_warning')->default(true)->comment('Show warning that the Application is just in testing mode');
$table->boolean('untrusted_warning')->default(false)->comment('Show warning that the Application is untrusted');
$table->dropColumn('trustLevel');
$table->dropColumn('owner');
$table->dropColumn('status');
});
\App\Models\AppCode::query()->delete();
Schema::table('app_codes', function (Blueprint $table) {
$table->dropForeign("app_codes_app_id_foreign");
$table->dropColumn("app_id");
$table->dropForeign("app_codes_user_id_foreign");
$table->dropColumn("user_id");
$table->unsignedInteger("access_id");
$table->foreign('access_id')->references('id')->on('app_access');
});
\App\Models\AccessToken::query()->delete();
Schema::table('access_tokens', function (Blueprint $table) {
$table->dropForeign("access_tokens_app_id_foreign");
$table->dropColumn("app_id");
$table->dropForeign("access_tokens_user_id_foreign");
$table->dropColumn("user_id");
$table->unsignedInteger("access_id");
$table->foreign('access_id')->references('id')->on('app_access');
});
\App\Models\RefreshToken::query()->delete();
Schema::table('refresh_tokens', function (Blueprint $table) {
$table->dropForeign("refresh_tokens_app_id_foreign");
$table->dropColumn("app_id");
$table->dropForeign("refresh_tokens_user_id_foreign");
$table->dropColumn("user_id");
$table->unsignedInteger("access_id");
$table->foreign('access_id')->references('id')->on('app_access');
});
$user = new \App\Models\User();
$user->username = "system";
$user->password = "";
$user->admin = 0;
$user->developer = 0;
$user->saveOrFail();
$app = \App\Models\App::createApp("PHP-GUI", "Webgui for oAuth Provider", "https://account.keks.cloud", $user);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop("app_access");
}
}