PHP code example of php-bread-and-butter / codeignitermigration

1. Go to this page and download the library: Download php-bread-and-butter/codeignitermigration library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

php-bread-and-butter / codeignitermigration example snippets


 defined('BASEPATH') or exit('No direct script access allowed');

class Migration_Add_New_Post_Table extends CI_Migration
{
    public function up() {
        // this up() migration is auto-generated, please modify it to your needs
        // Drop table 'table_name' if it exists
        $this->dbforge->drop_table('table_name', true);

        // Table structure for table 'table_name'
        $this->dbforge->add_field(array(
            'id' => array(
                'type' => 'MEDIUMINT',
                'constraint' => '8',
                'unsigned' => true,
                'auto_increment' => true
            ),
            'created_at' => array(
                'type' => 'DATETIME',
                'null' => false,
            )
        ));
        $this->dbforge->add_key('id', true);
        $this->dbforge->create_table('table_name');
    }

    public function down()
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->dbforge->drop_table('table_name', true);
    }
}


$ composer 

$ php vendor/php-bread-and-butter/codeignitermigration/ci migration:bare add_new_post_table

$ cd vendor/php-bread-and-butter/codeignitermigration
$ php ci migration:bare add_new_post_table

$ php ci migration:bare add_new_column_to_post_table
$ php ci migration:bare modify_post_table
$ php ci migration:bare update_post_table
$ php ci migration:bare rename_post_table
$ php ci migration:bare remove_post_table

$ php vendor/php-bread-and-butter/codeignitermigration/migrate

$ php vendor/php-bread-and-butter/codeignitermigration/suppress ${VERSION}