Remove raw SQL from migrations, take 2

Removed raw SQL from migrations except for permissions-related SQL where
old column names contain '.', which causes CodeIgniter to insert the
table prefix, and the users table's timestamp.