wood burning stoves*
The moose likes Other Languages and the fly likes update value through migrate file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Languages » Other Languages
Bookmark "update value through migrate file" Watch "update value through migrate file" New topic
Author

update value through migrate file

Suganya Ram
Greenhorn

Joined: Jun 12, 2008
Posts: 18
I want to update a bytefield value to a table . So for this i wrote a migrate file. but i dont the command to update the value. help me to write migration file to update the bytefield value to the table.


SuganyaRam
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Greetings. Do you mind sharing with us what technologies you are using and possibly posting a little of your code? At this point I don't even know if by "table" you mean a database table or a collection type of some particular language (this is the forum for alternative languages that you posted in).

Many people, myself included, would be glad to help you figure out your problems but you will need to Show Some Effort to explain the problem more thoroughly so that we can understand what you're working with.


A good workman is known by his tools.
Suganya Ram
Greenhorn

Joined: Jun 12, 2008
Posts: 18
I am using ruby on rails with Mysql as backend. I have a table named "users" with multiple fields. I have a fieldname "Override" and it acts as a bytefield. This "Override" field itself includes sub fields like "direct_override", "indirect_override" and so on and we used to store those values in bytefield.
Now i want to update a value to "indirect_override"which is the subfield of "override" field.
For this i want to write a migrate file in the path(trunk/db/migrate/012_new_file.rb).
I used the exute command for this as
execute"update users set indirect_override=8 where ....."
But it's showing error as "users.indirect_override doesn't exists"
How to solve this issue?
Suganya Ram
Greenhorn

Joined: Jun 12, 2008
Posts: 18
Is there any possibility to do so? I wrote a rake file in (lib/tasks/name.rake). it's working. but i need to write as a migrate file(trunk/db/migrate/....).
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
It seems to me that if all you want to do is change a field in the db it would be easier to use script/console. Migrations is better suited to setting up and changing the structure of the table along with setting the properties of the table columns.


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I'm still not sure what a bytefield is. Do you mean bit-field?

Here's a nice Rails-DB mapping cheatsheet. However, I don't see bit-field on the list... or bytefield for that matter.

Going off the path of normal mapping types isn't recommended because you'll be locking into a particular DB vendor. This other cheatsheet shows that you can put SQL directly in migration files (see the "Executing SQL directly" section), so it appears that what you're looking to accomplish can be done. Good luck!

FYI to others: the term "migration" in Rails has a different meaning than what most of us expect. To most of us, a migration is a port over of data from one DB to another (or between tables in the same DB). In Rails, "migration" is a way to use Ruby to update schemas when requirements change, a new version of the app creates additions, or there is some other need for altering the DB. Here is a nice little description how it works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update value through migrate file