I'm creating migration like below. I couldn't find a way to seed db. Looking for something similar db:seed in laravel ?
public function up(Schema $schema)
{
$table = $schema->createTable('user_map');
$table->addColumn('id', 'integer', ['autoincrement'=>true]);
$table->addColumn('user_id', 'integer', ['notnull'=>true]);
$table->addColumn('relation_id', 'integer', ['notnull'=>true]);
$table->setPrimaryKey(['id']);
$table->addOption('engine' , 'InnoDB');
}
One way to insert data in the table created at your migration is to do it in the postUp() method. Just add in your migration class:
public function postUp(Schema $schema)
{
$this->connection->insert('user_map', array(
'user_id' => 1,
'relation_id' => 2
));
parent::postUp($schema);
}