add foreignkey to event table
This commit is contained in:
@@ -18,11 +18,23 @@ class CreateEventsTable extends Migration
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->unsignedBigInteger('category_id');
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamp('start_date');
|
||||
$table->timestamp('end_date')->nullable();
|
||||
$table->string('location')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('user_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('restrict');
|
||||
|
||||
$table->foreign('category_id')
|
||||
->references('id')
|
||||
->on('event_categories')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('restrict');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,6 +45,10 @@ class CreateEventsTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropForeign(['category_id']);
|
||||
});
|
||||
Schema::dropIfExists('events');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user