57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Sakura\DB;
|
|
|
|
class NewsRefactor extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
$schema = DB::getSchemaBuilder();
|
|
|
|
$schema->drop('news');
|
|
|
|
$schema->create('news_posts', function (Blueprint $table) {
|
|
$table->increments('post_id');
|
|
$table->integer('category_id')->unsigned();
|
|
$table->integer('user_id')->unsigned();
|
|
$table->string('post_title');
|
|
$table->text('post_text');
|
|
$table->timestampTz('created_at')->useCurrent = true;
|
|
$table->timestampTz('updated_at')->useCurrent = true;
|
|
$table->timestampTz('deleted_at')->nullable()->default(null);
|
|
});
|
|
|
|
$schema->create('news_categories', function (Blueprint $table) {
|
|
$table->increments('category_id');
|
|
$table->string('category_name');
|
|
$table->string('category_description')->nullable();
|
|
$table->boolean('category_hidden')->default(false);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
$schema = DB::getSchemaBuilder();
|
|
|
|
$schema->drop('news_posts');
|
|
$schema->drop('news_categories');
|
|
|
|
$schema->create('news', function (Blueprint $table) {
|
|
$table->increments('news_id');
|
|
$table->string('news_category', 255);
|
|
$table->integer('user_id')->unsigned();
|
|
$table->integer('news_timestamp')->unsigned();
|
|
$table->string('news_title', 255);
|
|
$table->text('news_content');
|
|
});
|
|
}
|
|
}
|