I am working on the model of my rails based website, and created a model class called ItemAttributes, which defines a set of valid attributes for a specific item. For example, 'bed size' is an attribute of the item 'bed.' I have also created a AttributeValue class which defines valid values for Attributes, like 'king' 'queen' 'full' etc.
I am attempting to populate the PostgreSQL database on heroku with a migration, but it throws this rather unhelpful error (the migration works locally on SQLite):
PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"attribute_values"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Here is the migration I am using:
class AddBedSizeValues < ActiveRecord::Migration
def self.up
id = ItemAttribute.find_by_name('bed size').id
AttributeValue.create(
:name => 'king',
:item_attribute_id => id
)
AttributeValue.create(
:name => 'queen',
:item_attribute_id => id
)
AttributeValue.create(
:name => 'full',
:item_attribute_id => id
)
AttributeValue.create(
:name => 'x-long twin',
:item_attribute_id => id
)
AttributeValue.create(
:name => 'twin',
:item_attribute_id => id
)
end