Help understanding permissions during `fly deploy` and which user is running migrations

I am trying to run a migration that in addition to changing a schema ALSO updates a column.

As an example:

def change
add_column :stuff, :a, :string

reversible do |direction|
  direction.up do
    execute <<-SQL
      UPDATE stuff
      SET a = meta->>'a';
    SQL
  end
end

end

It fails with the error message: PG::InsufficientPrivilege: ERROR: permission denied for table stuff

How should I go about debugging this?

Actually it appears that the table-owner is just wrong (this was previously attached to a different app).

Is there any way for me to change table ownership from a previous app owner that I have deleted?

I resolved this by exporting all the records, rebuilding the DB and then reimporting them. That reset the table permissions.

Also, remember Fly Posgres is just… Postgres :slight_smile: so you can fly postgres connect and manage permissions by hand (Fly.io postgres is user-managed, I would certainly recommend getting comfortable with role and permission management if you intend to use it in anger!).

  • Daniel
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.