Skip to main content

Rails

Migrations

With Rails you can execute SQL in the change method of your migration class.

First, create a migration:

rails generate migration ElectrifyItems

Then e.g.:

class ElectrifyItems < ActiveRecord::Migration[7.0]
def change
execute "ALTER TABLE items ENABLE ELECTRIC"
end
end