Reputation: 11509
I tried to drop and reset my database in development with: rake db:drop db:create db:migrate
and it didn't work for some reason. Now when I try to run that command I get:
FATAL: database "myapp_development" does not exist
FATAL: database "myapp_test" does not exist
ERROR: relation "posts" does not exist at character 315
STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"posts"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
If I try only rake db:create db:migrate
then I get the error
myapp_development already exists
myapp_test already exists
ERROR: relation "posts" does not exist at character 315...
If I run only rake db:migrate
then I get only the last part of the error:
PG::Error: ERROR: relation "posts" does not exist
LINE 5: WHERE a.attrelid = '"posts"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"posts"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
I tried restarting my database: pg_ctl stop -D /usr/local/var/postgres
pg_ctl start -D /usr/local/var/postgres
, but to no avail.
I'm at a complete standstill on this one. Anyone know how to get the database reset and re-migrated?
Upvotes: 1
Views: 536
Reputation: 11509
After much hassle in postgres, it turns out this had nothing to do with the database schema or postgres.
I just had to comment out my routes.rb file, which was referencing the Post model. With routes.rb commented out, I ran the migrations just fine, and then uncommented routes.rb.
Upvotes: 1