This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/database/2016_12_12_203349_news_refactor.php

58 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2016-12-12 22:22:09 +00:00
<?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');
});
}
}