Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Migration Error: Trying to Sync Database with Local Directory and Github

Ruby on Rails Database Migrate Local Directory Github Command Line

  • Please log in to reply
1 reply to this topic

#1 chawalk90

chawalk90

    Passenger

  • Members
  • 1 posts

Posted 27 August 2014 - 10:55 PM

After trying to do a checkout to an older commit and then trying to fix a merge conflict, my pages will not load due to a Pending Migration Error. There were some migrations from the older commit that needed to be undone, so I tried using the rake db:rollback command and yet, it deleted a migration 3 steps further ahead from where I wanted it to delete and had didn't seem to have recollection of the 3 most recent migrations. Still, the files for these migrations are still visible in the local directory. I tried to also do rake db:migrate:down VERSION = (Commit#). How can I be able to view all of the attributes currently present in my database? I'm asking this assuming that the issue here is my database and local directory being at different points with perhaps different attributes/migrations, but let me know if that may not be the issue.

Also, I'm aware that another thing that may be causing an error is the fact that I was trying to change routes and paths through my documents, as I realized they were inconsistent at points and disrupted some of the pages, but not others. This has involved renaming some files on my local directory that were originally given singular names (seeker.html.erb, owner.html.etb) to plural names (seekers.html.erb, owners.html.erb), since I know that I once had something not appear because the path had to be consistent with the file name. However, I don't believe that that's the issue that's ultimately giving me this error. BTW, here is my schema.rb file that I had to edit and has been giving me problems.

__________________

ActiveRecord::Schema.define(version: 20140818224925) do

 
  create_table "surveys", force: true do |t|
    t.string   "first_name"
    t.string   "last_name"
    t.boolean  "user_status"
    t.string   "email"
    t.boolean  "loooking_for"
    t.string   "moving_to"
    t.boolean  "gender"
    t.boolean  "coed"
    t.integer  "age"
    t.string   "roommate_type"
    t.string   "housing_type"
    t.integer  "roommates_estimate"
    t.integer  "roommates_amount"
    t.boolean  "roommates_group"
    t.string   "roommates_names"
    t.integer  "wake_up"
    t.integer  "bedtime"
    t.integer  "max_rent"
    t.integer  "move_in"
    t.integer  "move_out"
    t.integer  "bedrooms"
    t.boolean  "amenities"
    t.boolean  "apartment_pet"
    t.boolean  "roommate_pet"
    t.string   "hometown"
    t.string   "school"
    t.string   "company"
    t.boolean  "terms"
    t.string   "avatar"
    t.boolean  "smoke"
    t.string   "smoke_often"
    t.boolean  "smokequit"
    t.boolean  "drink"
    t.string   "drink_often"
    t.string   "interest"
    t.boolean  "sex_privacy"
    t.boolean  "overnight"
    t.string   "overnight_often"
    t.string   "realty"
    t.boolean  "availability"
    t.string   "address"
    t.string   "list_rooms"
    t.integer  "age_min"
    t.integer  "age_max"
    t.integer  "age_mode"
    t.string   "pad_photo"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "user_id"
    t.string   "noise"
    t.string   "sociability"
    t.string   "tidiness"
    t.string   "political"
    t.string   "religion"
  end
 
  create_table "users", force: true do |t|
    t.string   "email",                  default: "", null: false
    t.string   "encrypted_password",     default: "", null: false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          default: 0,  null: false
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "avatar_file_name"
    t.string   "avatar_content_type"
    t.integer  "avatar_file_size"
    t.datetime "avatar_updated_at"
  end
 
  add_index "users", ["email"], name: "index_users_on_email", unique: true
  add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
 
end
 
______________________________________
 

Maybe I accidentally took the database too far back (through my rake db:rollback and rake db:migrate:down VERSION = commit# commands) where it doesn't recognize some attributes that would've been added through migrations? Yet the files from my migrations addFirstNameToBrowses and addAttachmentAvatarToUsers are still there in my migrate folder, neither of which I want. My main question concerns the synchronization between the database, local directory, and git hub (the latter two I believe are consistent with another now), but here are some other relevant files in case something else may be contributing to this error as well.

_____________________________________

routes.rb

__________________________________________

 

Rails.application.routes.draw do
get 'static_pages/about'

get 'static_pages/contact'

get '/howitworks' => 'static_pages#howitworks'

get '/team' => 'static_pages#team'

get '/seekerssurvey' => 'surveys#seekers'

get '/ownerssurvey' => 'surveys#owners'

get '/browsesseekers' => 'browse#seekers'

get '/browseowners' => 'browse#owners'

get '/deviseshow' => 'devise#show'



devise_for :users
resources
:users
resources
:surveys
resources
:browses
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root"
root 'static_pages#index'


# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products

# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end

# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end

# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end

# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable

# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end

 

____________________________________________________

 

index.html.erb

______________________________________________________

<div class="intro">
<%= image_tag("padibility_kangaroo.png") %>
<p>Finding Room For People</p>

<ul class="entrance">
<li class="pad"><%= link_to 'Need a Pad?', seekerssurvey_path %></li>
<li class="pad"><%= link_to 'Got a Pad?', ownerssurvey_path %></li>
<li class="pad"><%= link_to 'Browse Pad Seekers', browseseekers_path %></li>
<li class="pad"><%= link_to 'Browse Pad Owners', browseowners_path %></li>
<li class="learn">Learn More</li></a>
</ul>
</div>

 

_________________________________________

browse.rb

________________________________________________________

class Browse < ActiveRecord::Base
belongs_to :user

validates_presence_of
:first_name, :last_name
end

Here's my github file in case you want a closer look.

https://github.com/c...0/padibilityweb



#2 Ohm

Ohm

    Driver

  • Moderators
  • 468 posts
  • LocationCopenhagen

Posted 28 August 2014 - 05:22 AM

Pending migrations can be found with the rake db:migrate:status task. It will tell you which migrations have been run (up) and which hasn't (down).

 

If you do not care about the data in the database, you could also do a rake db:drop and then rake db:create.


Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk






Also tagged with one or more of these keywords: Ruby on Rails, Database, Migrate, Local Directory, Github, Command Line

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users