One thing I didn’t immediately find was how to insert data. Phinx has seed functionality but in this case I needed to put in a lookup table to go along with a data structure change. It’s actually simple to do so here’s the example (so I can find it again!):
$roles_table = $this->table('roles'); $roles_table // id created automatically ->addColumn('name', 'string') ->create(); $roles_table->insert(["name"], [["admin"]]); $roles_table->saveData();
The only gotcha here is that when changing a table structure you call
save() and when saving data you call
saveData(). The seed data is ideal for content, but if you do want to insert data along with a structure change, this is a good way to do it.