public function up() { $this->createTable(\app\models\Author::tableName(), ['id' => Schema::TYPE_PK, 'firstname' => Schema::TYPE_STRING . ' NOT NULL', 'lastname' => Schema::TYPE_STRING]); $authors = [['firstname' => 'Harper', 'lastname' => 'Lee'], ['firstname' => 'Tom', 'lastname' => 'Rath'], ['firstname' => 'Roger', 'lastname' => 'Priddy']]; foreach ($authors as $a) { $author = new \app\models\Author(); $author->attributes = $a; $author->save(); } }