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_11_30_062149_platforms.php

43 lines
1.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class Platforms extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('games_platforms', function (Blueprint $table) {
$table->increments('id');
$table->integer('game_id')->unsigned();
$table->foreign('game_id')->references('id')->on('games');
$table->integer('platform_id')->unsigned();
$table->foreign('platform_id')->references('id')->on('platforms');
});
Schema::table('games', function (Blueprint $table) {
$table->dropForeign(['platform_id']);
$table->dropColumn('platform_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('games_platforms');
Schema::table('games', function (Blueprint $table) {
$table->unsignedInteger('platform_id')->nullable();
$table->foreign('platform_id')->references('id')->on('platforms');
});
}
}