When i try to do
rake db:reset
or
rake db:drop
rake db:create
rake db:schema:load
rake db:seed
I randomly get a NoMethodError: undefined method 'fields' for nil:NilClass
when the seed occurs.
Here's one:
[1m[35m (186.0ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20130318105449')
[1m[36m (187.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20130319154146')[0m
[1m[35m (189.0ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20130322132730')
[1m[36m (104.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20130322142814')[0m
NoMethodError: undefined method `fields' for nil:NilClass: SELECT COUNT(*)
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind in ('v','r')
AND c.relname = 'schema_migrations'
AND n.nspname = ANY (current_schemas(false))
Here's an other one:
[1m[35m (39.0ms)[0m BEGIN
[1m[36mCategory Exists (107.0ms)[0m [1mSELECT 1 AS one FROM "categories" WHERE "categories"."hash" = 'cat1' LIMIT 1[0m
[1m[35mSQL (124.0ms)[0m INSERT INTO "categories" ("category_id", "created_at", "label", "hash", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["category_id", 58], ["created_at", Mon, 25 Mar 2013 15:07:53 CET +01:00], ["label", "Cat1"], ["hash", "cat1"], ["updated_at", Mon, 25 Mar 2013 15:07:53 CET +01:00]]
[1m[36m (117.0ms)[0m [1mCOMMIT[0m
[1m[35m (162.0ms)[0m BEGIN
[1m[36mCategory Exists (136.0ms)[0m [1mSELECT 1 AS one FROM "categories" WHERE "categories"."hash" = 'cat2' LIMIT 1[0m
[1m[35mSQL (104.0ms)[0m INSERT INTO "categories" ("created_at", "label", "hash", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["created_at", Mon, 25 Mar 2013 15:07:53 CET +01:00], ["label", "Cat2"], ["hash", "cat2"], ["updated_at", Mon, 25 Mar 2013 15:07:53 CET +01:00]]
[1m[36m (99.0ms)[0m [1mCOMMIT[0m
[1m[35m (108.0ms)[0m BEGIN
[1m[36mCategory Exists (173.0ms)[0m [1mSELECT 1 AS one FROM "categories" WHERE "categories"."hash" = 'cat3' LIMIT 1[0m
NoMethodError: undefined method `fields' for nil:NilClass: SELECT 1 AS one FROM "categories" WHERE "categories"."hash" = 'cat3' LIMIT 1
I really do not understand where this can be coming from. Sometimes i don't even have an error and everything is perfectly inserted. After doing some tests it seems that it depends on the speed of insertion. If i execute this from my development server, it almost always succeed. If i execute this remotly from my computer, it almost always fails.
I'm using ruby 1.9.3 locally and ruby 2 on my development server. On both i'm using rails4 (edge) and my driver is postgresql (pg, no version specified)