Guest User

Untitled

a guest
Jul 12th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. class Category
  2. include DataMapper::Resource
  3.  
  4. property :id, Serial
  5. property :name, String
  6.  
  7. has n, :categories, :through => Resource, :constraint => :destroy!
  8.  
  9. end
  10.  
  11. class Category
  12. include DataMapper::Resource
  13.  
  14. property :id, Serial
  15. property :name, String
  16.  
  17. has n, :comments, :through => Resource, :constraint => :destroy!
  18.  
  19. end
  20.  
  21. # On MySQL
  22. rake db:automigrate # First run works fine
  23. rake db:automigrate # Run it again and it blows up with "Cannot delete or update a parent row: a foreign key constraint fails (code: 1217, sql state: 23000, query: DROP TABLE IF EXISTS "categories")"
Add Comment
Please, Sign In to add comment