Skip to content

Instantly share code, notes, and snippets.

@3h5a9
Created May 26, 2016 12:17
Show Gist options
  • Save 3h5a9/d34afcc73b8e61e27e5d1a238562655c to your computer and use it in GitHub Desktop.
Save 3h5a9/d34afcc73b8e61e27e5d1a238562655c to your computer and use it in GitHub Desktop.
creating table shows errors in mysql
smehsan@smehsan:~/one$ rake db:migrate
== 20160526120711 CreateArticles: migrating ===================================
-- create_table(:articles)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Table 'articles' already exists: CREATE TABLE `articles` (`id` int(11) auto_increment PRIMARY KEY, `title` varchar(255)) ENGINE=InnoDB
/home/smehsan/one/db/migrate/20160526120711_create_articles.rb:3:in `change'
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'articles' already exists: CREATE TABLE `articles` (`id` int(11) auto_increment PRIMARY KEY, `title` varchar(255)) ENGINE=InnoDB
/home/smehsan/one/db/migrate/20160526120711_create_articles.rb:3:in `change'
Mysql2::Error: Table 'articles' already exists
/home/smehsan/one/db/migrate/20160526120711_create_articles.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
@3h5a9
Copy link
Author

3h5a9 commented May 26, 2016

Just drop the database and run migrations again
from the folder (make sure you are in the folder of your new app)
rake db:drop
then rake db:migrate to re-run all your migrations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment