Skip to content

Instantly share code, notes, and snippets.

@GesJeremie
Created December 16, 2015 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GesJeremie/161d6d06df4ae52b7243 to your computer and use it in GitHub Desktop.
Save GesJeremie/161d6d06df4ae52b7243 to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserOrderBuildingsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_order_buildings', function($table)
{
// Keys
$table->increments('id');
$table->integer('user_id')->unsigned()->nullable();
$table->integer('user_order_preference_id')->unsigned()->nullable();
$table->integer('user_profile_id')->unsigned()->nullable();
$table->integer('delivery_serie_id')->unsigned()->nullable();
// Fields
$table->text('step');
$table->string('destination_first_name');
$table->string('destination_last_name');
$table->string('destination_city');
$table->string('destination_zip');
$table->text('destination_address');
// Indexes
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('user_order_preference_id')->references('id')->on('user_order_preferences')->onDelete('cascade');
$table->foreign('user_profile_id')->references('id')->on('user_profiles')->onDelete('cascade');
$table->foreign('delivery_serie_id')->references('id')->on('delivery_series')->onDelete('cascade');
// Timestamps
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('user_order_buildings', function(Blueprint $table)
{
$table->dropForeign('user_order_buildings_user_id_foreign');
$table->dropForeign('user_order_buildings_user_order_preference_id_foreign');
$table->dropForeign('user_order_buildings_user_profile_id_foreign');
});
Schema::dropIfExists('user_order_buildings');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment