Hi All, I''ve just finished extracting and saving all the info from my database and I need to copy the contents from "description" field to the newly created fields "meta_description" and "meta_keywords" How do you do this? I don''t want my existing data to get messed up. Any help would be appreciated. Thanks. I''ve successfully added the new meta description and keywords using migrations <code><pre> $ ./script/generate migration remove_description_and_keyword_from_content description:text keyword:text exists db/migrate create db/migrate/003_remove_description_and_keyword_from_content.rb </pre></code> *and here''s my database schema* <pre><code> ActiveRecord::Schema.define(:version => 2) do create_table "contents", :force => true do |t| t.string "title" t.string "description" #<--- How do you copy all data from this field t.text "detail" t.string "image" t.string "product" t.string "link" t.float "price" t.string "other" t.string "target" t.float "cost" t.string "shipping" t.datetime "created_at" t.datetime "updated_at" t.text "meta_description" #<--- to here and t.text "meta_keyword" #<--- Here end end </code></pre> - Erwin Quita -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Garey
2008-Mar-14 07:19 UTC
Re: How do you copy a fileds content to newly added field?
update table contents set meta_description = description, meta_keyword = description; back up your database first before doing any of this stuff of course. Mike On 3/14/08, Erwin Quita <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi All, > > I''ve just finished extracting and saving all the info from my database > and I need to copy the contents from "description" field to the newly > created fields "meta_description" and "meta_keywords" How do you do > this? I don''t want my existing data to get messed up. Any help would be > appreciated. Thanks. > > I''ve successfully added the new meta description and keywords using > migrations > <code><pre> > $ ./script/generate migration > remove_description_and_keyword_from_content description:text > keyword:text > exists db/migrate > create > db/migrate/003_remove_description_and_keyword_from_content.rb > </pre></code> > > *and here''s my database schema* > <pre><code> > ActiveRecord::Schema.define(:version => 2) do > > create_table "contents", :force => true do |t| > t.string "title" > t.string "description" #<--- How do you copy all data from this > field > t.text "detail" > t.string "image" > t.string "product" > t.string "link" > t.float "price" > t.string "other" > t.string "target" > t.float "cost" > t.string "shipping" > t.datetime "created_at" > t.datetime "updated_at" > t.text "meta_description" #<--- to here and > t.text "meta_keyword" #<--- Here > end > > end > </code></pre> > > - Erwin Quita > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Erwin Quita
2008-Mar-14 08:15 UTC
Re: How do you copy a fileds content to newly added field?
Hi Mike is this a rake task? I tried it and it gave me an error rake aborted! Don''t know how to build task ''update'' update table contents set meta_description = description, meta_keyword = description; Thanks for the quick reply -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Erwin Quita
2008-Mar-14 08:23 UTC
Re: How do you copy a fileds content to newly added field?
Mike, I''m sorry forgot that it''s a mysql statement, I tried it on mysql but gave me this error mysql> UPDATE table contents SET meta_description = description, meta_keyword = description; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''table contents SET meta_description = description, meta_keyword = description'' at line 1 How do you properly construct it. Thanks again. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Bush
2008-Mar-14 08:30 UTC
Re: How do you copy a fileds content to newly added field?
Erwin Quita wrote:> mysql> UPDATE table contents SET meta_description = description, > meta_keyword = description; > ERROR 1064 (42000): You have an error in your SQL syntax; check theJust: UPDATE contents SET ... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Erwin Quita
2008-Mar-14 08:42 UTC
Re: How do you copy a fileds content to newly added field?
Mark Thank you so much! Indeed a success! Thanks again! mysql> update contents set meta_description = description, meta_keyword = description; Query OK, 989 rows affected (0.29 sec) Rows matched: 989 Changed: 989 Warnings: 0 Mark Bush wrote:> Erwin Quita wrote: >> mysql> UPDATE table contents SET meta_description = description, >> meta_keyword = description; >> ERROR 1064 (42000): You have an error in your SQL syntax; check the > > Just: UPDATE contents SET ...-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Garey
2008-Mar-14 18:22 UTC
Re: How do you copy a fileds content to newly added field?
oops.. thanks Mark, it was late when I posted that! Mike On 3/14/08, Erwin Quita <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Mark > > Thank you so much! Indeed a success! Thanks again! > > mysql> update contents set meta_description = description, meta_keyword > = description; > Query OK, 989 rows affected (0.29 sec) > Rows matched: 989 Changed: 989 Warnings: 0 > > > Mark Bush wrote: > > Erwin Quita wrote: > >> mysql> UPDATE table contents SET meta_description = description, > >> meta_keyword = description; > >> ERROR 1064 (42000): You have an error in your SQL syntax; check the > > > > Just: UPDATE contents SET ... > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---