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

**URL:** <https://www.ruby-forum.com/t/losing-decimal-scale-from-sqlite3-to-mysql-going-from-development-to-staging/185238>\
**Category:** Rails\
**Created:** [March 16, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/losing-decimal-scale-from-sqlite3-to-mysql-going-from-development-to-staging/185238 "2010-03-16T16:39:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Owain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/fbc32d/32.png) [@Owain](https://www.ruby-forum.com/u/Owain)\
**Post date:** [March 16, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/losing-decimal-scale-from-sqlite3-to-mysql-going-from-development-to-staging/185238/1 "2010-03-16T16:39:50Z")

</div>

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.
