Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialrmax lee
495 PointsMysql2::Error: Duplicate column name 'zipcode': ALTER TABLE `accounts` ADD `zipcode`
For some reason my rkae db::migrate is aborting. when l run rake db:migrate:status l get the following error
Status Migration ID Migration Name
--------------------------------------------------
up 20150801183106 Create customers
up 20150801184336 Add email address
up 20150801184941 Create time entries
up 20150801185342 Create employees
up 20150803211552 Create accounts
up 20150803212728 Remove old tables
up 20150808174148 Account entries
up 20150808183604 Create projects
up 20150808183658 Employees projects
up 20150808230343 Omg i forgot the type field
up 20150809212450 Add index employees
up 20150810190948 Add money
up 20150810221640 Entry approval
up 20150810224142 Create versions
down 20150810224204 Customer information
And the actual rake db:migrate out the foolowing
== 20150810224204 CustomerInformation: migrating ==============================
-- add_column(:accounts, :zipcode, :integer)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2::Error: Duplicate column name 'zipcode': ALTER TABLE `accounts` ADD `zipcode` int(11)/Users/kelvinatawura/sites/biller/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `query'
l have tried comparing my code to the donwload and filling in all the needed bits but still gettng an error when l migrate. ANy ideas how l can resolve this please?
1 Answer
Hampton Catlin
Treehouse Guest TeacherAn issue that I didn't hit during my course!
When you run a migration, the change it makes is done at that moment. At some point before, you must have run the migration and it didn't fully complete, creating the column in the database, and not finishing.
One way to fix this is to rebuild the database using rake db:reset
, and another way is to use your SQL skills and go remove the existing zip-code column.
Hope this helps!
rmax lee
495 Pointsrmax lee
495 Pointsl am absolutely delighted to have you reply to my question Hampton Catlin . You are awesome!
l have tried the rake db:reset then after runned rake db:migrate but ended up with the same error. :)
rmax lee
495 Pointsrmax lee
495 PointsMy database skills are shocking. What would this code look like please if am to use my sql?