Running raw migrations for Vapor Fluent

Aron Budinszky
hoursofoperation
Published in
Oct 2, 2022

Vapor’s migrations API allows you to keep your database schema up to date with your API implementation. The vast majority of the time this API covers all your needs — but there will be the occasional instance where you need a totally custom SQL command or setting that is simply not supported by the API.

Photo by Alfons Morales on Unsplash

One example of this was MySQL ENUMs with default values. Though creating them was possible via the API (although already using .custom() so already partially a raw query) updating failed to work.

Fortunately you can drop down to lower-level SQL and simply run a fully raw SQL command as part of your migration. Here’s how:

--

--