I'm trying to upgrade to 0.2. The rake db:migrate step is failing:
$ DATABASE_URL=postgres://...@localhost/tent_server bundle exec rake db:migrate
Error: Sequel::DatabaseError: PG::Error: ERROR: insert or update on table "post_versions_mentions" violates foreign key constraint "post_versions_mentions_mention_id_fkey"
DETAIL: Key (mention_id)=(309) is not present in table "mentions".
It appears to be this migration, 002_post_versions_many_to_many.rb.
There's no row in the mentions table with id=309, but I'm not sure why that would be a problem? If I show the whole table, about 100 IDs are skipped.
Fix 0.2 002_post_versions_many_to_many migration
The relavant portion of the migration is:
INSERT INTO post_versions_mentions
SELECT id AS mention_id, post_version_id FROM mentions
WHERE mentions.post_version_id IS NOT NULL;
what appears to be happening is postgres is inserting the selected columns in column definition order (as described in the docs) but the columns are mistakenly being selected in the oposite order. tent/tentd@d2047f3 reorders the columns in the create table statement so the query will work as expected.
id 309 I expect is referencing the post_versions table.
That seems to have done it. Thanks Jesse!