Migration refactoring

This commit is contained in:
Peter Papp
2021-02-25 17:15:58 +01:00
parent 18518106ca
commit af1a8e6333
28 changed files with 101 additions and 581 deletions

View File

@@ -14,12 +14,13 @@ class CreateUsersTable extends Migration
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->uuid('id');
$table->enum('role', ['admin', 'user'])->default('user');
$table->string('name');
$table->string('avatar')->nullable();
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('avatar')->nullable();
$table->rememberToken();
$table->timestamps();
});

View File

@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOauthAuthCodesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('oauth_auth_codes', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('oauth_auth_codes');
}
}

View File

@@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOauthAccessTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('oauth_access_tokens', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->unsignedBigInteger('client_id');
$table->string('name')->nullable();
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->timestamps();
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('oauth_access_tokens');
}
}

View File

@@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOauthRefreshTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->string('access_token_id', 100);
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('oauth_refresh_tokens');
}
}

View File

@@ -1,38 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOauthClientsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('oauth_clients', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->string('name');
$table->string('secret', 100)->nullable();
$table->text('redirect');
$table->boolean('personal_access_client');
$table->boolean('password_client');
$table->boolean('revoked');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('oauth_clients');
}
}

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOauthPersonalAccessClientsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('client_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('oauth_personal_access_clients');
}
}

View File

@@ -15,7 +15,7 @@ class CreateSubscriptionsTable extends Migration
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->uuid('user_id');
$table->string('name');
$table->string('stripe_id');
$table->string('stripe_status');

View File

@@ -13,15 +13,14 @@ class CreateFileManagerFolders extends Migration
*/
public function up()
{
Schema::create('file_manager_folders', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('unique_id');
$table->integer('parent_id')->default(0);
$table->text('name')->nullable();
$table->text('type')->nullable();
Schema::create('folders', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('user_id');
$table->uuid('parent_id');
$table->text('name');
$table->string('color')->nullable();
$table->string('emoji')->nullable();
$table->enum('user_scope', ['master', 'editor', 'visitor'])->default('master');
$table->softDeletes();
$table->timestamps();
});

View File

@@ -13,20 +13,21 @@ class CreateFileManagerFiles extends Migration
*/
public function up()
{
Schema::create('file_manager_files', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('unique_id');
$table->integer('folder_id')->default(0);
Schema::create('files', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->uuid('user_id');
$table->uuid('folder_id');
$table->text('thumbnail')->nullable();
$table->text('name')->nullable();
$table->text('basename')->nullable();
$table->text('name');
$table->text('basename');
$table->text('mimetype')->nullable();
$table->text('filesize')->nullable();
$table->text('filesize');
$table->text('type')->nullable();
$table->longText('metadata')->nullable();
$table->enum('user_scope', ['master', 'editor', 'visitor'])->default('master');
$table->softDeletes();
$table->timestamps();

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUserIdToFileManagerFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('file_manager_files', function (Blueprint $table) {
$table->bigInteger('user_id')->after('id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('file_manager_files', function (Blueprint $table) {
//
});
}
}

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUserIdToFileManagerFoldersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('file_manager_folders', function (Blueprint $table) {
$table->bigInteger('user_id')->after('id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('file_manager_folders', function (Blueprint $table) {
//
});
}
}

View File

@@ -14,8 +14,8 @@ class CreateFavouritesFoldersTable extends Migration
public function up()
{
Schema::create('favourite_folder', function (Blueprint $table) {
$table->bigInteger('user_id');
$table->bigInteger('folder_unique_id');
$table->uuid('user_id');
$table->uuid('folder_id');
});
}

View File

@@ -14,14 +14,15 @@ class CreateSharesTable extends Migration
public function up()
{
Schema::create('shares', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->uuid('id')->primary();
$table->uuid('user_id');
$table->string('token', 16)->unique();
$table->bigInteger('item_id');
$table->enum('type', ['file', 'files', 'folder']);
$table->uuid('item_id');
$table->enum('type', ['file', 'folder']);
$table->enum('permission', ['visitor', 'editor'])->nullable();
$table->boolean('protected');
$table->boolean('is_protected')->default(0);
$table->string('password')->nullable();
$table->integer('expire_in')->nullable();
$table->timestamps();
});
}

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUserScopeToFileManagerFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('file_manager_files', function (Blueprint $table) {
$table->string('user_scope')->after('type')->default('master');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('file_manager_files', function (Blueprint $table) {
//
});
}
}

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUserScopeToFileManagerFoldersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('file_manager_folders', function (Blueprint $table) {
$table->string('user_scope')->after('type')->default('master');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('file_manager_folders', function (Blueprint $table) {
//
});
}
}

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRoleToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->enum('role', ['admin', 'user'])->default('user')->after('id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
});
}
}

