Archived
1
0
Fork 0
This repository has been archived on 2021-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
ifnews/database/migrations/2019_09_12_155807_initial.php
2019-09-13 00:03:56 +07:00

102 lines
3 KiB
PHP

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Initial extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('authors', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('url');
$table->boolean('is_company');
$table->boolean('is_person');
$table->text('description');
});
Schema::create('platforms', function (Blueprint $table) {
$table->increments('id');
$table->string('title')->unique();
});
Schema::create('languages', function (Blueprint $table) {
$table->increments('id');
$table->string('code')->unique();
$table->string('title_en')->unique();
$table->string('title_ru')->unique();
});
Schema::create('tags', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->unsignedInteger('language_id')->nullable();
});
Schema::create('games', function (Blueprint $table) {
$table->increments('id');
$table->string('url');
$table->string('url_play_online')->nullable();
$table->string('url_download')->nullable();
$table->string('url_discussion')->nullable();
$table->string('url_download_description')->nullable();
$table->string('url_online_description')->nullable();
$table->string('title')->nullable();
$table->text('description')->nullable();
$table->text('short_description')->nullable();
$table->text('version')->nullable();
$table->date('release_date')->nullable();
$table->string('image_url')->nullable();
$table->unsignedInteger('platform_id')->nullable();
$table->foreign('platform_id')->references('id')->on('platforms');
$table->nullableTimestamps();
$table->softDeletes();
});
Schema::create('authors_games', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('author_id');
$table->unsignedInteger('game_id');
$table->foreign('author_id')->references('id')->on('authors');
$table->foreign('game_id')->references('id')->on('games');
});
Schema::create('tags_games', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('tag_id');
$table->unsignedInteger('game_id');
$table->foreign('tag_id')->references('id')->on('tags');
$table->foreign('game_id')->references('id')->on('games');
});
Schema::create('languages_games', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('language_id');
$table->unsignedInteger('game_id');
$table->foreign('language_id')->references('id')->on('languages');
$table->foreign('game_id')->references('id')->on('games');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('authors_games');
Schema::drop('tags_games');
Schema::drop('languages_games');
Schema::drop('tags');
Schema::drop('games');
Schema::drop('platforms');
Schema::drop('authors');
Schema::drop('languages');
}
}