cleanup database migrations

This commit is contained in:
2019-04-24 23:03:59 -05:00
parent 291c1cd426
commit 5110c58a7c
58 changed files with 531 additions and 1924 deletions

View File

@@ -25,7 +25,6 @@ class CreateUsersTable extends Migration
$table->integer('expires_in')->default(0);
$table->string('owner_hash');
$table->string('user_type')->default('Guest');
$table->string('role')->default('Guest');
$table->text('scopes')->nullable();
$table->string('email')->unique()->nullable();
$table->timestamp('email_verified_at')->nullable();
@@ -33,6 +32,142 @@ class CreateUsersTable extends Migration
$table->timestamps();
});
}
if(!Schema::hasTable('user_roles')) {
Schema::create('user_roles', function (Blueprint $table) {
$table->increments('id');
$table->integer('character_id')->unsigned();
$table->foreign('character_id')->references('character_id')->on('users');
$table->string('role')->default('None');
$table->timestamps();
});
}
if(!Schema::hasTable('EsiTokens')) {
Schema::create('EsiTokens', function(Blueprint $table) {
$table->increments('id');
$table->integer('character_id')->unique();
$table->string('access_token');
$table->string('refresh_token');
$table->integer('expires_in');
$table->timestamps();
});
}
if(!Schema::hasTable('EsiScopes')) {
Schema::create('EsiScopes', function(Blueprint $table) {
$table->increments('id');
$table->integer('character_id');
$table->foreign('character_id')->references('character_id')->on('EsiTokens');
$table->string('scope');
$table->timestamps();
});
}
if(!Schema::hasTable('user_permissions')) {
Schema::create('user_permissions', function (Blueprint $table) {
$table->increments('id');
$table->integer('character_id')->unsigned();
$table->foreign('character_id')->references('character_id')->on('users');
$table->string('permission');
$table->timestamps();
});
}
if(!Schema::hasTable('available_user_permissions')) {
Schema::create('available_user_permissions', function(Blueprint $table) {
$table->increments('id');
$table->string('permission');
});
}
if(!Schema::hasTable('available_user_roles')) {
Schema::create('available_user_roles', function (Blueprint $table) {
$table->increments('id');
$table->string('role');
$table->string('description');
$table->timestamps();
});
DB::table('available_user_roles')->insert([
'role' => 'None',
'description' => 'User has no roles and is not allowed in the site.',
]);
DB::table('available_user_roles')->insert([
'role' => 'Guest',
'description' => 'Guest of the site.',
]);
DB::table('available_user_roles')->insert([
'role' => 'Renter',
'description' => 'Renters of W4RP.',
]);
DB::table('available_user_roles')->insert([
'role' => 'User',
'description' => 'Members of Legacy allowed on the site.',
]);
DB::table('available_user_roles')->insert([
'role' => 'Admin',
'description' => 'Admin of the site.',
]);
DB::table('available_user_roles')->insert([
'role' => 'SuperUser',
'description' => 'Super user of the site.',
]);
}
if(!Schema::hasTable('user_to_corporation')) {
Schema::create('user_to_corporation', function (Blueprint $table) {
$table->increments('id');
$table->string('character_id');
$table->string('character_name');
$table->string('corporation_id');
$table->string('corporation_name');
});
}
if(!Schema::hasTable('AllianceCorps')) {
Schema::create('AllianceCorps', function(Blueprint $table) {
$table->integer('corporation_id')->unique();
$table->string('name');
$table->timestamps();
});
}
if(!Schema::hasTable('character_to_corporation')) {
Schema::create('character_to_corporation', function (Blueprint $table) {
$table->increments('id');
$table->string('character_id');
$table->string('character_name');
$table->string('corporation_id');
$table->string('corporation_name');
});
}
if(!Schema::hasTable('corporation_to_alliance')) {
Schema::create('corporation_to_alliance', function (Blueprint $table) {
$table->increments('id');
$table->string('corporation_id');
$table->string('corporation_name');
$table->string('alliance_id');
$table->string('alliance_name');
});
}
if(!Schema::hasTable('allowed_logins')) {
Schema::create('allowed_logins', function(Blueprint $table) {
$table->increments('id');
$table->string('entity_id');
$table->string('entity_type');
$table->string('entity_name');
$table->string('login_type');
$table->timestamps();
});
}
}
/**
@@ -43,5 +178,16 @@ class CreateUsersTable extends Migration
public function down()
{
Schema::dropIfExists('users');
Schema::dropIfExists('available_user_roles');
Schema::dropIfExists('user_roles');
Schema::dropIfExists('EsiTokens');
Schema::dropIfExists('EsiScopes');
Schema::dropIfExists('available_user_permissions');
Schema::dropIfExists('user_permissions');
Schema::dropIfExists('user_to_corporation');
Schema::dropIfExists('AllianceCorps');
Schema::dropIfExists('character_to_corporation');
Schema::dropIfExists('corporation_to_alliance');
Schema::dropIfExists('allowed_logins');
}
}