View File

@@ -14,9 +14,16 @@ class CreateUserSettingsTable extends Migration
public function up()
{
Schema::create('user_settings', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('user_id');
$table->uuid('user_id');
$table->integer('storage_capacity')->default(5);
$table->text('name')->nullable();
$table->text('address')->nullable();
$table->text('state')->nullable();
$table->text('city')->nullable();
$table->text('postal_code')->nullable();
$table->text('country')->nullable();
$table->text('phone_number')->nullable();
$table->decimal('timezone', 10, 1)->nullable();
});
}

View File

@@ -1,44 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAttributesToUserSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('user_settings', function (Blueprint $table) {
$table->text('billing_name')->nullable();
$table->text('billing_address')->nullable();
$table->text('billing_state')->nullable();
$table->text('billing_city')->nullable();
$table->text('billing_postal_code')->nullable();
$table->text('billing_country')->nullable();
$table->text('billing_phone_number')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('user_settings', function (Blueprint $table) {
$table->dropColumn('billing_name');
$table->dropColumn('billing_address');
$table->dropColumn('billing_state');
$table->dropColumn('billing_city');
$table->dropColumn('billing_postal_code');
$table->dropColumn('billing_country');
$table->dropColumn('billing_phone_number');
});
}
}

View File

@@ -14,7 +14,6 @@ class CreateSettingsTable extends Migration
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->longText('value')->nullable();
});

View File

@@ -14,10 +14,9 @@ class CreatePagesTable extends Migration
public function up()
{
Schema::create('pages', function (Blueprint $table) {
$table->id();
$table->boolean('visibility');
$table->string('title');
$table->string('slug');
$table->string('title');
$table->boolean('visibility');
$table->longText('content');
});
}

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddExpirationAtAttributeToSharesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('shares', function (Blueprint $table) {
$table->integer('expire_in')->after('password')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('shares', function (Blueprint $table) {
//
});
}
}

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddExifDataToFileManagerFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('file_manager_files', function (Blueprint $table) {
$table->longText('metadata')->after('type')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('file_manager_files', function (Blueprint $table) {
//
});
}
}

View File

@@ -14,8 +14,8 @@ class CreateTrafficTable extends Migration
public function up()
{
Schema::create('traffic', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->uuid('id');
$table->uuid('user_id');
$table->bigInteger('upload')->default(0);
$table->bigInteger('download')->default(0);
$table->timestamps();

View File

@@ -15,7 +15,7 @@ class CreateZipsTable extends Migration
{
Schema::create('zips', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->bigInteger('user_id');
$table->uuid('user_id');
$table->string('shared_token')->nullable();
$table->text('basename');
$table->timestamps();

View File

@@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTimezoneToUserSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('user_settings', function (Blueprint $table) {
$table->decimal('timezone', 10, 1)->after('billing_phone_number')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('user_settings', function (Blueprint $table) {
//
});
}
}

View File

@@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFolderIconOptionsToFileManagerFoldersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('file_manager_folders', function (Blueprint $table) {
$table->string('icon_color')->after('user_scope')->nullable();
$table->string('icon_emoji')->after('icon_color')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('file_manager_folders', function (Blueprint $table) {
//
});
}
}