Comments (9)
By server restart, does it mean the entire box or just the rails server? If just the rails server, all you have to do is hit control-c in the terminal you originally started it in. It might just be that rails can't run the migration while the server is running for whatever reason.
from nku.
@flanaganm87 you copied and pasted most of the output, but the lines just after you stopped would have been the most helpful.
Also, @jaimerump is correct about restarting the Rails server. You don't need to in this particular instance, though, as Rails will continue once the migration is successful.
from nku.
I did not have the server running while using the migrate command, but here is the rest of the error
$ bin/rake db:migrate RAILS_ENV=development
== CreateComments: migrating =================================================
-- create_table(:comments)
-> 0.0068s
-- add_index(:comments, :post_id)
rake aborted!
An error has occurred, this and all later migrations canceled:
Index name 'index_comments_on_post_id' on table 'comments' already exists/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:815:in add_index_option s' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:521:in
add_index'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:625:in block in method_missing' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:597:in
block in say_with_time'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:597:in say_with_time' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:617:in
method_missing'
/home/action/nku-rails/db/migrate/20140123223406_create_comments.rb:10:in change' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:571:in
exec_migration'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:555:in block (2 levels) in migrate' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:554:in
block in migrate'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in with_connection' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:553:in
migrate'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:709:in migrate' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:959:in
block in execute_migration_in_transaction'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:1005:in block in ddl_transaction' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
block in transaction'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in within_new_transaction' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
transaction'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in transaction' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:1005:in
ddl_transaction'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:958:in execute_migration_in_transaction' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:920:in
block in migrate'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:916:in each' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:916:in
migrate'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:764:in up' /home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/migration.rb:742:in
migrate'
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
from nku.
@flanaganm87 the important line in there is: Index name 'index_comments_on_post_id' on table 'comments' already exists
. It's tough to figure out how this happened without access to the db, but you could try dropping and re-creating the database:
rake db:drop
rake db:create
rake db:migrate
See if that gets you past the error.
from nku.
@cdmwebs , I ran the the three mentioned commands, and I ensured that the development.sqlite3 file was removed, and I am still getting the same error as above.
from nku.
Any chance you are adding the index twice in separate migrations?
A way to test it would be to remove the one added in: db/migrate/20140123223406_create_comments.rb. Then see if the index is still defined in: db/schema.rb. Just search db/schema.rb for "index_comments_on_post_id" after you repeat the steps @cdmwebs gave you.
from nku.
Hey @flanaganm87. I just took a look at your migrations and the problem is that you're trying to add multiple indexes.
def change
create_table :comments do |t|
t.string :commenter
t.text :body
t.references :post, index: true
t.timestamps
end
add_index :comments, :post_id
end
Removing either the add_index
line or the index: true
should resolve the issue.
from nku.
I removed the index: true and it worked, I don't understand how this happened though, I don't recall editing this file, and it clearly worked for assignment#1. Thanks though!
from nku.
@flanaganm87 I had this same in class issue after migrating to the new box @rockwood helped me resolve it then.
Though not super clearly explained by the error message it gives after looking into it appears to be as stated above an issue with multiple indexes. Primarily in our case it seem to be cause by the fact we moved everything including already raked databases over to the new box and and reset up rails. It seems to be unable to handle that situation effectively.
from nku.
Related Issues (20)
- ActiveRecord question HOT 2
- How can an administrator sign up? HOT 1
- Logout not being properly referenced HOT 1
- CSS / LESS not classes not being applied
- Adding upload action? HOT 3
- Creating an administrator HOT 3
- Question about to assignments ago, querying for assignments
- SASS Error HOT 5
- Rollback some commits HOT 5
- Question about STIs or polymorphic associations HOT 10
- Site won't collapse on mobile HOT 2
- I'm thinking about using devise HOT 4
- Who wants an invite to prelang? HOT 16
- Ruby Brigade tomorrow is anyone going?
- How do to safely use github? HOT 8
- Blank Pages HOT 5
- Can't Use Partial Dates HOT 4
- has_many :through => HOT 2
- validation errors HOT 4
- ActiveRecord::PendingMigrationError HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nku.