• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

update value through migrate file

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Suganya Ram
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/....).
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic