spree-subscriptions icon indicating copy to clipboard operation
spree-subscriptions copied to clipboard

rake db:seed exception

Open lancejpollard opened this issue 16 years ago • 3 comments

SQLite3::SQLException: PRIMARY KEY must be unique: INSERT INTO "option_types" ("name", "updated_at", "id", "presentation", "created_at") VALUES ('subscription-interval', '2009-12-28 22:46:36', 432467915, 'Interval', '2009-12-28 22:46:36')

I am running "rake db:bootstrap" and I get that. Any ideas? It happens when loading the fixtures.

lancejpollard avatar Dec 28 '09 22:12 lancejpollard

I'm using Spree gem version 0.9.99, and I'm note sure if this is a regression

http://railsdog.lighthouseapp.com/projects/31096/tickets/744-problems-with-dbbootstrap-in-0899

lancejpollard avatar Dec 28 '09 22:12 lancejpollard

Here is the full output, after the migrations:


loading fixture /Users/Lance/Documents/Development/git/spree/db/default/zones.yml
loading fixture /Users/Lance/Documents/Development/git/spree/db/default/roles.yml
loading fixture /Users/Lance/Documents/Development/git/spree/vendor/extensions/subscriptions/db/default/option_types.yml
loading fixture /Users/Lance/Documents/Development/git/spree/vendor/extensions/subscriptions/db/default/option_values.yml
loading fixture /Users/Lance/Documents/Development/git/spree/db/default/states.yml
loading fixture /Users/Lance/Documents/Development/git/spree/db/default/countries.yml
loading fixture /Users/Lance/Documents/Development/git/spree/db/default/zone_members.yml
Default data has been loaded
Loading db/seeds.rb for each extension
=========/Users/Lance/Documents/Development/git/spree/vendor/extensions/subscriptions/db/default
loading fixtures from /Users/Lance/Documents/Development/git/spree/vendor/extensions/subscriptions/db/default
rake aborted!
SQLite3::SQLException: PRIMARY KEY must be unique: INSERT INTO "option_types" ("name", "updated_at", "id", "presentation", "created_at") VALUES ('subscription-interval', '2009-12-28 22:46:36', 432467915, 'Interval', '2009-12-28 22:46:36')

lancejpollard avatar Dec 28 '09 22:12 lancejpollard

I think we might not even need that in the extension, it looks like spree is figuring it out on it's own.

I added this:


def yaml_to_database(fixture, path)
  ActiveRecord::Base.establish_connection(RAILS_ENV)
  tables = Dir.new(path).entries.select{|e| e =~ /(.+)?\.yml/}.collect{|c| c.split('.').first}
  begin
    Fixtures.create_fixtures(path, tables)
  rescue Exception => e
    puts 'problem loading fixtures from subscriptions extension'
  end
end

And it's basically skipping everything because they were already loaded.

lancejpollard avatar Dec 28 '09 23:12 lancejpollard