Open solnic opened 13 years ago
~ (0.000052) PRAGMA table_info("ronin_addresses")
~ (0.000307) CREATE TABLE "ronin_addresses" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "type" VARCHAR NOT NULL, "address" VARCHAR(50) NOT NULL, "created_at" TIMESTAMP NOT NULL, "frozen_tag_list" TEXT, "organization_id" INTEGER, "version" INTEGER NOT NULL)
~ (0.000117) CREATE INDEX "index_ronin_addresses_organization" ON "ronin_addresses" ("organization_id")
~ (0.000113) CREATE UNIQUE INDEX "unique_ronin_addresses_address" ON "ronin_addresses" ("address")
~ (0.000078) PRAGMA table_info("ronin_addresses")
~ (0.000143) PRAGMA table_info("ronin_addresses")
~ duplicate column name: id (code: 1, sql state: , query: ALTER TABLE "ronin_addresses" ADD COLUMN "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, uri: sqlite3://:memory:)
/home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/adapters/dm-do-adapter.rb:70:in `execute_non_query’: duplicate column name: id (DataObjects::SyntaxError)
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/adapters/dm-do-adapter.rb:70:in `block (2 levels) in upgrade_model_storage’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/adapters/dm-do-adapter.rb:64:in `map’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/adapters/dm-do-adapter.rb:64:in `block in upgrade_model_storage’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-do-adapter-1d52cea8904d4da687c2fddabd5bf999c94cd21e-master/lib/dm-do-adapter/adapter.rb:260:in `with_connection’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/adapters/dm-do-adapter.rb:63:in `upgrade_model_storage’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:71:in `upgrade_model_storage’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:143:in `auto_upgrade!’
from /vault/1/code/ronin/ronin/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:145:in `auto_upgrade!’
from /vault/1/code/ronin/ronin/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:45:in `block in repository_execute’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-core-37b4bd22b9e3842977cf83d32baba459607e900a-master/lib/dm-core/model/descendant_set.rb:33:in `block in each’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-core-37b4bd22b9e3842977cf83d32baba459607e900a-master/lib/dm-core/model/descendant_set.rb:33:in `each’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-core-37b4bd22b9e3842977cf83d32baba459607e900a-master/lib/dm-core/model/descendant_set.rb:33:in `each’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:44:in `repository_execute’
from /home/hal/.bundle/ruby/1.9.1/bundler/gems/dm-migrations-10e2a03514bd272776b61444593ff4b4fe608269-master/lib/dm-migrations/auto_migration.rb:27:in `auto_upgrade!’
from /vault/1/code/ronin/ronin/lib/ronin/database/database.rb:190:in `block in upgrade’
from /vault/1/code/ronin/ronin/lib/ronin/database/database.rb:189:in `each_key’
from /vault/1/code/ronin/ronin/lib/ronin/database/database.rb:189:in `upgrade’
from /vault/1/code/ronin/ronin/lib/ronin/database/database.rb:215:in `setup’
from /vault/1/code/ronin/ronin/spec/spec_helper.rb:25:in `block (2 levels) in <top (required)>’
from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `call’
from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `block in run_examples’
from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `each’
from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `run_examples’
from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run’
from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/bin/spec:5:in `<main>’
rake aborted!
Command /usr/bin/ruby19 -I"lib:lib:spec" "/usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/bin/spec" "spec/author_spec.rb" "spec/os_spec.rb" "spec/installation_spec.rb" "spec/ronin_spec.rb" "spec/ui/command_line/command_spec.rb" "spec/ui/output_spec.rb" "spec/model/has_name_spec.rb" "spec/model/has_description_spec.rb" "spec/model/has_license_spec.rb" "spec/model/model_spec.rb" "spec/model/lazy_upgrade_spec.rb" "spec/license_spec.rb" "spec/platform/overlay_spec.rb" "spec/platform/extension_cache_spec.rb" "spec/platform/overlay_cache_spec.rb" "spec/platform/maintainer_spec.rb" "spec/platform/extension_spec.rb" "spec/platform/cached_file_spec.rb" "spec/platform/platform_spec.rb" "spec/platform/cacheable_spec.rb" "spec/software_spec.rb" "spec/database_spec.rb" "spec/arch_spec.rb" "spec/vendor_spec.rb" "spec/url_spec.rb" --options .specopts failed
(See full trace by running task with --trace)
by Postmodern
I did some research into this test today, but I haven’t been able to narrow down the cause. I think it’s something inside DO or SQLite causing the problem. Here’s what I do know:
At this point I am unsure what the solution is. I think this will require more research, so I am removing it from the 1.0.0 milestone.
@Dirkjan: Can you think of anything that would cause this behaviour?
by Dan Kubb (dkubb)
A user who was testing Ronin edge and DataMapper 1.0.0.rc3 on Ruby 1.8.7 and OpenSolaris (libsqlite3 3.6.17) was able to reproduce the error:
~> ronin-web
/var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/adapters/dm-do-adapter.rb:70:in `execute_non_query’: duplicate column name: id (DataObjects::SyntaxError)
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/adapters/dm-do-adapter.rb:70:in `upgrade_model_storage’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/adapters/dm-do-adapter.rb:64:in `map’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/adapters/dm-do-adapter.rb:64:in `upgrade_model_storage’
from /var/ruby/1.8/gem_home/gems/dm-do-adapter-1.0.0.rc3/lib/dm-do-adapter/adapter.rb:260:in `with_connection’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/adapters/dm-do-adapter.rb:63:in `upgrade_model_storage’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:71:in `upgrade_model_storage’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:143:in `auto_upgrade!’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:145:in `auto_upgrade!’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:45:in `send’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:45:in `repository_execute’
from /var/ruby/1.8/gem_home/gems/dm-core-1.0.0.rc3/lib/dm-core/model/descendant_set.rb:33:in `each’
from /var/ruby/1.8/gem_home/gems/dm-core-1.0.0.rc3/lib/dm-core/model/descendant_set.rb:33:in `each’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:44:in `repository_execute’
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:27:in `auto_upgrade!’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:190:in `upgrade’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:189:in `each_key’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:189:in `upgrade’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:215:in `setup’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/environment.rb:37
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin.rb:21
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/console.rb:171:in `start’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/console.rb:170:in `instance_eval’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/console.rb:170:in `start’
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/command_line/commands/console.rb:60:in `execute’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/task.rb:33:in `send’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/task.rb:33:in `run’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/invocation.rb:109:in `invoke’
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `map’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/core_ext/ordered_hash.rb:73:in `each’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/invocation.rb:118:in `map’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/invocation.rb:118:in `invoke’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/group.rb:36:in `start’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/base.rb:378:in `start’
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/group.rb:29:in `start’
from /var/ruby/1.8/gem_home/gems/ronin-web-0.2.2/bin/ronin-web:14
from /var/ruby/1.8/gem_home/bin/ronin-web:19:in `load’
from /var/ruby/1.8/gem_home/bin/ronin-web:19
Note: Ronin by default uses the sqlite3 "~/.ronin/database.sqlite3".
by Postmodern
I am able to reproduce this bug on JRuby 1.5.1:
$ DEBUG=true rake spec
(in /vault/1/code/ronin/ronin)
You don’t have tzinfo installed in your application. Please add it to your Gemfile and run bundle install
You don’t have tzinfo installed in your application. Please add it to your Gemfile and run bundle install
~ (0.000) SELECT sqlite_version(*)
~ (0.057) CREATE TABLE "ronin_vendors" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50) NOT NULL)
~ (0.018) CREATE UNIQUE INDEX "unique_ronin_vendors_name" ON "ronin_vendors" ("name")
~ (0.028) CREATE TABLE "ronin_arches" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50) NOT NULL, "endian" VARCHAR(50) NOT NULL, "address_length" INTEGER NOT NULL)
~ (0.019) CREATE UNIQUE INDEX "unique_ronin_arches_name" ON "ronin_arches" ("name")
~ (0.037) CREATE TABLE "taggings" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "taggable_id" INTEGER NOT NULL, "taggable_type" VARCHAR NOT NULL, "tag_context" VARCHAR(50) NOT NULL, "tag_id" INTEGER NOT NULL)
~ (0.032) CREATE INDEX "index_taggings_tag" ON "taggings" ("tag_id")
~ (0.024) CREATE TABLE "tags" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50) NOT NULL)
~ (0.024) CREATE UNIQUE INDEX "unique_tags_name" ON "tags" ("name")
~ (0.029) CREATE TABLE "ronin_organizations" ("name" VARCHAR(50) NOT NULL, "description" VARCHAR(65535), "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "created_at" TIMESTAMP NOT NULL, "frozen_tag_list" TEXT)
~ (0.035) CREATE INDEX "index_ronin_organizations_name" ON "ronin_organizations" ("name")
~ (0.031) CREATE TABLE "ronin_addresses" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "type" VARCHAR NOT NULL, "address" VARCHAR(50) NOT NULL, "created_at" TIMESTAMP NOT NULL, "frozen_tag_list" TEXT, "organization_id" INTEGER, "version" INTEGER NOT NULL)
~ (0.037) CREATE INDEX "index_ronin_addresses_organization" ON "ronin_addresses" ("organization_id")
~ (0.032) CREATE UNIQUE INDEX "unique_ronin_addresses_address" ON "ronin_addresses" ("address")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.000) PRAGMA table_info("ronin_addresses")
~ (0.025) CREATE TABLE "ronin_ip_address_mac_addresses" ("created_at" TIMESTAMP NOT NULL, "ip_address_id" INTEGER NOT NULL, "mac_address_id" INTEGER NOT NULL, PRIMARY KEY("ip_address_id", "mac_address_id"))
~ (0.025) CREATE INDEX "index_ronin_ip_address_mac_addresses_ip_address" ON "ronin_ip_address_mac_addresses" ("ip_address_id")
~ (0.030) CREATE INDEX "index_ronin_ip_address_mac_addresses_mac_address" ON "ronin_ip_address_mac_ad/home/hal/.rvm/gems/jruby-1.5.1/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:64:in `map’: duplicate column name: id (code: 0, sql state: , query: , uri: ) (DataObjects::SQLError)
from /home/hal/.rvm/gems/jruby-1.5.1/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:64:in `upgrade_model_storage’
from /home/hal/.rvm/gems/jruby-1.5.1/gems/dm-do-adapter-1.0.0/lib/dm-do-adapter/adapter.rb:260:in `with_connection’
from /home/hal/.rvm/gems/jruby-1.5.1/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:63:in `upgrade_model_storage’
from /home/hal/.rvm/gems/jruby-1.5.1/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:71:in `upgrade_model_storage’
from /home/hal/.rvm/gems/jruby-1.5.1/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:143:in `auto_upgrade!’
from /vault/1/code/ronin/ronin/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!’
from /home/hal/.rvm/gems/jruby-1.5.1/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migratidresses" ("mac_address_id")
~ (0.018) CREATE TABLE "ronin_credentials" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "user" VARCHAR(50), "password" VARCHAR(50))
~ (0.000) PRAGMA table_info("ronin_credentials")
~ duplicate column name: id (code: 0, sql state: , query: , uri: )
on.rb:145:in `auto_upgrade!’
from /vault/1/code/ronin/ronin/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!’
... 13 levels...
from /home/hal/.rvm/gems/jruby-1.5.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `run_examples’
from /home/hal/.rvm/gems/jruby-1.5.1/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run’
from /home/hal/.rvm/gems/jruby-1.5.1/gems/rspec-1.3.0/bin/spec:5
rake aborted!
Command /home/hal/.rvm/rubies/jruby-1.5.1/bin/jruby -I"lib:lib:spec" "/home/hal/.rvm/gems/jruby-1.5.1/gems/rspec-1.3.0/bin/spec" "spec/installation_spec.rb" "spec/vendor_spec.rb" "spec/arch_spec.rb" "spec/os_spec.rb" "spec/database_spec.rb" "spec/license_spec.rb" "spec/author_spec.rb" "spec/software_spec.rb" "spec/url_spec.rb" "spec/ronin_spec.rb" "spec/ui/output_spec.rb" "spec/ui/command_line/command_spec.rb" "spec/model/model_spec.rb" "spec/model/lazy_upgrade_spec.rb" "spec/model/has_name_spec.rb" "spec/model/has_description_spec.rb" "spec/model/has_license_spec.rb" "spec/platform/cacheable_spec.rb" "spec/platform/extension_cache_spec.rb" "spec/platform/overlay_spec.rb" "spec/platform/maintainer_spec.rb" "spec/platform/overlay_cache_spec.rb" "spec/platform/extension_spec.rb" "spec/platform/platform_spec.rb" "spec/platform/cached_file_spec.rb" --options .specopts failed
(See full trace by running task with --trace)
by Postmodern
I'm getting this issue too.
1.9.2-p290 dm-core 1.2.0 dm-migrations 1.2.0
/Users/darren/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/adapters/dm-do-adapter.rb:70:in `execute_non_query': duplicate column name: id (DataObjects::SyntaxError)
from /Users/darren/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/dm-migrations-1.2.0/lib/dm-migrations/adapters/dm-do-adapter.rb:70:in `block (2 levels) in upgrade_model_storage'
Same deal as you, auto_migrate!
works.
I was able to work around this issue with this
DataMapper::Model.descendants.each {|m| m.auto_upgrade! if m.superclass == Object}
as a replacement for DataMapper.auto_upgrade!
I'm getting the same issue. It's especially annoying when adding a new index, since it tries to add it twice.
It also seems to happen with DataMapper.auto_migrate!
as well:
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite::memory:')
class Shape
include DataMapper::Resource
property :id, Serial
property :type, Discriminator
property :name, String, :index => true
end
class Circle < Shape
end
DataMapper.finalize
DataMapper.auto_migrate!
When fresh it runs correctly, but the tables are being created twice:
~ (0.000048) SELECT sqlite_version(*)
~ (0.000097) DROP TABLE IF EXISTS "shapes"
~ (0.000011) PRAGMA table_info("shapes")
~ (0.000426) CREATE TABLE "shapes" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "type" VARCHAR NOT NULL, "name" VARCHAR(50))
~ (0.000129) CREATE INDEX "index_shapes_name" ON "shapes" ("name")
~ (0.000163) DROP TABLE IF EXISTS "shapes"
~ (0.000009) PRAGMA table_info("shapes")
~ (0.000144) CREATE TABLE "shapes" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "type" VARCHAR NOT NULL, "name" VARCHAR(50))
~ (0.000123) CREATE INDEX "index_shapes_name" ON "shapes" ("name")
However, if the table already exists and I run auto_upgrade!
instead, I get a duplicate column name
error when it tries to add the index the second time.
I'm using data_mapper (1.2.0).
Thanks for the workaround @charlieschwabacher
It appears that DataMapper.auto_upgrade! is attempting to re-create the columns of a base STI model, for every descendent of that base model. This results in duplicate column errors when calling auto_upgrade!. This error does not occurr when running DataMapper.auto_migrate!.
Gemfile
test.rb
Created by Postmodern - 2010-05-24 01:54:27 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/1289