Welcome Guest, Not a member yet? Register   Sign In
Add dummy content when running migrations
#1

Hi all, I'd like some feedback please, if possible. I'm using CI v3 and I was wondering whether there's a way I could enter some dummy content on the tables I generate running through Migrations.

For instance when I run this migration

PHP Code:
class Migration_Add_blog extends CI_Migration {

        public function 
up()
        {
                
$this->dbforge->add_field(array(
                        
'blog_id' => array(
                                
'type' => 'INT',
                                
'constraint' => 5,
                                
'unsigned' => TRUE,
                                
'auto_increment' => TRUE
                        
),
                        
'blog_title' => array(
                                
'type' => 'VARCHAR',
                                
'constraint' => '100',
                        ),
                        
'blog_description' => array(
                                
'type' => 'TEXT',
                                
'null' => TRUE,
                        ),
                ));
                
$this->dbforge->add_key('blog_id'TRUE);
                
$this->dbforge->create_table('blog');
        }

        public function 
down()
        {
                
$this->dbforge->drop_table('blog');
        }


Is there also a way I could enter a few dummy blog posts to see as an example ?

One additional question regarding the Migrations. If I have the migrations types set as
PHP Code:
$config['migration_type'] = 'timestamp'
when I run this command
PHP Code:
$this->migration->version(5); 
do I have to enter the full timestamp or just the number version and if so how can I get the timestamp ?

Thanks in advance
Reply


Messages In This Thread
Add dummy content when running migrations - by Lykos22 - 10-05-2015, 02:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB