43 lines
1.1 KiB
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');
|
||
|
});
|
||
|
}
|
||
|
}
|