Losing Decimal scale from sqlite3 to mysql going from development to staging

I have been performing some testing between my development and staging
environments. I had noticed that the order.amount has been truncated.

All works fine in sqlite3 in development.

Here is the output: Amount is meant to be decimal (8,2) to support
pounds and pence (or dollars and cents).

class CreateOrders < ActiveRecord::Migration
def self.up
create_table :orders do |t|
t.integer :quote_id
t.integer :policyholder_id
t.string :ip_address
t.string :account_name
t.string :payment_type
t.string :last_digits
t.decimal :amount, :precision => 8, :scale => 2
t.string :cc_txncode
t.string :cc_securitykey
t.string :cc_card_type
t.timestamps
end
end

def self.down
drop_table :orders
end
end

If I check the table definition in sqllite (v 3.6.12) it looks
correct.

sqlite> .schema orders
CREATE TABLE “orders” (“id” INTEGER PRIMARY KEY AUTOINCREMENT NOT
NULL, “quote_id” integer, “policyholder_id” integer, “ip_address”
varchar(255), “account_name” varchar(255), “payment_type”
varchar(255), “last_digits” varchar(255), “amount” decimal(8,2),
“cc_txncode” varchar(255), “cc_securitykey” varchar(255),
“cc_card_type” varchar(255), “created_at” datetime, “updated_at”
datetime);

but the decimal amount gets changed to decimal(10,0) on the staging
mysql (Ver 5.0.67)

CREATE TABLE orders (
id int(11) NOT NULL auto_increment,
quote_id int(11) default NULL,
policyholder_id int(11) default NULL,
ip_address varchar(255) collate utf8_unicode_ci default NULL,
account_name varchar(255) collate utf8_unicode_ci default NULL,
payment_type varchar(255) collate utf8_unicode_ci default NULL,
last_digits varchar(255) collate utf8_unicode_ci default NULL
amount decimal(10,0) default NULL,
cc_txncode varchar(255) collate utf8_unicode_ci default NULL,
cc_securitykey varchar(255) collate utf8_unicode_ci default NULL,
cc_card_type varchar(255) collate utf8_unicode_ci default NULL,
created_at datetime default NULL,
updated_at datetime default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
COLLATE=utf8_unicode_ci;

Running on rails 2.3.5

Some of my decimal declarations are ok, even on the same table, some
work and some do not:

  t.decimal :annual_price, :precision => 8, :scale => 2
  t.decimal :monthly_price, :precision => 8, :scale => 2
  t.string :status
  t.date :policy_purchased_on
  t.decimal :excess, :precision => 8, :scale => 2

annual_price decimal(8,2) default NULL,
monthly_price decimal(8,2) default NULL,
status varchar(255) collate utf8_unicode_ci default NULL,
policy_purchased_on date default NULL,
excess decimal(10,0) default NULL,

Any ideas as to what I am missing? Is it Rake?

Thanks,

O.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs