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_04_112146_init.php

126 lines
4.4 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 Init extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('username');
$table->string('password');
$table->boolean('developer')->default(false);
$table->boolean('admin')->default(false);
$table->enum('status', ['active']);
});
Schema::create("mails", function(Blueprint $table) {
$table->increments("id");
$table->timestamps();
$table->unsignedInteger("user_id");
$table->string("mail");
$table->string("validation_code");
$table->boolean("primary")->comment("This is the Account primary mail adress");
$table->enum("status", ["waiting", "valide", "invalide"]);
$table->foreign('user_id')->references('id')->on('users');
$table->unique(['user_id', 'primary'], 'unique_primary_email');
});
Schema::create('apps', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('user_id');
$table->string("name");
$table->text("description");
$table->string("url");
$table->string("apiKey");
$table->string("apiSecret");
$table->enum("trustLevel", ["untrustet", "trustet", "full-trustet"])->comment("If level is untrustet a warning is shown, trustet show a notice, only full-trustet it without warning");
$table->enum("owner", ["user", "system"])->comment("If owner is user a warning is shown");
$table->enum("status", ["active", "deactivate", "testing"])->default("active");
$table->foreign('user_id')->references('id')->on('users');
});
Schema::create("app_codes", function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('app_id');
$table->unsignedInteger('user_id');
$table->string('code');
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('app_id')->references('id')->on('apps');
});
Schema::create('access_tokens', function(Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->enum('status', ['active'])->default('active');
$table->timestamp('expires_at')->nullable();
$table->unsignedInteger('user_id');
$table->unsignedInteger('app_id')->nullable();
$table->string('token');
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('app_id')->references('id')->on('apps');
});
Schema::create('refresh_tokens', function(Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->enum('status', ['active'])->default('active');
$table->unsignedInteger('user_id');
$table->unsignedInteger('app_id')->nullable();
$table->string('token');
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('app_id')->references('id')->on('apps');
});
Schema::create('settings', function(Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string("name");
$table->string("description");
$table->enum("typ", ["checkbox"]);
$table->string("value");
});
$setting = new \App\Models\Setting();
$setting->name = "registration_possible";
$setting->description = "Can new user create an account";
$setting->typ = "checkbox";
$setting->value = 1;
$setting->saveOrFail();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop("settings");
Schema::drop('refresh_tokens');
Schema::drop('access_tokens');
Schema::drop('app_codes');
Schema::drop('apps');
Schema::drop('mails');
Schema::drop('users');
}
}