Must I create a schema.sql? Given that rails creates the schema when
using mySQL, why create schema.sql?
I have sqlite3 installed but am unsure about what the database.yml
should
look like and how the database file is found. I created an empty
database and placed it in straw/db, but that doesn’t seem to work.
http://wiki.rubyonrails.org/rails/pages/HowtoUseSQLite says to:
sqlite3 ~/databases/rails-app.db < /path/to/schema.sql
However, I never created a .sql file. Can’t I just plop straw.db
somewhere and tell database.yml where to find it? This appears to be
what happens in Windows.
For mySQL rails created all tables and schemas. Cannot rails do the
same
thing for sqLite?
Here’s what I have:
thufir@arrakis ~/rubyCode/straw $
thufir@arrakis ~/rubyCode/straw $ cat db/migrate/001_feeds.rb
class Feeds < ActiveRecord::Migration
def self.up
create_table :feeds do |table|
table.column :title, :string
table.column :location, :string
table.column :category_id, :integer
end
end
def self.down
drop_table :feeds
end
end
thufir@arrakis ~/rubyCode/straw $
thufir@arrakis ~/rubyCode/straw $ ll db/straw.db
-rw-r–r-- 1 thufir users 0 Nov 28 22:30 db/straw.db
thufir@arrakis ~/rubyCode/straw $
thufir@arrakis ~/rubyCode/straw $ cat config/database.yml
development:
adapter: sqlite
dbfile: /home/thufir/straw/db/straw.db
test:
adapter: sqlite
dbfile: /home/thufir/straw/db/straw.db
production:
adapter: sqlite
dbfile: /home/thufir/straw/db/straw.db
thufir@arrakis ~/rubyCode/straw $
thufir@arrakis ~/rubyCode/straw $ pwd
/home/thufir/rubyCode/straw
thufir@arrakis ~/rubyCode/straw $
thufir@arrakis ~/rubyCode/straw $ rake db:migrate
(in /home/thufir/rubyCode/straw)
rake aborted!
no such file to load – sqlite
(See full trace by running task with --trace)
thufir@arrakis ~/rubyCode/straw $
thufir@arrakis ~/rubyCode/straw $ eix dev-ruby/sqlite3-ruby
[I] dev-ruby/sqlite3-ruby
Available versions: 1.1.0 ~1.2.1 {doc swig}
Installed versions: 1.1.0(21:15:58 11/28/07)(doc)
Homepage: http://rubyforge.org/projects/sqlite-ruby/
Description: An extension library to access a SQLite
database from Ruby
thufir@arrakis ~/rubyCode/straw $
thanks,
Thufir