Created
December 26, 2014 23:17
-
-
Save scrubmx/2b2a7e5065badbd07997 to your computer and use it in GitHub Desktop.
Import mysql dump as laravel migration
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
<?php | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Database\Migrations\Migration; | |
class CreatePostalCodesTable extends Migration { | |
/** | |
* Run the migrations. | |
* | |
* @return void | |
*/ | |
public function up() | |
{ | |
$file = realpath(__DIR__.'/../catalogs/codigos_postales.sql'); | |
DB::unprepared( file_get_contents($file) ); | |
} | |
/** | |
* Reverse the migrations. | |
* | |
* @return void | |
*/ | |
public function down() | |
{ | |
Schema::drop('codigos_postales'); | |
} | |
} |
@nsareddy
yes you can. Just use DB::unprepared
function repeatedly. I used this in case I need to restore from backup from several tables in my db.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can we use two sql files at a time for dump?