Site icon iGoPayGO

Codeigniter 4+ – Database Migrations

After a long time of being stuck on Codeigniter 3, I have decided to give Codeigniter 4 a try. And right off the bat I am overly enthused about how well put together the project is. However like some projects they are lacking in some areas of documentation. I am hoping with this series that I can fill in some of that.

Up to this point I have avoided Migrations in previous versions and only have had a taste in Ruby. But since I feel like I am starting over a bit, and really want to go full on with the testing, Migrations is going to be a huge deal when testing the DB side.

I spent many hours trying to figure out how to get the Migration going as there is no documentation on what the Migration table in Codeigniter is supposed to look like, and very little help on the schema from anyone. Most search results turn up scant info, claiming schemas but only to find nothing. Well here it is.

Codeigniter 4+ Migration Schema – MySql/MariaDB

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

— Table structure for migrations

DROP TABLE IF EXISTS migrations;

CREATE TABLE migrations (

id int(11) NOT NULL AUTO_INCREMENT,

name varchar(255) DEFAULT NULL,

version varchar(255) DEFAULT NULL,

group varchar(255) DEFAULT NULL,

batch int(11) DEFAULT NULL,

class varchar(255) DEFAULT NULL,

namespace varchar(255) DEFAULT NULL,

time int(11) DEFAULT NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

More details and full migration can be found at GitHub