Mysql Bigint plugin

Plugin details

This plugin changes the way ActiveRecord interacts with MySQL using the limit parameter and integer columns. While most databases seem to automatically adjust the size (in bytes) of an integer column to fit the data stored in it. In these databases the limit parameter sets an upper bound on the size of the integer column. MySQL uses different integer types to reflect the maximum value _expected_ in the column.

Websitehttp://www.northpub.com/pages/mysql_bigint Repositoryhttp://svn.northpub.com/plugins/mysql_bigint Author Steven J Hammond Tags mysql, bigint LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.northpub.com/plugins/mysql_bigint

Integer Columns
===============

There isn't any additional syntax needed to use this plugin on integer columns, in MySQL. Instead the :limit parameter now specifics the number of bytes expected and smallest MySQL type capable of suppporting that many bytes will be used, up to a maximum of 8 bytes. For example...

    t.column "col1", :integer, :limit => 1, :null=> false # uses MySQL tinyint
    t.column "col2", :integer, :limit => 3, :null=> false # uses MySQL mediumint
    t.column "col3", :integer, :limit => 4, :null=> false # uses MySQL int
    t.column "col4", :integer, :limit => 5, :null=> false # uses MySQL bigint	
    t.column "col5", :integer, :limit => 8, :null=> false # uses MySQL bigint
    t.column "col6", :integer, :limit => 12, :null=> false # uses MySQL bigint which still holds 8-bytes	


Primary Keys
=============

You can also use bigint's as primary keys with this plugin. This does require a bit of syntax. Add the :use_big_id option to the create_table statement as shown below.

    create_table :random_numbers, :use_big_id => true, :force => true do |t|

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago