FEATURE: add support for categories into content save/edit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddCategorySupport extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$platform = Schema::getConnection()
|
||||
->getDoctrineSchemaManager()
|
||||
->getDatabasePlatform();
|
||||
$platform->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
$table->integer('category_id', false, true)
|
||||
->comment('FK to table categories')
|
||||
->after('module_handler')
|
||||
->nullable(true)
|
||||
->default(null);
|
||||
});
|
||||
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
$table->foreign('category_id')
|
||||
->references('id')
|
||||
->on('categories')
|
||||
->onDelete('set null')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$platform = Schema::getConnection()
|
||||
->getDoctrineSchemaManager()
|
||||
->getDatabasePlatform();
|
||||
$platform->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
Schema::table('contents', function (Blueprint $table) {
|
||||
$table->dropForeign('contents_category_id_foreign');
|
||||
$table->dropColumn('category_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user