Created
August 14, 2014 15:39
-
-
Save thunderrabbit/6130543037c7538075bc to your computer and use it in GitHub Desktop.
Revisions
-
thunderrabbit renamed this gist
Aug 14, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
thunderrabbit created this gist
Aug 14, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,82 @@ AddForeignkeysToUsersTable ``` public function up() { Schema::table('users', function($table) { $table->foreign('department_id')->references('id')->on('departments'); $table->foreign('role_id')->references('id')->on('roles'); }); } public function down() { Schema::table('users', function($table){ $table->dropForeign('users_department_id_foreign'); $table->dropForeign('users_role_id_foreign'); $table->dropIndex('users_department_id_foreign'); $table->dropIndex('users_role_id_foreign'); }); } ``` AddForeignkeysToRolesTable ``` public function up() { Schema::table('roles', function($table) { $table->foreign('department_id')->references('id')->on('departments'); }); } public function down() { Schema::table('roles', function($table){ $table->dropForeign('roles_department_id_foreign'); $table->dropIndex('roles_department_id_foreign'); }); } ``` AddForeignkeysToTransactionsTable ``` public function up() { Schema::table('transactions', function($table) { $table->foreign('department_id')->references('id')->on('departments'); }); } public function down() { Schema::table('transactions', function($table){ $table->dropForeign('transactions_department_id_foreign'); $table->dropIndex('transactions_department_id_foreign'); }); } ``` AddForeignkeysToRolestransactionsTable ``` public function up() { Schema::table('rolestransactions', function($table) { $table->foreign('transaction_id')->references('id')->on('transactions'); $table->foreign('role_id')->references('id')->on('roles'); }); } public function down() { Schema::table('rolestransactions', function($table){ $table->dropForeign('rolestransactions_transaction_id_foreign'); $table->dropForeign('rolestransactions_role_id_foreign'); $table->dropIndex('rolestransactions_transaction_id_foreign'); $table->dropIndex('rolestransactions_role_id_foreign'); }); } ```