[WIP] Refactor project
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAuthenticationLogTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('authentication_log', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->morphs('authenticatable');
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->timestamp('login_at')->nullable();
|
||||
$table->timestamp('logout_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('authentication_log');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActivityLogTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCommentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('comments', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->morphs('commentable');
|
||||
$table->text('comment');
|
||||
$table->boolean('is_approved')->default(false);
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('comments');
|
||||
}
|
||||
}
|
||||
32
database/migrations/2021_05_21_001707_create_media_table.php
Normal file
32
database/migrations/2021_05_21_001707_create_media_table.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateMediaTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('media', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
|
||||
$table->morphs('model');
|
||||
$table->uuid('uuid')->nullable()->unique();
|
||||
$table->string('collection_name');
|
||||
$table->string('name');
|
||||
$table->string('file_name');
|
||||
$table->string('mime_type')->nullable();
|
||||
$table->string('disk');
|
||||
$table->string('conversions_disk')->nullable();
|
||||
$table->unsignedBigInteger('size');
|
||||
$table->json('manipulations');
|
||||
$table->json('custom_properties');
|
||||
$table->json('generated_conversions');
|
||||
$table->json('responsive_images');
|
||||
$table->unsignedInteger('order_column')->nullable();
|
||||
|
||||
$table->nullableTimestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class TeamworkSetupTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table(\Config::get('teamwork.users_table'), function (Blueprint $table) {
|
||||
$table->integer('current_team_id')->unsigned()->nullable();
|
||||
});
|
||||
|
||||
Schema::create(\Config::get('teamwork.teams_table'), function (Blueprint $table) {
|
||||
$table->increments('id')->unsigned();
|
||||
$table->integer('owner_id')->unsigned()->nullable();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create(\Config::get('teamwork.team_user_table'), function (Blueprint $table) {
|
||||
$table->bigInteger('user_id')->unsigned();
|
||||
$table->integer('team_id')->unsigned();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')
|
||||
->references(\Config::get('teamwork.user_foreign_key'))
|
||||
->on(\Config::get('teamwork.users_table'))
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('team_id')
|
||||
->references('id')
|
||||
->on(\Config::get('teamwork.teams_table'))
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create(\Config::get('teamwork.team_invites_table'), function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->bigInteger('user_id')->unsigned();
|
||||
$table->integer('team_id')->unsigned();
|
||||
$table->enum('type', ['invite', 'request']);
|
||||
$table->string('email');
|
||||
$table->string('accept_token');
|
||||
$table->string('deny_token');
|
||||
$table->timestamps();
|
||||
$table->foreign('team_id')
|
||||
->references('id')
|
||||
->on(\Config::get('teamwork.teams_table'))
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table(\Config::get('teamwork.users_table'), function (Blueprint $table) {
|
||||
$table->dropColumn('current_team_id');
|
||||
});
|
||||
|
||||
Schema::table(\Config::get('teamwork.team_user_table'), function (Blueprint $table) {
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->dropForeign(\Config::get('teamwork.team_user_table').'_user_id_foreign');
|
||||
}
|
||||
if (DB::getDriverName() !== 'sqlite') {
|
||||
$table->dropForeign(\Config::get('teamwork.team_user_table').'_team_id_foreign');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::drop(\Config::get('teamwork.team_user_table'));
|
||||
Schema::drop(\Config::get('teamwork.team_invites_table'));
|
||||
Schema::drop(\Config::get('teamwork.teams_table'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Kalnoy\Nestedset\NestedSet;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCategoriesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.categories.tables.categories'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->increments('id');
|
||||
$table->string('slug');
|
||||
$table->json('name');
|
||||
$table->json('description')->nullable();
|
||||
NestedSet::columns($table);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// Indexes
|
||||
$table->unique('slug');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.categories.tables.categories'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCategorizablesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.categories.tables.categorizables'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->integer('category_id')->unsigned();
|
||||
$table->morphs('categorizable');
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->unique(['category_id', 'categorizable_id', 'categorizable_type'], 'categorizables_ids_type_unique');
|
||||
$table->foreign('category_id')->references('id')->on(config('rinvex.categories.tables.categories'))
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.categories.tables.categorizables'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTagsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.tags.tables.tags'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->increments('id');
|
||||
$table->string('slug');
|
||||
$table->json('name');
|
||||
$table->json('description')->nullable();
|
||||
$table->mediumInteger('sort_order')->unsigned()->default(0);
|
||||
$table->string('group')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// Indexes
|
||||
$table->unique('slug');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.tags.tables.tags'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTaggablesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('rinvex.tags.tables.taggables'), function (Blueprint $table) {
|
||||
// Columns
|
||||
$table->integer('tag_id')->unsigned();
|
||||
$table->morphs('taggable');
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->unique(['tag_id', 'taggable_id', 'taggable_type'], 'taggables_ids_type_unique');
|
||||
$table->foreign('tag_id')->references('id')->on(config('rinvex.tags.tables.tags'))
|
||||
->onDelete('cascade')->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(config('rinvex.tags.tables.taggables'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user