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.
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.
Joined: Jun 12, 2008
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?
Joined: Jun 12, 2008
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/....).
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
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.