Git Product home page Git Product logo

Comments (7)

solnic avatar solnic commented on July 18, 2024
 ~ (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)>&rsquo;
    from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `call&rsquo;
    from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `block in run_examples&rsquo;
    from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `each&rsquo;
    from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/options.rb:146:in `run_examples&rsquo;
    from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run&rsquo;
    from /usr/lib/ruby/gems/1.9.1/gems/rspec-1.3.0/bin/spec:5:in `<main>&rsquo;
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

from dm-migrations.

solnic avatar solnic commented on July 18, 2024

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:

  • The path to the file in the example is not writable on most systems, so SQLite defaults to using an in-memory database. If you specify "sqlite::memory:" you will see the same bug.
  • If you change the path to a writable location, a file will be created, and the bug will not occur.
  • A CREATE TABLE statement is issued, creating the table, then a PRAGMA table_info query runs immediately after and returns no records. That means that the columns created are not seen by the system.
  • Performing an ALTER TABLE statement and adding in a column that already exists will cause an explosion. So even though SQLite does not report any columns in the table, it won’t allow you to add them.
  • At first I thought it was a problem with pooling, like maybe one connection would create the table, and the other connection wouldn’t see it, because of how in-memory DBs are not sharable across connections. However, I checked the object_id of the Connection objects both when the CREATE TABLE and PRAGMA queries were executed, and they were the same.

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)

from dm-migrations.

solnic avatar solnic commented on July 18, 2024

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&rsquo;: 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&rsquo;
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&rsquo;
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&rsquo;
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&rsquo;
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&rsquo;
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&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:143:in `auto_upgrade!&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:145:in `auto_upgrade!&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:45:in `send&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:45:in `repository_execute&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-core-1.0.0.rc3/lib/dm-core/model/descendant_set.rb:33:in `each&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-core-1.0.0.rc3/lib/dm-core/model/descendant_set.rb:33:in `each&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:44:in `repository_execute&rsquo;
from /var/ruby/1.8/gem_home/gems/dm-migrations-1.0.0.rc3/lib/dm-migrations/auto_migration.rb:27:in `auto_upgrade!&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:190:in `upgrade&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:189:in `each_key&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:189:in `upgrade&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/database/database.rb:215:in `setup&rsquo;
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&rsquo;
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require&rsquo;
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&rsquo;
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/console.rb:171:in `start&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/console.rb:170:in `instance_eval&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/console.rb:170:in `start&rsquo;
from /var/ruby/1.8/gem_home/gems/ronin-0.4.0/lib/ronin/ui/command_line/commands/console.rb:60:in `execute&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/task.rb:33:in `send&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/task.rb:33:in `run&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/invocation.rb:109:in `invoke&rsquo;
from /usr/ruby/1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `map&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/core_ext/ordered_hash.rb:73:in `each&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/invocation.rb:118:in `map&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/invocation.rb:118:in `invoke&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/group.rb:36:in `start&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/base.rb:378:in `start&rsquo;
from /var/ruby/1.8/gem_home/gems/thor-0.13.6/lib/thor/group.rb:29:in `start&rsquo;
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&rsquo;
from /var/ruby/1.8/gem_home/bin/ronin-web:19

Note: Ronin by default uses the sqlite3 "~/.ronin/database.sqlite3".

by Postmodern

from dm-migrations.

solnic avatar solnic commented on July 18, 2024

I am able to reproduce this bug on JRuby 1.5.1:

$ DEBUG=true rake spec
(in /vault/1/code/ronin/ronin)
You don&rsquo;t have tzinfo installed in your application. Please add it to your Gemfile and run bundle install
You don&rsquo;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&rsquo;: 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&rsquo;
    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&rsquo;
    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&rsquo;
    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&rsquo;
    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!&rsquo;
    from /vault/1/code/ronin/ronin/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!&rsquo;
    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!&rsquo;
    from /vault/1/code/ronin/ronin/lib/ronin/model/lazy_upgrade.rb:63:in `auto_upgrade!&rsquo;
     ... 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&rsquo;
    from /home/hal/.rvm/gems/jruby-1.5.1/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run&rsquo;
    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

from dm-migrations.

daz avatar daz commented on July 18, 2024

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.

from dm-migrations.

charlieschwabacher avatar charlieschwabacher commented on July 18, 2024

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!

from dm-migrations.

gilbert avatar gilbert commented on July 18, 2024

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

from dm-migrations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.