Created
November 27, 2010 00:07
-
-
Save matthuhiggins/717379 to your computer and use it in GitHub Desktop.
mysql_love_2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create_table :foo, :id => false do |t| | |
| t.column :id, :manual_pk | |
| t.column :bytes, :big_integer | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ActiveRecord | |
| module ConnectionAdapters | |
| class MysqlAdapter < AbstractAdapter | |
| alias :original_native_database_types :native_database_types | |
| def native_database_types | |
| original_native_database_types.update( | |
| :big_integer => { :name => "bigint", :limit => 21 }, | |
| :manual_pk => "int(11) NOT NULL PRIMARY KEY") | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ActiveRecord::ConnectionAdapters::MysqlAdapter.register :big_integer, { :name => "bigint", :limit => 21 } | |
| ActiveRecord::ConnectionAdapters::MysqlAdapter.register :manual_pk, "int(11) NOT NULL PRIMARY KEY" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create_table :foo, :id => false do |t| | |
| t.manual_pk :id | |
| t.big_integer :bytes | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ActiveRecord | |
| module ConnectionAdapters | |
| class TableDefinition | |
| %w(big_integer manual_pk).each do |column_type| | |
| class_eval <<-EOV | |
| def #{column_type}(*args) | |
| options = args.extract_options! | |
| column_names = args | |
| column_names.each { |name| column(name, '#{column_type}', options) } | |
| end | |
| EOV | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment