Mike Bailey

First Post(gresql)!

Filed under: postgresql — mbailey @ 2:43 am on April 21, 2009

Update: DB Table permissions don’t belong in migrations and aren’t added to schema.rb. I’ve added them to the bootstrap rake tasks.

I’m a postgresql newbie and suspect there will be a few more of us now that Oracle has brought Mysql. I’ve heard Ruby on Rails is a bit mysql centric. I know I have been for a few years. So I think it’s time to dust off the old blog and put it to use.

Postgresql permissions on a table appear to be removed when the table is removed.

I’ve added the following Rails migration to grant an outside user access to a single table in the schema:

class SetupRecipePerms < ActiveRecord::Migration
  def self.up
    ActiveRecord::Base.connection.execute "grant select,update,insert,delete on recipes to eggs_recipes;"
    if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
      ActiveRecord::Base.connection.execute "grant select,update on sequence recipes_id_seq to eggs_recipes;"
    end
  end
  ...

This doesn’t get added to schema.rb so doesn’t get run by “rake db:schema:load”

Will it get added to schema.rb if I’m running postgres locally (making it db dependent)?
How else might I add permissions as part of the standard Rails db setup?

WordPress database error: [Table './wordpress/wp_comments' is marked as crashed and should be repaired]
SELECT * FROM wp_comments WHERE comment_post_ID = '30' AND comment_approved = '1' ORDER BY comment_date

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Copyright 2007 Mike Bailey. All Rights Reserved