i use rails transaction like these:
Account.transaction do
first.do_something
end
in first.do_something, i set a error, it should be rollback after these
code excuted
here is a param in my log:
e[4;36;1mSQL (0.000000)e[0m e[0;1mROLLBACKe[0m
i find rails do rollback operation, but in my database ,the data is not
rollback,
anybody may help?
I think this is the deal: the default table type in MySQL is MyISAM,
which is generally good for speed with web apps and such, but it does
not support transactions. So MySQL will take the rollback command, but
won’t actually roll anything back.
To enable transactions, you must be working with an InnoDB table, which
is the more hardcore table type in MySQL. It requires more resources to
read and write these tables, but according to databasejournal.com, you
get these benefits:
InnoDB Features
* ACID-compliant transactions.
* Full referential integrity
* Row-level locking
* Tables are stored in a tablespace (unlike MyISAM tables where each
table is a file)
Jason
I try your suggestion ,set my table type as InnoDB, but still not
rollback.
there is something like config i miss?