I'm working on migrating a really old project to laravel and I thought about seeding the database with my old content to the new database.
Here is an example of how I do this for one of my tables:
<?php
class CallsTableSeeder extends Seeder {
public function run()
{
$hostname = 'localhost';
$username = 'root';
$password = 'root';
$link = mysql_connect($hostname, $username, $password);
mysql_select_db('olddatabase');
$callselect = 'SELECT * FROM calls';
$ressource = mysql_query($callselect);
$calls = array();
while($item = mysql_fetch_object($ressource))
{
$calls['id']=$item->id;
$calls['author_name']=$item->author_name;
$calls['comments']=$item->comment;
DB::table('calls')->insert($calls);
}
}
}
And in my DatabaseSeeder.php I have:
<?php
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
$this->call('MembersTableSeeder');
$this->command->info('The Members table has been seeded!');
$this->call('ContactsTableSeeder');
$this->command->info('The Contacts table has been seeded!');
$this->call('CallsTableSeeder');
$this->command->info('The Calls table has been seeded!');
$this->call('ClientsTableSeeder');
//and so on
}
}
The thing is that when I do php artisan migrate:refresh --seed I get the migrations done and the seed message for the first table (it only has 8 rows in it) but nothing else. The command seems to stop after a while and the second table (Calls) will only get some of the values from my old table. It seems it has a running time that stops it from doing the loop for all the rows, but I see no message whatsoever, it just plains stops and when I check the database everything seems correct except the number of rows inserted (I'm missing a few thousands, it is a large database).
Maybe this isn't supposed to be the way to be doing this but so far it seemed like it worked for the job, except for this issue. How can I run the command for a longer period of time?