The database migrations documentation does say:
Please note that we do not recommend using records directly within a migration
Are there technical reasons for this recommendation, or is it something you'd just rather not support? I don't mind if I'm on my own as far as support goes, but it seems like I might be able to use migrations to deploy schema changes across environments if I was careful?
Of course this would be for private, site-specific plugins, not anything that was going to be publicly released, so I don't think the issue Brandon highlighted here would necessarily apply.
I have successfully created a new tag group using the following:
public function safeUp()
{
$tagGroup = new TagGroupModel();
$tagGroup->name = Craft::t('Tag Group');
$tagGroup->handle = 'tagGroup';
craft()->tags->saveTagGroup($tagGroup);
}
But obviously this is quite a simple example, and a migration that added fields, sections and entry types (like the InstallService does) would be more complicated and should probably check each record was saved properly before continuing with the next bit.
Are all of Craft's services available while a migration is being run?