[英]mysql2 in rails3 'table exits already' how to delete that?
I delete the project robin_offine for some reason and when I restart it and run 我出于某种原因删除了项目robin_offine,并在重新启动它并运行时
rake db:create,it claims: rake db:create,它声称:
robin_offline_development already exists
robin_offline_test already exists
ignore that and add migration named events 忽略它并添加迁移命名事件
if rake db:migrate 如果rake db:migrate
Mysql2::Error: Table 'events' already exists(cuz i have done that last time)
The problem is ,I couldn't find where the table is 问题是,我找不到桌子在哪里
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)
Even don't know which one to delete 甚至不知道要删除哪一个
sorry I'm new to mysql 抱歉,我是mysql新手
the system is Ubuntu 12.04LTS 系统是Ubuntu 12.04LTS
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: robin_offline_development
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: robin_offline_test
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: robin_offline_production
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
and my migration file is just what run 而我的迁移文件正是运行
rails g model events
nothing special 没什么特别的
develop.log 开发日志
Connecting to database specified by database.yml
Connecting to database specified by database.yml
[1m[36m (1.1ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
Migrating to CreateEvents (20121213091145)
[1m[35m (0.5ms)[0m CREATE TABLE `events` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
Mysql2::Error: Table 'events' already exists: CREATE TABLE `events` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
Connecting to database specified by database.yml
[1m[36m (1.1ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
Migrating to CreateEvents (20121213091145)
[1m[35m (0.5ms)[0m CREATE TABLE `events` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
Mysql2::Error: Table 'events' already exists: CREATE TABLE `events` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
Connecting to database specified by database.yml
[1m[36m (1.9ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
Migrating to CreateEvents (20121213091145)
[1m[35m (0.5ms)[0m CREATE TABLE `events` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
Mysql2::Error: Table 'events' already exists: CREATE TABLE `events` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
I just run 我刚跑
rake db:drop
and do the migration again, all goes well again 并再次进行迁移,一切都恢复正常
and rails db
to goto the database and do whatever you want. 和
rails db
转到数据库并执行您想要的任何操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.