heroku rake db:migrate
== AddFilesizeToPapclip: migrating ===========================================
-- add_column(:papclips, :files_file_size, :string)
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::DuplicateColumn: ERROR: column "files_file_size" of relation "papclips" already exists
then how can i rectify this error?
Advance Thanks.
The AddFilesizeToPapclip migration tries to add a database column files_file_size that already exists in table papclips.
If you want to manually remove this column, try this:
Open a Rails console on your Heroku app: heroku run console
Then run this code: ActiveRecord::Migration.remove_column :papclips, :files_file_size
Related
The full error is
~/.gem/ruby/2.4.0/gems/railties-5.1.5/lib/rails/command/actions.rb:8:in `set_application_directory!': uninitialized constant Rails::Command::Actions::APP_PATH (NameError)
I recently upgrade from Rails 4.x to 5.x.
You need to generate (or regenerate) "binstubs" for the dummy application.
cd spec/dummy
bundle exec rails app:update:bin
You should now be able to start the dummy application, from the spec/dummy directory, as such:
bundle exec bin/rails server
The spec/dummy/script directory can also be deleted.
I've got an existing rails app, and I've added an ember front-end. I'm having trouble deploying the new version (which includes Ember for the first time) to Heroku.
The problem is that I'm unable to run rake tasks in production mode.
I discovered this when I tried to rake db:migrate on heroku. I got the following error:
rake aborted!
undefined method `handlebars' for #<Rails::Application::Configuration:0x00000004f0de90>/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configuration.rb:85:in `method_missing'
/app/config/application.rb:60:in `<class:Application>'
I get the same error if I try to run any tasks locally in production mode, e.g.:
RAILS_ENV=production rake -T
the offending line, from config/application.rb:
config.handlebars.templates_root = 'ember/templates'
for various reasons, I had to move the ember templates down one file level. and it needs to stay there. everything works fine in development mode.
Any idea how I can fix this?
tried upgrading the ember-rails gem. this didn't help. (I'm using 0.12.0)
trick was to move ember-rails gem out of assets group
I had a working setup using Rails 3.1 and Postgres 9.0 and just upgraded Rails to 3.2.1 and Postgres 9.1.2.
Upgrading postgres meant migrating the data as the 2 versions datastores are incompatible. I didn't care much to migrate the data in my local db's as they are all used for development purposes anyway. So I'm trying to recreate my databases using Rails migrations (or w/ schema). However no matter what I try I cannot get the migrations to run.
Using either
rake db:migrate
or
rake db:reset
Running this on with my Postgres 9.1.2 setup gives me:
spif: > rake db:migrate
rake aborted!
PG::Error: ERROR: relation "users" does not exist
LINE 4: WHERE a.attrelid = '"users"'::regclass
^
: 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 = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
At first I though it might be that the pg gem doesn't support Rails 3.2.1 yet so tried with sqlite3 as well but that gives me the same users not found:
spif: > rake db:reset
rake aborted!
Could not find table 'users'
So it looks like Rails expects a users table somewhere.
I have no clue how to find out what code is actually calling this. When I run the migration commands with --trace it show's that is ActiveRecord internals doing it. Can this be a bug in ActiveRecord 3.2.1 (how would I go about finding that out?).
I can connect to the pg db's fine using psql and my user setup in config/database.yml. Does rails expect some postgres tables that it can query about users?
I have completely removed my db/migrate directory and the db/schema.rb in order to make sure there is not some strange internal dependency there but also to no avail.
I'm sure I'm missing some simple concept - I haven't often tried to reset my db from scratch so I hope there is a simple explanation.
Thanks, help very much appreciated.
I solved this by manually creating the users table and each other table I had in this project. Then ran the migrations again and everything is setup fine. There were only a few tables so it wasn't too cumbersome but not the "fix" I was trying to find.
Looks like 'mu is too short' was right that this is related to ActiveAdmin and the way it loads itself when loading the environment during any db operation (or rails server/console too for that matter).
Thanks for the pointers mu.
DO you use any model load in initializers?
I had the same problem and i was loading the model in an initializer, so the error comes, because the table doesn't exist before doing the migration and i was trying to load something that ever doesn't exist!
I am new to ruby on rails, just trying to follow some tutorials.I just entered:
rails generate controller helloWorld index
then i started rails server and tried to access http://localhost:3000/hello_world/index
and got
Action controller: Exception Caught
ActiveRecord::ConnectionNotEstablished
ActiveRecord::ConnectionNotEstablished
in the browser
Did you run rake db:create db:migrate before starting the server.
If you did, pls check your database configuration in config/database.yml. If you can't figure it out, please let us know the contents of that file.
I'm having the same heroku rake issues described (and from what I can tell solved) in this question.
When I try the fix (include require 'rake/dsl_definition' above require 'rake') I get the same
'uninitialized constant Rake::DSL'
error from heroku + I get the error
'no such file to load -- rake/dsl_definition'
from my local rake.
Without incorporating the fix (using the standard rakefile) I can use rake on my local setup with no errors (with the same heroku error)
I'm using rake version 0.8.7 (though I get the same results using 0.9.2) and Rails 3.0.9. I've gone through the suggestions in the previous question but from what I can tell the problem isn't with my Gemfile. Has anyone else had this problem? Has anyone else solved their heroku rake problem using a different solution? Or can anyone explain/suggest how I'm going about this incorrectly?
Thank you for your help.
Try adding require 'rake/dsl_definition' on top of Rakefile.
Not enough for me. I was getting the no such file to load -- rake/dsl_definition error even adding the require 'rake/dsl_definition' line in the "Rakefile" file
I had all gems version OK and only 0.8.7 rake version but I had to create a "Gemfile" in the redmine root path with the next content:
gem "rake", "0.8.7"
And delete the require 'rake/dsl_definition' line added previously in Rakefile
Hope be usefull for someone