🚀 Moving to CodeIgniter 4: Embracing Migrations for Database Management
After spending a long time working with CodeIgniter 3, I finally decided to take the leap and explore CodeIgniter 4. Right away, I was impressed with how well-structured and modern the framework feels. However, like many projects, CodeIgniter 4 still has gaps in its documentation, which can make certain features tricky to implement. With this series, I hope to fill in those missing pieces and provide clarity on areas that lack official guidance.
One area I previously avoided in CodeIgniter 3 was Migrations. My only prior experience with database migrations came from Ruby, but now, as I take a fresh start with CodeIgniter 4, I’m committed to incorporating Migrations fully—especially since they play a crucial role in database testing and version control.
The Challenge: Missing Migration Schema Documentation
Setting up Migrations in CodeIgniter 4 was not as straightforward as I had hoped. Despite spending hours searching, I found little to no documentation about what the Migration table should look like. Many search results pointed to outdated or incomplete information, leaving me frustrated. But after significant trial and error, I finally figured it out. If you’re struggling with CodeIgniter 4 Migrations and need clarity on its schema, you’re in the right place. In the next section, I’ll break down exactly what you need to know!
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