Skip to content

Instantly share code, notes, and snippets.

@scrubmx
Created December 26, 2014 23:17
Show Gist options
  • Save scrubmx/2b2a7e5065badbd07997 to your computer and use it in GitHub Desktop.
Save scrubmx/2b2a7e5065badbd07997 to your computer and use it in GitHub Desktop.
Import mysql dump as laravel migration
<?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
Copy link

can we use two sql files at a time for dump?

@easterneas
Copy link

@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