« November 2006 | Main | February 2007 »

December 07, 2006

Reading PostgreSQL Meta Data

Listen to this articleListen to this article

If, like me, you need to read in various bits and pieces of meta-data in PostgreSQL, you've probably found it rather tiresome navigating your way around the various pg_catalog tables in order to determine where the one piece of information you need lives.

After a bit of googling, I discovered a nifty option you can set in psql:

\set ECHO_HIDDEN 'yes'

Then whenever you describe a table, index, etc. using \d and friends, you'll also get the SQL that was used!

December 02, 2006

Conventions Were Made to be Broken

Listen to this articleListen to this article

The Rails convention for naming foreign key fields is to use the singular name of the table with a suffix of _id.

In the past few days a number of people using the Foreign Key Migrations plugin together with ActiveRecord session store have discovered that the exception to the rule is session_id in the sessions table. In this case, session_id is not a recursive relationship but an unfortunately named field.

The solution is to update the migration script and add :references => nil to the line that adds the session_id. The plugin will then ignore the column and not attempt to generate a database foreign key constraint.

RedHill on Rails Plugins 1.2

Listen to this articleListen to this article

With the pending release of Rails 1.2, I've taken the opportunity to begin updating the plugins to take advantage of various 1.2 features such as alias_method_chain and to remove where possible, work-arounds for bugs that have been fixed. So, as of today, the trunk will only run against Rails 1.2.

For those not lucky or perhaps not foolish enough to start using the latest and greatest that Rails has to offer, you can find all the Rails 1.1.6 compatible versions of the plugins at:

svn://rubyforge.org/var/svn/redhillonrails/tags/release-1.1.6/vendor/plugins

Enjoy!