1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
-
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
-
- class AddSemesterIdToCourses extends Migration {
-
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::table('courses', function(Blueprint $table)
- {
- $table->integer('semester_id')->unsigned()->default(1)->after('user_id');
- });
-
- Schema::table('courses', function(Blueprint $table)
- {
- $table->foreign('semester_id')->references('id')->on('semesters');
- });
- }
-
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table('courses', function(Blueprint $table)
- {
- $table->dropForeign('courses_semester_id_foreign');
- $table->dropColumn('semester_id');
- });
- }
-
- }
|