-
-
Save andrewhl/0b5d89cecf05d69aa387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateFoodItemTemplatesTable extends Migration { | |
/** | |
* Run the migrations. | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create('food_item_templates', function (Blueprint $table) | |
{ | |
$table->increments('id')->unsigned(); | |
$table->string('name', 255); | |
$table->text('description')->nullable(); | |
$table->string('type')->nullable(); | |
$table->float('price')->nullable(); | |
$table->datetime('starts_at')->default(DB::raw('CURRENT_TIMESTAMP')); | |
$table->datetime('ends_at')->default(DB::raw('CURRENT_TIMESTAMP')); | |
$table->text('cooking_instructions')->nullable(); | |
$table->text('nutritional_information')->nullable(); | |
$table->text('assembly_instructions')->nullable(); | |
$table->boolean('active')->default(false); | |
$table->string('size_type', 50)->nullable(); | |
$table->boolean('archive')->default(false); | |
$table->timestamps(); | |
}); | |
Schema::table('food_items', function (Blueprint $table) | |
{ | |
$table->foreign('food_item_template_id') | |
->references('id') | |
->on('food_item_templates') | |
->onDelete('cascade'); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::drop('food_item_templates'); | |
Schema::table('food_items', function (Blueprint $table) | |
{ | |
$table->dropForeign('food_items_food_item_template_id_foreign'); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateFoodItemsTable extends Migration { | |
/** | |
* Run the migrations. | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
Schema::create('food_items', function(Blueprint $table) | |
{ | |
$table->increments('id')->unsigned(); | |
$table->integer('food_item_template_id')->unsigned(); | |
$table->float('price', 10)->nullable(); | |
$table->string('name', 255); | |
$table->string('type', 50)->nullable(); | |
$table->string('size_type', 50)->nullable(); | |
$table->datetime('starts_at')->default(DB::raw('CURRENT_TIMESTAMP')); | |
$table->datetime('ends_at')->default(DB::raw('CURRENT_TIMESTAMP')); | |
$table->text('description')->nullable(); | |
$table->text('cooking_instructions')->nullable(); | |
$table->text('nutritional_information')->nullable(); | |
$table->text('assembly_instructions')->nullable(); | |
$table->boolean('active')->default(false); | |
$table->boolean('archive')->default(false); | |
$table->timestamps(); | |
}); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::drop('food_items'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Illuminate\Database\QueryException] | |
SQLSTATE[2BP01]: Dependent objects still exist: 7 ERROR: cannot drop table food_it | |
em_templates because other objects depend on it | |
DETAIL: constraint food_items_food_item_template_id_foreign on table food_items de | |
pends on table food_item_templates | |
HINT: Use DROP ... CASCADE to drop the dependent objects too. (SQL: drop table "fo | |
od_item_templates") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment