SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Simply Rails 2 - Sqlite3 add_column error - SOLVED

    Hi, noob here.
    I'm running my shovell app on OS X 10.4 and $sqlite3 --version results in: 3.5.8

    Edit: I found a script that gets run in the script/console:
    Code:
    require 'rubygems'
    require 'sqlite3'
    db = SQLite3::Database.new('db/development.sqlite3')
    puts db.execute('select sqlite_version()')
    Supposedly it tells me which version of sqlite3 my rails app is attached to... it spit out 3.1.3, not the 3.5.8 that I get from the command line. aaaahhhhhh!?!?!
    /Edit

    I've uninstalled and reinstalled sqlite3-ruby-1.2.2

    In chapter 8, I discovered a problem while trying to test the functionals. I originally thought it was a problem with my test database and ended up following instructions on Justin Frenchís site - justinfrenchdotcom/ + index.php?id=232 - to recreate my databases, where I discovered the issue was related to my migrations. Ifigured the problem was due to the migration on page 255, requesting the addition of columns to the existing tables...

    Code:
    add_column :stories, :user_id, :integer
    add_column :votes, :user_id, :integer
    rake db:migrate resulted in:

    Code:
    -- add_column(:stories, :votes_count, :integer, {:default=>0})
    rake aborted!
    SQLite3::SQLException: near "ADD": syntax error: ALTER TABLE...

    I got around this problem by removing the add_column code and having them established in the original migrations, which were rebuilt using Justinís code. Nice fix but then I ran into the same issue on page 306 when adding the votes_count column for the counter cache function.

    $rake db:migrate resultes in:
    Code:
    == 4 AddCounterCacheToStories: migrating ======================================
    -- add_column(:stories, :votes_count, :integer, {:default=>0})
    rake aborted!
    SQLite3::SQLException: near "ADD": syntax error: ALTER TABLE stories ADD "votes_count" integer DEFAULT 0
    
    (See full trace by running task with --trace)
    From what I find elsewhere, people refer to this problem for older versions of Sqlite and itís ruby gem. but mine seem to be up to date. not really sure where to go from here. Please help.
    Last edited by TotallyInfected; Jun 24, 2008 at 11:21. Reason: new issue info - not very well understood

  2. #2
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    per the interwebs... it seems I had originally installed Ruby & rails with MySQL and then added sqlite3 by way of Macports. So all was showing up to date but rails was still trying to access the old native install of sqlite3 on os x 10.4. reinstalled sqlite3 from source and reinstalled sqlite3-ruby gem (again) and all seems fine.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •