How to migrate from CodeIgniter database to Laravel database How to migrate from CodeIgniter database to Laravel database codeigniter codeigniter

How to migrate from CodeIgniter database to Laravel database


Databases are pretty much the same in Laravel or Codeigniter, if your tables are good the way they are for you and they have a primary key named id (this also is not mandatory) you can just connect with Laravel in your database and it will work just fine.

For your new tables, you can create new migrations and Laravel will not complaint about this.

Well, but if you really need to migrate to a whole new database, you can do the following:

1) rename the tables you need to migrate

php artisan migrate:make

2) create all your migrations with your and migrate them:

php artisan migrate

3) use your database server sql utility to copy data from one table to another, it will be way faster than creating everything in Laravel, believe me. Most databases will let you do things like:

INSERT INTO users (FirstName, LastName)SELECT FirstName, LastNameFROM users_old

And in some you'll be able to do the same using two different databases and columns names

INSERT INTO NEWdatabasename.users (firstName+' '+Lastname, email)SELECT name, emailFROM OLDdatabasename.

Or you can just export data to a CSV file and then create a method in your Laravel seeding class to load that data into your database, with a lot of data to import, you just have to remember to execute:

DB::disableQueryLog();

So your PHP doesn't run out of memory.

See? There are a lot of options, probably many more, so pick one and if you need help, shoot more questions.