Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alchemy upgrade ForeignKeyViolation #1326

Closed
chalmagean opened this issue Nov 17, 2017 · 8 comments
Closed

Alchemy upgrade ForeignKeyViolation #1326

chalmagean opened this issue Nov 17, 2017 · 8 comments

Comments

@chalmagean
Copy link
Contributor

I'm trying to run bin/rake alchemy:upgrade to update my db schema and I get this error:

== 20171117141153 AddForeignKeys: migrating ===================================
-- add_foreign_key(:alchemy_cells, :alchemy_pages, {:column=>:page_id, :on_update=>:cascade, :on_delete=>:cascade, :name=>:alchemy_cells_page_id_fkey})
   -> 0.0020s
-- add_foreign_key(:alchemy_contents, :alchemy_elements, {:column=>:element_id, :on_update=>:cascade, :on_delete=>:cascade, :name=>:alchemy_contents_element_id_fkey})
   -> 0.0016s
-- add_foreign_key(:alchemy_elements, :alchemy_pages, {:column=>:page_id, :on_update=>:cascade, :on_delete=>:cascade, :name=>:alchemy_elements_page_id_fkey})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::ForeignKeyViolation: ERROR:  insert or update on table "alchemy_elements" violates foreign key constraint "alchemy_elements_page_id_fkey"
DETAIL:  Key (page_id)=(5) is not present in table "alchemy_pages".
: ALTER TABLE "alchemy_elements" ADD CONSTRAINT "alchemy_elements_page_id_fkey"
FOREIGN KEY ("page_id")
  REFERENCES "alchemy_pages" ("id")
 ON DELETE CASCADE ON UPDATE CASCADE
@mamhoff
Copy link
Contributor

mamhoff commented Nov 17, 2017

Please try running the alchemy:db:tidy rake task before attempting to alchemy:upgrade.

@chalmagean
Copy link
Contributor Author

Running that blows up.

ActiveRecord::RecordNotFound: Couldn't find Alchemy::Element with 'id'=357

@chalmagean
Copy link
Contributor Author

chalmagean commented Nov 18, 2017

Running it a second time worked :)

But then I get another exception

Install asset manifests into `vendor/assets`
--------------------------------------------
      create  vendor/assets/javascripts/alchemy/admin/all.js
      create  vendor/assets/stylesheets/alchemy/admin/all.css

Store image file format
-----------------------
-- Storing file format of 269 pictures
   -> Reading file format of 5-lance-anderson.jpg (1/269)
rake aborted!
NoMethodError: undefined method `identify' for #<#<Class:0x007fa0fbde40d8>:0x007fa0fbf265b8>
.../bundler/gems/alchemy_cms-0ed9f0f4fbd1/lib/alchemy/upgrader/three_point_four.rb:21:in `block in store_image_file_format'

@tvdeyen
Copy link
Member

tvdeyen commented Nov 18, 2017

identify is an imagemagick tool. Do you have imagemagick installed on that machine?

@chalmagean
Copy link
Contributor Author

Yes, I do.

$ identify -version
Version: ImageMagick 7.0.7-8 Q16 x86_64 2017-10-24 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib

But the error seems to be referring to an undefined method.

@chalmagean
Copy link
Contributor Author

I've added a PR for this.

@tvdeyen
Copy link
Member

tvdeyen commented Nov 24, 2017

Closed by #1327

@tvdeyen tvdeyen closed this as completed Nov 24, 2017
@chalmagean
Copy link
Contributor Author

Just to provide some documentation for anyone else getting the error I mentioned in the issue.

I had to run rake alchemy:tidy:up twice and then do the rake alchemy:upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants