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

**URL:** <https://discuss.rubyonrails.org/t/losing-decimal-scale-from-sqlite3-to-mysql-going-from-development-to-staging/50170>\
**Category:** rubyonrails-talk\
**Created:** [March 16, 2010, 3:35pm UTC](https://discuss.rubyonrails.org/t/losing-decimal-scale-from-sqlite3-to-mysql-going-from-development-to-staging/50170 "2010-03-16T15:35:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Owain](https://avatars.discourse-cdn.com/v4/letter/o/fbc32d/32.png) [@Owain](https://discuss.rubyonrails.org/u/Owain)\
**Post date:** [March 16, 2010, 3:35pm UTC](https://discuss.rubyonrails.org/t/losing-decimal-scale-from-sqlite3-to-mysql-going-from-development-to-staging/50170/1 "2010-03-16T15:35:52Z")

</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 &nbsp;&nbsp;def self.up &nbsp;&nbsp;&nbsp;&nbsp;create\_table :orders do |t| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.integer :quote\_id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.integer :policyholder\_id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :ip\_address &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :account\_name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :payment\_type &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :last\_digits &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.decimal :amount, :precision =\> 8, :scale =\> 2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :cc\_txncode &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :cc\_securitykey &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :cc\_card\_type &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.timestamps &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

&nbsp;&nbsp;def self.down &nbsp;&nbsp;&nbsp;&nbsp;drop\_table :orders &nbsp;&nbsp;end end

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

> .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` ( &nbsp;&nbsp;`id` int(11) NOT NULL auto\_increment, &nbsp;&nbsp;`quote_id` int(11) default NULL, &nbsp;&nbsp;`policyholder_id` int(11) default NULL, &nbsp;&nbsp;`ip_address` varchar(255) collate utf8\_unicode\_ci default NULL, &nbsp;&nbsp;`account_name` varchar(255) collate utf8\_unicode\_ci default NULL, &nbsp;&nbsp;`payment_type` varchar(255) collate utf8\_unicode\_ci default NULL, &nbsp;&nbsp;`last_digits` varchar(255) collate utf8\_unicode\_ci default NULL &nbsp;&nbsp;`amount` decimal(10,0) default NULL, &nbsp;&nbsp;`cc_txncode` varchar(255) collate utf8\_unicode\_ci default NULL, &nbsp;&nbsp;`cc_securitykey` varchar(255) collate utf8\_unicode\_ci default NULL, &nbsp;&nbsp;`cc_card_type` varchar(255) collate utf8\_unicode\_ci default NULL, &nbsp;&nbsp;`created_at` datetime default NULL, &nbsp;&nbsp;`updated_at` datetime default NULL, &nbsp;&nbsp;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:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.decimal :annual\_price, :precision =\> 8, :scale =\> 2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.decimal :monthly\_price, :precision =\> 8, :scale =\> 2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :status &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.date :policy\_purchased\_on &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.decimal :excess, :precision =\> 8, :scale =\> 2

&nbsp;&nbsp;`annual_price` decimal(8,2) default NULL, &nbsp;&nbsp;`monthly_price` decimal(8,2) default NULL, &nbsp;&nbsp;`status` varchar(255) collate utf8\_unicode\_ci default NULL, &nbsp;&nbsp;`policy_purchased_on` date default NULL, &nbsp;&nbsp;`excess` decimal(10,0) default NULL,

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

Thanks,

O.
