jruby/activerecord-jdbc-adapter — pull request #380 by jamuc (2013-04-23 16:43:00+00:00)
Title: H2 auto increment

# Background

I've written a Rails application, which allows the user to switch from an embedded H2 database to a MySQL database at runtime.

When switching, the Rails application migrates the db schema and user data from the H2 database to the MySQL database.

This fails.

Reason: A mismatch in the auto increment values of the primary keys between H2 and MySQL

# Further research

When inserting data into the H2 database directly (without using ActiveRecord), H2 performs the same auto increment as MySQL and SQlite (starts with ID=1)

When inserting data into the H2 database via ActiveRecord, auto incrementation starts with an ID=0.

I double checked this against the official H2 documentation: http://h2database.com/html/grammar.html#column_definition

It seems to me that the H2/adapter was copied and pasted from the HSQLDB/adapter.

# Conclusion

When I changed the adapter.rb, so that it doesn't overwrite the default behaviour of the H2 database, my problem disappeared.

Hence, this pull request.

To recap:

* H2/adapter.rb seems to be copy/pasted from HSQLDB/adapter
* H2/adapter.rb used to override the default behaviour of the H2 database
* I changed the H2/adapter.rb to implement the default behaviour of the H2/database (Documentation: http://h2database.com/html/grammar.html#column_definition)

Of course, I'm not a database specialist and any feedback on this would be greatly appreciated.

Thanks,
Jason