{"id":36407,"date":"2024-01-02T16:41:54","date_gmt":"2024-01-02T11:11:54","guid":{"rendered":"https:\/\/www.oneclickitsolution.com\/blog\/?p=36407"},"modified":"2024-09-06T11:39:04","modified_gmt":"2024-09-06T06:09:04","slug":"setting-up-migration-in-codeigniter","status":"publish","type":"post","link":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter","title":{"rendered":"How to Implement Database Migration In CodeIgniter?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-what-is-migration\">What is Migration?<\/h2>\n\n\n\n<p>Migration is a way for developers to alter a database managed in a structured and well-organized manner.<\/p>\n\n\n\n<p>Migration detects and runs those SQL queries on the developer&#8217;s behalf without handing over SQL query files to other developers each time we make some changes to the database.<\/p>\n\n\n\n<p>Migrations are used to create and maintain database queries programmatically.<\/p>\n\n\n\n<p>CodeIgniter framework supports migrations. CodeIgniter mainly supports two classes for migrations; first Database Forge and second is Migrations.<\/p>\n\n\n\n<p>Database Forge is responsible to generate SQL queries which manipulate a selected database. Migrations are responsible to manage the single object in the database.<\/p>\n\n\n\n<p>Migrations are helpful when more than one developer is working on a single project. When a developer has modified or created a migration file for creating a table or alter queries in a database then the developers need to notify others to run the migration file.<\/p>\n\n\n\n<p>Normally when a developer creates a table or modifies anything in the existing database table then developers need to send updated SQL files to run SQL Files who are working with the developers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Migration is Needed?<\/h2>\n\n\n\n<p>Some below advantages are available for use migrations.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.oneclickitsolution.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"300\" src=\"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2022\/03\/Hire-Travel-Technology-Solution-Provider.png\" alt=\"Hire Travel Technology Solution Provider\" class=\"wp-image-54593\" srcset=\"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2022\/03\/Hire-Travel-Technology-Solution-Provider.png 1200w, https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2022\/03\/Hire-Travel-Technology-Solution-Provider-768x192.png 768w, https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2022\/03\/Hire-Travel-Technology-Solution-Provider-20x5.png 20w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">1. Easy to share database changes:<\/h3>\n\n\n\n<p>Let\u2019s assume more than one developer is working on one project. All developers are working on own machine to develop functionalities. If one developer created a Migration file for modifications in the table, the developer will share a migration file with all other developers and developers execute the migration in own machine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Maintain the database version:<\/h3>\n\n\n\n<p>Migrations are allowed to downgrade and upgrade the database version. So it\u2019s easy to upgrade and <a href=\"https:\/\/www.oneclickitsolution.com\/blog\/oracle-database-21c-takes-on-cloud-with-apex\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>downgrade the database version.<\/strong><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. No need to write SQL Changes in the file:<\/h3>\n\n\n\n<p>If we did any changes in the database tables we need to write SQL queries in the file. Using Migration no need to write SQL queries, just need to execute the migration files and SQL changes are implemented in the database.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Database structure backup maintains if SQL file corrupted or failed to Restore the database:<\/h3>\n\n\n\n<p>Have the developer&#8217;s database SQL file corrupted or failed to restore the database?&nbsp; Sometimes to possible failed to restore the database. Developers have to run migration files and they will have his database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setting Up Migration In CodeIgniter<\/h2>\n\n\n\n<p>In order to work with migration, developers need to configure CodeIgniter. Currently, we assume that they have configured the <strong><a href=\"https:\/\/www.oneclickitsolution.com\/services\/mobile-app-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">application<\/a><\/strong>.<\/p>\n\n\n\n<p>Now Open the application\/config\/migration.php file<\/p>\n\n\n\n<p>In file, developers will see the $config[&#8216;migration_enabled&#8217;] with value False. Set it TRUE. For Securities, reason set False, if no longer use Migration.<\/p>\n\n\n\n<p>In file, developers will also see the $config[&#8216;migration_type&#8217;] with set \u2018timestamp\u2019. Developers set two different migration types when they create migration.<\/p>\n\n\n\n<p>Sequential: Sequential migration naming (001_add_user.php) Timestamp: Timestamp migration naming (20121031104401_add_user.php)<\/p>\n\n\n\n<p>Note: Create a migration file as per the selected type in the migration file. If developers selected timestamp and created migration file with Sequential number, Migration file execute but a table will not create in the database.<\/p>\n\n\n\n<p>Actually migration history maintains in a database table with the last migration. By default, the migration table is Migrations. A developer can change the migration table name. If developers want to modify the table name they can modify the $config[&#8216;migration_table&#8217;] value. E.g. if developers want to change the migration table name \u2018 Migrate\u2019 then they need to set as below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">$config['migration_table'] = 'Migrate';<\/code><\/pre>\n\n\n\n<p>$config[\u2018migration_auto_latest\u2019] defines the framework to update the migration to the latest version.<\/p>\n\n\n\n<p>Also, developers can modify the migration file path as they want. If developers want to modify the migration path, then they need to modify the $config[&#8216;migration_path&#8217;] parameter. By default, $config[&#8216;migration_path&#8217;] Path is APPPATH.&#8217;migrations\/&#8217;.<\/p>\n\n\n\n<p>Create a folder called migrations in the application\/ folder.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create Migration With Example<\/h2>\n\n\n\n<p>We will create table \u2018users\u2019 that contains the following fields: \u2018sr_no\u2019,\u2019name\u2019,\u2019email\u2019<\/p>\n\n\n\n<p>I have set up below values in application\/config\/migration.php file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">$config['migration_enabled'] = TRUE;\n$config['migration_type'] = 'sequential';\n$config['migration_table'] = 'Migrations';\n$config['migration_path'] = APPPATH.'migrations\/';<\/code><\/pre>\n\n\n\n<p>As above mentions migration type &#8216;sequential&#8217;, we create \u201c001_create_user.php\u201d file inside the \u201capplication\/migrations\u201d.<\/p>\n\n\n\n<p>In the migrations folder, we can create our database changes files. Let\u2019s we want to create the \u2018users\u2019 table. So create a file with the name \u2018001_create_user.php\u2019 and open file write basic code for migrations.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">defined('BASEPATH') OR exit('No direct script access allowed'); \nclass Migration_create_users extends CI_Migration \n{ \n  public function up() \n  { \n  \n  } \n  public function down() \n  { \n\n  } \n?&gt;<\/code><\/pre>\n\n\n\n<p>As developers can see, the class name must start with \u2018Migration_\u2019 and attach with string \u2018create_user\u2019.<\/p>\n\n\n\n<p>Every migration has two class methods: an up() method and a down() method. The up() method to tell our application want to create when migration is run. The down() method to tell our application if we want to undo the particular migration.<\/p>\n\n\n\n<p>In our case, if we run migration the up() method to create the \u2018users\u2019 table. If we want to undo the migration, down() method delete the \u2018users\u2019 table for us.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Forge Class<\/h3>\n\n\n\n<p>The Database Forge class used to manage the database operations such like create table, delete table, rename the table field name. Now we create the construct method inside the migration file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">defined('BASEPATH') OR exit('No direct script access allowed');<br>class Migration_create_users extends CI_Migration&nbsp;<br>{<br>&nbsp; public function __construct()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;dbforge();<br>&nbsp;&nbsp;}&nbsp;<br>&nbsp;&nbsp;public function up()<br>&nbsp;&nbsp;{&nbsp;&nbsp;<br>&nbsp;&nbsp;}&nbsp;<br>&nbsp;&nbsp;public function down()<br>&nbsp;&nbsp;{&nbsp;<br>&nbsp;&nbsp;}<br>?&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">up() method<\/h3>\n\n\n\n<p>As above mentioned before, the up() method used when we want to run migration. Now we define code in up()&nbsp;method.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">defined('BASEPATH') OR exit('No direct script access allowed');<br>class Migration_create_users extends CI_Migration&nbsp;<br>{<br>&nbsp; public function __construct()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;dbforge();<br>&nbsp;&nbsp;}&nbsp;<br>&nbsp;&nbsp;public function up()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fields = array<br>&nbsp;&nbsp;&nbsp;&nbsp;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'sr_no' =&gt; array(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'INT',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; 11,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'auto_increment' =&gt; TRUE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' =&gt; array(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'VARCHAR',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; 60<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email' =&gt; array(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'VARCHAR',<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;'constraint' =&gt; 255<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;);&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;}&nbsp;<br>&nbsp;&nbsp;public function down()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;}<br>?&gt;<\/code><\/pre>\n\n\n\n<p>As below, now we simply assign dbforge the field by add_field() method.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">$this-&gt;dbforge-&gt;add_field($fields);<\/code><\/pre>\n\n\n\n<p>As we want to \u2018sr_no\u2019 as primary key, So we want to assign field by add_key() method.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">this-&gt;dbforge-&gt;add_key(\u2018sr_no\u2019,TRUE);<\/code><\/pre>\n\n\n\n<p>As we want to create table \u2018users; , So we want to assign dbforge the field by create_table() method.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">$this-&gt;dbforge-&gt;create_table('users',TRUE);&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">down() method<\/h3>\n\n\n\n<p>As above mentioned before, the down() method used when we want to undo the migration. Now we define code in down()&nbsp;method.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">$this-&gt;dbforge-&gt;drop_table('users', TRUE);<\/code><\/pre>\n\n\n\n<p>Now we will see the migration file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">defined('BASEPATH') OR exit('No direct script access allowed');<br>class Migration_create_users extends CI_Migration&nbsp;<br>{<br>&nbsp; public function __construct()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;parent::__construct();<br>&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;load-&gt;dbforge();<br>&nbsp;&nbsp;}&nbsp;<br>&nbsp;&nbsp;public function up()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$fields = array<br>&nbsp;&nbsp;&nbsp;&nbsp;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'sr_no' =&gt; array(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'INT',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; 11,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'auto_increment' =&gt; TRUE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'name' =&gt; array(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'VARCHAR',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; 60<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'email' =&gt; array(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'VARCHAR',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'constraint' =&gt; 255<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;);<br>&nbsp;&nbsp;&nbsp;$this-&gt;dbforge-&gt;add_field($fields);<br>&nbsp;&nbsp;&nbsp;this-&gt;dbforge-&gt;add_key(\u2018sr_no\u2019,TRUE);<br>&nbsp;&nbsp;&nbsp;$this-&gt;dbforge-&gt;create_table('users',TRUE);&nbsp;<br>&nbsp;&nbsp;}&nbsp;<br>&nbsp;&nbsp;public function down()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;dbforge-&gt;drop_table('users', TRUE);<br>&nbsp;&nbsp;}<br>?&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Controller Class<\/h3>\n\n\n\n<p>We have created the migration file. Now for executing the migration file, we need to create a controller file in \u2018application\/controllers\u2019 folder. So create file with name \u2018Migration.php\u2019<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">class Migrate extends CI_Controller<br>{<br>public function index()<br>{<br>echo \u2018Controller file index method run.\u2019;<br>}<br>public function CreateMigration($version = NULL)<br>{<br>$this-&gt;load-&gt;library(\u2018migration\u2019);<br>if(isset($version) &amp;&amp; ($this-&gt;migration-&gt;version($version) === FALSE))<br>{<br>show_error($this-&gt;migration-&gt;error_string());<br>}<br>elseif(is_null($version) &amp;&amp; $this-&gt;migration-&gt;latest() === FALSE)<br>{<br>show_error($this-&gt;migration-&gt;error_string());<br>}<br>else<br>{<br>echo \u2018The migration file has executed successfully.\u2019;<br>}<br>}<br>public function undoMigration($version = NULL)<br>{<br>$this-&gt;load-&gt;library(\u2018migration\u2019);<br>$migrations = $this-&gt;migration-&gt;find_migrations();<br>$migrationKeys = array();<br>foreach($migrations as $key =&gt; $migration)<br>{<br>$migrationKeys[] = $key;<br>}<br>if(isset($version) &amp;&amp; array_key_exists($version,$migrations) &amp;&amp; $this-&gt;migration-&gt;version($version))<br>{<br>echo \u2018The migration was undo\u2019;<br>exit;<br>}<br>elseif(isset($version) &amp;&amp; !array_key_exists($version,$migrations))<br>{<br>echo \u2018The migration with selected version doesn\u2019t exist.\u2019;<br>}<br>else<br>{<br>$penultimate = (sizeof($migrationKeys)==1) ? 0 : $migrationKeys[sizeof($migrationKeys) \u2013 2];<br>if($this-&gt;migration-&gt;version($penultimate))<br>{<br>echo \u2018The migration has been reverted successfully.\u2019;<br>exit;<br>}<br>else<br>{<br>echo \u2018Couldn\\\u2019t roll back the migration.\u2019;<br>exit;<br>}<br>}<br>}<br>public function resetMigration()<br>{<br>$this-&gt;load-&gt;library(\u2018migration\u2019);<br>if($this-&gt;migration-&gt;current()!== FALSE)<br>{<br>echo \u2018The migration was revert to the version set in the config file.\u2019;<br>return TRUE;<br>}<br>else<br>{<br>echo \u2018Couldn\\\u2019t reset migration.\u2019;<br>show_error($this-&gt;migration-&gt;error_string());<br>exit;<br>}<br>}<br>}<\/code><\/pre>\n\n\n\n<p>As above, developers can see we have created three methods : CreateMigration(), undoMigration() and resetMigration(). Using CreateMigration() method, accept the parameter that in our case we have set the &#8216;sequential&#8217;. If developers pass the &#8216;sequential&#8217; number, Codeignter will call that version of the file in migration. Using undoMigration() method and resetMigration() method that will reset migration to the set in file $config[&#8216;migration_version&#8217;].<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Route File<\/h3>\n\n\n\n<p>We have created the migration and controller files to executing the migration. Now for define the route path in route.php file. \u201capplication\/config\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"basic\" class=\"language-basic\">$route['MigrationIndex'] = 'Migrate\/index';<br>$route['createMigration'] = 'Migrate\/CreateMigration;<br>$route['undoMigration'] = 'Migrate\/undoMigration;<br>$route['resetMigration'] = 'Migrate\/resetMigration;<\/code><\/pre>\n\n\n\n<p>If developers execute the MigrationIndex in the browser output will show as below<\/p>\n\n\n\n<p>Controller file index method run<\/p>\n\n\n\n<p>If developers execute the createMigration in the browser output will show as below and two tables will create in database: &#8216;Migrations&#8217; and \u2018users<\/p>\n\n\n\n<p>The migration file has executed successfully.<\/p>\n\n\n\n<p>If developers execute the undoMigration in the browser output will show as below and delete the \u2018users\u2019 table from the database.<\/p>\n\n\n\n<p>The migration was undo.<\/p>\n\n\n\n<p>Are multiple developers are working on your CodeIgniter project and facing issues while altering the database? we have a solution for you as Migration functionality in the CodeIgniter project. We have expertise in implementing Migration function, contact our expert <strong><a href=\"https:\/\/www.oneclickitsolution.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\">OneClick team<\/a><\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Migration? Migration is a way for developers to alter a database managed in a structured and well-organized manner. Migration detects and runs those SQL queries on the developer&#8217;s behalf without handing over SQL query files to other developers each time we make some changes to the database. Migrations are used to create and &hellip;<\/p>\n","protected":false},"author":1,"featured_media":53804,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[784],"tags":[812],"class_list":["post-36407","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-application","tag-website-development-solution-provider-company"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v18.2.1 (Yoast SEO v24.8.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Implement Database Migration In CodeIgniter?<\/title>\n<meta name=\"description\" content=\"In this technical blog we cover step by step tutorial for setting up database migration in codeIgniter know more with examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Implement Database Migration In CodeIgniter?\" \/>\n<meta property=\"og:description\" content=\"In this technical blog we cover step by step tutorial for setting up database migration in codeIgniter know more with examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter\" \/>\n<meta property=\"og:site_name\" content=\"OneClick IT Consultancy\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/oneclickconsultancy\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-02T11:11:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-06T06:09:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2020\/02\/How-to-Implement-Database-Migration-In-CodeIgniter.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"OneClick IT Consultancy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@OneclickIT\" \/>\n<meta name=\"twitter:site\" content=\"@OneclickIT\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"OneClick IT Consultancy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Implement Database Migration In CodeIgniter?","description":"In this technical blog we cover step by step tutorial for setting up database migration in codeIgniter know more with examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter","og_locale":"en_US","og_type":"article","og_title":"How to Implement Database Migration In CodeIgniter?","og_description":"In this technical blog we cover step by step tutorial for setting up database migration in codeIgniter know more with examples.","og_url":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter","og_site_name":"OneClick IT Consultancy","article_publisher":"https:\/\/www.facebook.com\/oneclickconsultancy","article_published_time":"2024-01-02T11:11:54+00:00","article_modified_time":"2024-09-06T06:09:04+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2020\/02\/How-to-Implement-Database-Migration-In-CodeIgniter.png","type":"image\/png"}],"author":"OneClick IT Consultancy","twitter_card":"summary_large_image","twitter_creator":"@OneclickIT","twitter_site":"@OneclickIT","twitter_misc":{"Written by":"OneClick IT Consultancy","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#article","isPartOf":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter"},"author":{"name":"OneClick IT Consultancy","@id":"https:\/\/www.oneclickitsolution.com\/blog\/#\/schema\/person\/c2616c0a433427a79a96fe5ca2b34ec3"},"headline":"How to Implement Database Migration In CodeIgniter?","datePublished":"2024-01-02T11:11:54+00:00","dateModified":"2024-09-06T06:09:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter"},"wordCount":1185,"commentCount":0,"publisher":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#primaryimage"},"thumbnailUrl":"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2020\/02\/How-to-Implement-Database-Migration-In-CodeIgniter.png","keywords":["Website Development Solution"],"articleSection":["Web Application"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter","url":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter","name":"How to Implement Database Migration In CodeIgniter?","isPartOf":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#primaryimage"},"image":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#primaryimage"},"thumbnailUrl":"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2020\/02\/How-to-Implement-Database-Migration-In-CodeIgniter.png","datePublished":"2024-01-02T11:11:54+00:00","dateModified":"2024-09-06T06:09:04+00:00","description":"In this technical blog we cover step by step tutorial for setting up database migration in codeIgniter know more with examples.","breadcrumb":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#primaryimage","url":"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2020\/02\/How-to-Implement-Database-Migration-In-CodeIgniter.png","contentUrl":"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2020\/02\/How-to-Implement-Database-Migration-In-CodeIgniter.png","width":1200,"height":628,"caption":"How to Implement Database Migration In CodeIgniter"},{"@type":"BreadcrumbList","@id":"https:\/\/www.oneclickitsolution.com\/blog\/setting-up-migration-in-codeigniter#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.oneclickitsolution.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Implement Database Migration In CodeIgniter?"}]},{"@type":"WebSite","@id":"https:\/\/www.oneclickitsolution.com\/blog\/#website","url":"https:\/\/www.oneclickitsolution.com\/blog\/","name":"OneClick IT Consultancy","description":"We Build Brands from Ideas","publisher":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/#organization"},"alternateName":"OneClick IT Solution","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.oneclickitsolution.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.oneclickitsolution.com\/blog\/#organization","name":"OneClick IT Consultancy","alternateName":"OneClick IT Solution","url":"https:\/\/www.oneclickitsolution.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.oneclickitsolution.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2022\/10\/oneclick-official-logo.png","contentUrl":"https:\/\/www.oneclickitsolution.com\/blog\/wp-content\/uploads\/2022\/10\/oneclick-official-logo.png","width":100,"height":100,"caption":"OneClick IT Consultancy"},"image":{"@id":"https:\/\/www.oneclickitsolution.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/oneclickconsultancy","https:\/\/x.com\/OneclickIT","https:\/\/www.instagram.com\/oneclick.it.consultancy\/","https:\/\/www.linkedin.com\/company\/one-click-it-consultancy\/","https:\/\/www.pinterest.com\/oneclickitconsultancy\/","https:\/\/www.youtube.com\/channel\/UCsEG6aiwOwvYrcZxMoP5xjg","https:\/\/oneclickit.tumblr.com\/","https:\/\/dribbble.com\/oneclickitconsultancy"]},{"@type":"Person","@id":"https:\/\/www.oneclickitsolution.com\/blog\/#\/schema\/person\/c2616c0a433427a79a96fe5ca2b34ec3","name":"OneClick IT Consultancy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.oneclickitsolution.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8169ffe1b63da548d77fb666e94f1aba?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8169ffe1b63da548d77fb666e94f1aba?s=96&d=mm&r=g","caption":"OneClick IT Consultancy"},"description":"OneClick IT Consultancy is the best custom software development company based in India &amp; USA with expertise in BLE, travel, mobile, and web development. With nearly a decade\u2019s experience, we use best practices and development standards to deliver high-performance applications, focused on the user experience.","sameAs":["https:\/\/www.oneclickitsolution.com\/blog\/"],"jobTitle":"Founder","url":"https:\/\/www.oneclickitsolution.com\/blog\/author\/oneclick"}]}},"_links":{"self":[{"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/posts\/36407"}],"collection":[{"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/comments?post=36407"}],"version-history":[{"count":0,"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/posts\/36407\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/media\/53804"}],"wp:attachment":[{"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/media?parent=36407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/categories?post=36407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oneclickitsolution.com\/blog\/wp-json\/wp\/v2\/tags?post=36407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}