I am running: rake db:migrate, and I am getting this error. I am some what of a beginner, and I can''t seem to understand migrations, because I can''t fix this problem :( == 2 CreateWorks: migrating ==================================================-- create_table(:works) rake aborted! Mysql::Error: #42S01Table ''works'' already exists: CREATE TABLE `works` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL) ENGINE=InnoDB (See full trace by running task with --trace) The Trace is below: ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate == 2 CreateWorks: migrating ==================================================-- create_table(:works) rake aborted! Mysql::Error: #42S01Table ''works'' already exists: CREATE TABLE `works` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL) ENGINE=InnoDB /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract_adapter.rb:150:in `log'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/mysql_adapter.rb:281:in `execute'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract/schema_statements.rb:104:in `create_table'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/mysql_adapter.rb:416:in `create_table'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:285:in `send'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:285:in `method_missing'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:265:in `say_with_time'' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ 1.8/benchmark.rb:293:in `measure'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:265:in `say_with_time'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:281:in `method_missing'' ./db/migrate//002_create_works.rb:3:in `up_without_benchmarks'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:219:in `send'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:219:in `migrate'' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ 1.8/benchmark.rb:293:in `measure'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:219:in `migrate'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:348:in `migrate'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:339:in `each'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:339:in `migrate'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:307:in `up'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ migration.rb:298:in `migrate'' /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:85 /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'' /Library/Ruby/Gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/bin/rake:19:in `load'' /usr/bin/rake:19 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Somehow the table ''works'' has already been created in that database. Log into mysql from the command line or however else you interact directly with the database and drop that table manually (drop table works;). Then you can recreate it using your migration. On Fri, May 23, 2008 at 8:34 PM, GarrettB <mail-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote:> > I am running: rake db:migrate, and I am getting this error. I am some > what of a beginner, and I can''t seem to understand migrations, because > I can''t fix this problem :( > > == 2 CreateWorks: migrating > ==================================================> -- create_table(:works) > rake aborted! > Mysql::Error: #42S01Table ''works'' already exists:--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Won''t that cause all my data to be lost though? So do you suggest maybe me exporting my whole database, then inserting it after doing a db:migrate? On May 23, 2008, at 8:46 PM, Cynthia Kiser wrote:> > Somehow the table ''works'' has already been created in that database. > Log into mysql from the command line or however else you interact > directly with the database and drop that table manually (drop table > works;). Then you can recreate it using your migration. > > On Fri, May 23, 2008 at 8:34 PM, GarrettB <mail-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote: >> >> I am running: rake db:migrate, and I am getting this error. I am some >> what of a beginner, and I can''t seem to understand migrations, >> because >> I can''t fix this problem :( >> >> == 2 CreateWorks: migrating >> ==================================================>> -- create_table(:works) >> rake aborted! >> Mysql::Error: #42S01Table ''works'' already exists: > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Fri, May 23, 2008 at 8:55 PM, Garrett Bjerkhoel <mail-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote:> > Won''t that cause all my data to be lost though? > > So do you suggest maybe me exporting my whole database, then inserting > it after doing a db:migrate?If you already have the table works in your database, why did you create a migration file to recreate it? I had assumed that you had a table ''works'' as a side affect of an error in a migration. If you already have ''works'' and you want what you have, then don''t have a migration that creates the table. Was the migration created when you ran ''script/generate scaffold''? If so, you want the code that was created but NOT the migration. For now, just delete the migration file. In future, I am pretty sure there is a flag you can pass to script/generate to tell it not to create the migration file. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Are migrations really that important? My migrations obviously are really messed up, yet my application works fine! Will it effect me when I try to deploy my app, will the effect me then? Thanks!! On May 23, 2008, at 9:01 PM, Cynthia Kiser wrote:> > On Fri, May 23, 2008 at 8:55 PM, Garrett Bjerkhoel > <mail-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote: >> >> Won''t that cause all my data to be lost though? >> >> So do you suggest maybe me exporting my whole database, then >> inserting >> it after doing a db:migrate? > > If you already have the table works in your database, why did you > create a migration file to recreate it? I had assumed that you had a > table ''works'' as a side affect of an error in a migration. If you > already have ''works'' and you want what you have, then don''t have a > migration that creates the table. Was the migration created when you > ran ''script/generate scaffold''? If so, you want the code that was > created but NOT the migration. For now, just delete the migration > file. In future, I am pretty sure there is a flag you can pass to > script/generate to tell it not to create the migration file. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Fri, May 23, 2008 at 9:17 PM, Garrett Bjerkhoel <mail-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote:> Are migrations really that important? My migrations obviously are > really messed up, yet my application works fine! Will it effect me > when I try to deploy my app, will the effect me then?Migrations are an easy way to recreate a database that works with your application. If you have another way to create a valid database (for example migrating the data using mysqldump), then migrations are not important. However, I would, if I were you, spend some time getting your migrations straightened out. One way to do that without disrupting your working development database is to run them forwards and backwards in a disposable database (for example your test database) until they run without error and reproduce the structure you currently have. Hint: "rake db:schema:dump" on your development database and then on the play database. When the two schema.rb files match, your migrations will reproduce the structure of your dev database. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I would like to echo Cynthia''s comments. Migrations are important because they make your life a lot easier when it comes to creating and updating your tables. If you''ve got an existing database, look at the following page: http://www.ruby-forum.com/topic/134848 Definitely take the time to pick up migrations. It''s simple once you get the hang of it. It will also make your application portable... meaning that if you decide to switch databases, you won''t have to recreate your database. ActiveRecord will do that for you. On May 23, 9:27 pm, "Cynthia Kiser" <cynthia.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, May 23, 2008 at 9:17 PM, Garrett Bjerkhoel <m...-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote: > > Are migrations really that important? My migrations obviously are > > really messed up, yet my application works fine! Will it effect me > > when I try to deploy my app, will the effect me then? > > Migrations are an easy way to recreate a database that works with your > application. If you have another way to create a valid database (for > example migrating the data using mysqldump), then migrations are not > important. > > However, I would, if I were you, spend some time getting your > migrations straightened out. One way to do that without disrupting > your working development database is to run them forwards and > backwards in a disposable database (for example your test database) > until they run without error and reproduce the structure you currently > have. Hint: "rake db:schema:dump" on your development database and > then on the play database. When the two schema.rb files match, your > migrations will reproduce the structure of your dev database.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
That forum topic fixed it! Thanks a bunch! On May 23, 2008, at 9:41 PM, mel ram wrote:> > I would like to echo Cynthia''s comments. Migrations are important > because they make your life a lot easier when it comes to creating and > updating your tables. > > If you''ve got an existing database, look at the following page: > http://www.ruby-forum.com/topic/134848 > > Definitely take the time to pick up migrations. It''s simple once you > get the hang of it. It will also make your application portable... > meaning that if you decide to switch databases, you won''t have to > recreate your database. ActiveRecord will do that for you. > > On May 23, 9:27 pm, "Cynthia Kiser" <cynthia.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On Fri, May 23, 2008 at 9:17 PM, Garrett Bjerkhoel >> <m...-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote: >>> Are migrations really that important? My migrations obviously are >>> really messed up, yet my application works fine! Will it effect me >>> when I try to deploy my app, will the effect me then? >> >> Migrations are an easy way to recreate a database that works with >> your >> application. If you have another way to create a valid database (for >> example migrating the data using mysqldump), then migrations are not >> important. >> >> However, I would, if I were you, spend some time getting your >> migrations straightened out. One way to do that without disrupting >> your working development database is to run them forwards and >> backwards in a disposable database (for example your test database) >> until they run without error and reproduce the structure you >> currently >> have. Hint: "rake db:schema:dump" on your development database and >> then on the play database. When the two schema.rb files match, your >> migrations will reproduce the structure of your dev database. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No problemo! On May 24, 11:31 am, Garrett Bjerkhoel <m...-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote:> That forum topic fixed it! Thanks a bunch! > > On May 23, 2008, at 9:41 PM, mel ram wrote: > > > > > I would like to echo Cynthia''s comments. Migrations are important > > because they make your life a lot easier when it comes to creating and > > updating your tables. > > > If you''ve got an existing database, look at the following page: > >http://www.ruby-forum.com/topic/134848 > > > Definitely take the time to pick up migrations. It''s simple once you > > get the hang of it. It will also make your application portable... > > meaning that if you decide to switch databases, you won''t have to > > recreate your database. ActiveRecord will do that for you. > > > On May 23, 9:27 pm, "Cynthia Kiser" <cynthia.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On Fri, May 23, 2008 at 9:17 PM, Garrett Bjerkhoel > >> <m...-L7cFN5YTvg2akBO8gow8eQ@public.gmane.org> wrote: > >>> Are migrations really that important? My migrations obviously are > >>> really messed up, yet my application works fine! Will it effect me > >>> when I try to deploy my app, will the effect me then? > > >> Migrations are an easy way to recreate a database that works with > >> your > >> application. If you have another way to create a valid database (for > >> example migrating the data using mysqldump), then migrations are not > >> important. > > >> However, I would, if I were you, spend some time getting your > >> migrations straightened out. One way to do that without disrupting > >> your working development database is to run them forwards and > >> backwards in a disposable database (for example your test database) > >> until they run without error and reproduce the structure you > >> currently > >> have. Hint: "rake db:schema:dump" on your development database and > >> then on the play database. When the two schema.rb files match, your > >> migrations will reproduce the structure of your dev database.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---