rails migration runs on local Postgresql but fails on prod
In short, dropping, creating, and running migrate on the local Postgres
instance will work any number of times for creating a working database for
my app, but the same technique on Heroku's prod always produces:
heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.9674
PG::UndefinedTable: ERROR: relation "mytable" does not exist
LINE 5: WHERE a.attrelid = '"mytable"'::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 = '"mytable"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
rake aborted!
PG::UndefinedTable: ERROR: relation "mytable" does not exist
LINE 5: WHERE a.attrelid = '"mytable"'::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 = '"mytable"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
This is what works locally:
rake db:drop
rake db:create
rake db:migrate
I have
confirmed that Heroku's db is blank before migration by doing heroku
pg:psql and then \dt to verify 0 tables exist.
tried heroku pg:reset DATABASE before the migrate
confirmed both local and prod Postgres is version 9.2.4
tried renaming the "mytable" migration file in db/migrate to have the
earliest timestamp so as to get run first
This is a pretty simple app so it's very frustrating that something basic
like creating a db from scratch keeps failing. Any ideas?
"mytable" migration:
class CreateMytable < ActiveRecord::Migration
def change
create_table :mytable do |t|
t.string :codes
t.string :name
t.timestamps
end
end
end
No comments:
Post a Comment