Comments (17)
Paul, would you mind looking into this? If it is an issue, please mark it as confirmed. Also, if you do decide to take it on, please mark it as accepted so we know you’re working on it.
by Dan Kubb (dkubb)
from dm-migrations.
Yup, confirmed.
To fix this, all that needs done is adding a TableModifier class to http://github.com/sam/dm-more/tree/master/dm-migrations/lib/sql/mysql.rb and overriding the ’rename_column’ method, as found here: http://github.com/sam/dm-more/tree/master/dm-migrations/lib/sql/table_modifier.rb#L33
by Paul Sadauskas (Rando)
from dm-migrations.
I have written what I think is a patch for this problem.
There were no specs for the MySQL adapter in dm-migrations so I created the spec file. I also mimicked those from sqlite3 for the core functionality.
I then added the class TableModifier with the method rename_column. The method extracts the existing column from the table columns, updates it’s name, and then generates the correct ALTER TABLE statement.
I hope it is ok that both of these are in one patch, but the later relies on the former!
This is my first patch, so sorry if it’s all wrong, but let me know what any problems are and I’ll try to fix them.
Emma
by Emma Persky
from dm-migrations.
yikes, i spoke to soon. ignore that patch...
by Emma Persky
from dm-migrations.
When I attempted to fix this bug I found numerous problems with dm-migrations. I think dm-migrations should be queued up for a rewrite before DM 1.0 is released, since it’s one of the weakest official DM libs.
Going to put this on hold while we plan out how to approach this.
by Dan Kubb (dkubb)
from dm-migrations.
I should add that we ran out of time to rewrite dm-migrations before the 1.0 launch. I am going to see what I can do about getting this in before the 1.1 release.
by Dan Kubb (dkubb)
from dm-migrations.
Kick! Any news on this?
from dm-migrations.
@stephankaag I added it to 1.3.0 milestone
from dm-migrations.
I might attempt to shoehorn in this fix in the mean time. We shouldn't leave this broken while waiting for DM 2.0.
from dm-migrations.
There's pull request from me about this issue, but hasn't been migrated yet
from dm-migrations.
@rindek are there any tests covering this new behaviour? If so, could you add them? I'll merge in this change if it has tests.
A rewrite is going to happen, but later, and if people are willing to fix things w/tests then I think we should accept them.
from dm-migrations.
I was going to work on writing tests for @rindek's patches, but it appear that master cannot even pass mysql auto-migration specs.
DataObjects::SQLError in 'DataMapper::Migrations with default adapter#auto_migrate NumericString property before(:all)'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRIMARY KEY, `number` VARCHAR(50) DEFAULT '0', PRIMARY KEY(`id`)) ENGINE = MyISA' at line 1
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/adapters/dm-do-adapter.rb:100:in `execute_non_query'
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/adapters/dm-do-adapter.rb:100:in `block (2 levels) in create_model_storage'
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/adapters/dm-do-adapter.rb:98:in `each'
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/adapters/dm-do-adapter.rb:98:in `block in create_model_storage'
/home/hal/.rvm/gems/ruby-1.9.3-p0/bundler/gems/dm-do-adapter-d295d77f3e4b/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/adapters/dm-do-adapter.rb:93:in `create_model_storage'
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/auto_migration.rb:81:in `create_model_storage'
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/auto_migration.rb:177:in `auto_migrate_up!'
/vault/1/code/forks/dm/dm-migrations/lib/dm-migrations/auto_migration.rb:132:in `auto_migrate!'
spec/integration/auto_migration_spec.rb:300:in `block (6 levels) in <top (required)>'
spec/integration/auto_migration_spec.rb:8:in `capture_log'
spec/integration/auto_migration_spec.rb:300:in `block (5 levels) in <top (required)>'
747 examples, 158 failures, 4 pending
I created the datamapper
user and datamapper_default_tests
/ datamapper_alternate_tests
databases.
from dm-migrations.
I ended up improving on @rindek's rename_column_type_statement
for mysql (wasn't including DEFAULT
or NOT NULL
modifiers) and even added a basic spec for it:
https://github.com/postmodern/dm-migrations/commits/mysql_rename_column
Can we finally merge this?
from dm-migrations.
@postmodern are you saying that the dm-migrations master's specs don't pass? They appear to be passing in CI: http://ci.datamapper.org/job/dm-migrations/
from dm-migrations.
@dkubb maybe I'm forgetting something, or more likely it's an environment specific issue. Half of the auto-migration specs consistently fail on my Fedora 16 workstation running mysql 5.5.19. However, I was able to manually run the migration specs for this particular bug.
from dm-migrations.
@postmodern thanks for this. I was going to write those tests but I totally forgot about it :(
from dm-migrations.
@rindek dm-migrations is kind of a wasteland, none of the existing specs caught this obvious syntax error. I also noticed that the MySQL specific change_column
method wasn't speced. The sooner we can fix this, the better. :)
from dm-migrations.
Related Issues (20)
- dm-oracle-adapter: auto_upgrade does not work on Oracle when adding a required property HOT 5
- dm-migrations contains hardcoded SQL HOT 1
- auto_upgrade doesn't work with property type change HOT 3
- AutoUpgrades fail on STI models. HOT 7
- change_column produces bad SQL on Postgres HOT 5
- Migrating from one dbms backend to another HOT 1
- NoMethodError: undefined method `variable_value' (JRuby 1.6.3 and dm-mysql-adapter)
- auto_upgrade! within a Postgres migration creates bad create table sql HOT 1
- rename_column sql syntax is incorrect HOT 4
- Explicit migrations cannot lookup DataMapper Property constants with dm-rails and Ruby 1.8.7
- auto-migration specs fail with syntax error on mysql 14.14
- Alter column length on migration for PostgreSQL db fails due to incorrect syntax HOT 1
- Better fallback for defauls on autoupgrade opration?
- doesn't migrate repositories which are not :default HOT 2
- Support creation of composite primary keys
- Issues with db:setup and db:migrate HOT 3
- Can't convert nil into Hash when using a type from dm-types
- dm-migrations needs a new maintainer. HOT 1
- SQLite and required field without default adds 'DEFAULT NULL'
- Running tests on migrations as given in example fails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dm-migrations.