Skip to main content

Rails

Migrations

Proxying

To run your migrations through the proxy set DATABASE_URL to connect to the proxy when running migrations, e.g.:

DATABASE_URL=postgresql://postgres:$PG_PROXY_PASSWORD@localhost:$PG_PROXY_PORT/mydb rake db:migrate

Applying DDLX statements

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