我正在研究基于rails的网站的模型,并创建了一个名为ItemAttributes的模型类,它定义了一组特定项目的有效属性。例如,“床大小”是物品“床”的属性。我还创建了一个AttributeValue类,它为属性定义了有效值,如'king''queen''full'等。Heroku PostgreSQL迁移问题
我试图在迁移时在heroku上填充PostgreSQL数据库,但它会抛出这个而不起作用错误(迁移本地工作的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
这里是我使用的迁移:
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
我尝试在此迁移中删除所有“创建”,并且顺利完成。一旦我将一个创建添加到迁移中,同样的错误将会返回。 – kleptocrat 2011-04-12 17:55:26
Heroku开发人员悲伤的头号原因是在本地使用SQLite。 PostgreSQL是免费的。下载它,安装它,并停止使用SQLite。 – 2011-05-21 11:08:08