cascading style sheets

What’s The Deal With CSS4?

November 30, 2020
how to implement a cropper tools in your frontend vue application

How To Implement A Cropper Tool In Your Frontend Vue Application

January 11, 2021

Laravel Migrations VS CodeIgniter Migrations

December 7, 2020 / Rayne Falkenberg

Laravel and CodeIgniter are both PHP frameworks. They have many differences but they also have their similarities. One of their similarities is that they both have migrations but I will be showing you the differences between their migrations.

Migration: A migration is a single PHP file that describes the changes to operate to the database. A migration file can create or drop tables, add or remove columns, create indexes and even insert data into your database.

 

The Setup:

 

Laravel:

  1. Type the below into your command line:
    php artisan make:migration migrationName

    • The naming conventions I use for the migrationName
    • If I am creating a table: createUsersTable
    • If I am altering a table: alterUsersTableAddContact – I usually specify what I am altering incase I need to alter the table again in the future then it is easy to keep track of changes.

CodeIgniter:

  1. Open application/config/migration.php and check that $config['migration_enabled'] is set to true.
  2. In application/config/ create a folder called migrations
  3. In the migrations folder is where you can create your migrations
    • Naming conventions to use for the migration file name: YYYYMMDDHHIISS_create_users
      • where:
        • YYYYMMDDHHIISS is the time stamp of when you are creating the file
        • create_users is what the migration does (eg. creates a users table)
  4. In the migration file you created add the below code:

 

Creating a Migration

 

Laravel:

  1. Locate the migration file that was created (database/migrations/)
    • If you are creating a table:

    • If you are altering a table:

 

CodeIgniter:

  1. Edit your migration file you created
    • If you are creating a table:

    • If you are altering a table:

 

Running Migrations

 

Laravel:

  1. Type the below into your command line
    • php artisan migrate
      • migrate:fresh  will drop all the tables you currently have in your DB and migrate all migrations from scratch
      • migrate:rollback will rollback your DB to the state it was before you did your last migration

 

CodeIgniter:

  1. To run the migrations you have created you will need to create a controller called migrate
  2. In your migrate controller add the code below:
  3. To run the migrations go to http://yoursite.com/migrate  

 

Conclusion

 

Laravel and CodeIgniter are very similar in their processes but I find Laravel’s migrations a lot easier and faster to implement.

 

Happy Coding!

Share

Rayne Falkenberg

Rayne is a developer manager with experience in web apps, mobile apps and project management.

✕
Laravel Migrations VS CodeIgniter Migrations
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.
Read more