2010年3月22日 星期一

substruct with sqlite3

-- Substruct (download)

-- patch it by sqlite3 support (mysql by default).
diff --git a/config/boot.rb b/config/boot.rb
index dd5e3b6..ad28b5a 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -44,7 +44,7 @@ module Rails
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
- Rails::GemDependency.add_frozen_gem_path
+ #Rails::GemDependency.add_frozen_gem_path
end
end

diff --git a/config/database.yml b/config/database.yml
index 796e976..8c4c899 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -14,29 +14,52 @@
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
-development:
- adapter: mysql
- encoding: utf8
- database: substruct_development
- username: root
- password:
- socket: /tmp/mysql.sock
+#development:
+# adapter: mysql
+# encoding: utf8
+# database: substruct_development
+# username: root
+# password:
+# socket: /tmp/mysql.sock

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
+#test:
+# adapter: mysql
+# encoding: utf8
+# database: substruct_test
+# username: root
+# password:
+# socket: /tmp/mysql.sock
+#
+#production:
+# adapter: mysql
+# encoding: utf8
+# database: substruct_production
+# username: root
+# password:
+# socket: /tmp/mysql.sock
+
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
test:
- adapter: mysql
- encoding: utf8
- database: substruct_test
- username: root
- password:
- socket: /tmp/mysql.sock
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000

production:
- adapter: mysql
- encoding: utf8
- database: substruct_production
- username: root
- password:
- socket: /tmp/mysql.sock
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
diff --git a/config/initializers/new_rails_defaults.rb b/config/initializers/new_rails_defaults.rb
index c94db0a..54e3661 100644
--- a/config/initializers/new_rails_defaults.rb
+++ b/config/initializers/new_rails_defaults.rb
@@ -11,11 +11,11 @@ if defined?(ActiveRecord)
ActiveRecord::Base.store_full_sti_class = true
end

-ActionController::Routing.generate_best_match = false
+#ActionController::Routing.generate_best_match = false

# Use ISO 8601 format for JSON serialized times and dates.
ActiveSupport.use_standard_json_time_format = true

# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
# if you're including raw json in an HTML page.
diff --git a/vendor/plugins/substruct/db/schema.rb b/vendor/plugins/substruct/db/schema.rb
index ce71f69..2c13378 100755
--- a/vendor/plugins/substruct/db/schema.rb
+++ b/vendor/plugins/substruct/db/schema.rb
@@ -116,8 +116,10 @@ ActiveRecord::Schema.define(:version => 20100210194537) do
t.integer "country_id", :default => 0, :null => false
end

- add_index "order_addresses", ["first_name", "last_name"], :name => "name"
- add_index "order_addresses", ["country_id", "order_user_id"], :name => "countries"
+ #add_index "order_addresses", ["first_name", "last_name"], :name => "name"
+ #add_index "order_addresses", ["country_id", "order_user_id"], :name => "countries"
+ add_index "order_addresses", ["first_name", "last_name"]
+ add_index "order_addresses", ["country_id", "order_user_id"]

create_table "order_line_items", :force => true do |t|
t.integer "item_id"
@@ -145,7 +147,8 @@ ActiveRecord::Schema.define(:version => 20100210194537) do
t.string "name", :limit => 30, :default => "", :null => false
end

- add_index "order_status_codes", ["name"], :name => "name"
+ #add_index "order_status_codes", ["name"], :name => "name"
+ add_index "order_status_codes", ["name"]

create_table "order_users", :force => true do |t|
t.string "email_address", :limit => 50, :default => "", :null => false
@@ -246,7 +249,8 @@ ActiveRecord::Schema.define(:version => 20100210194537) do
t.integer "related_id", :default => 0, :null => false
end

- add_index "related_products", ["product_id", "related_id"], :name => "related_products"
+ #add_index "related_products", ["product_id", "related_id"], :name => "related_products"
+ add_index "related_products", ["product_id", "related_id"]

create_table "rights", :force => true do |t|
t.string "name"
@@ -290,7 +294,8 @@ ActiveRecord::Schema.define(:version => 20100210194537) do
t.integer "parent_id", :default => 0, :null => false
end

- add_index "tags", ["name"], :name => "name"
+ #add_index "tags", ["name"], :name => "name"
+ add_index "tags", ["name"]

create_table "user_uploads", :force => true do |t|
t.string "filename"
diff --git a/vendor/plugins/substruct/app/models/product.rb b/vendor/plugins/substruct/app/models/product.rb
index 655e1c8..c2f9b5c 100755
--- a/vendor/plugins/substruct/app/models/product.rb
+++ b/vendor/plugins/substruct/app/models/product.rb
@@ -2,9 +2,9 @@ class Product < Item
# Conditions that the product is in stock, or available
# and just out of stock.
CONDITIONS_AVAILABLE = %Q/
- CURRENT_DATE() >= DATE(items.date_available)
- AND items.is_discontinued = 0
- OR (items.is_discontinued = 1 AND (items.quantity > 0 OR items.variation_quantity > 0))
+ CURRENT_DATE >= DATE(items.date_available)
+ AND items.is_discontinued = 'f'
+ OR (items.is_discontinued = 't' AND (items.quantity > 0 OR items.variation_quantity > 0))
/

has_many :product_images, :dependent => :destroy
-- my gem list
*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
appengine-jruby-jars (0.0.6)
appengine-rack (0.0.6)
appengine-sdk (1.3.1)
appengine-tools (0.0.10.1)
authlogic (2.1.3)
authlogic-oid (1.0.4)
bundler08 (0.8.5)
cgi_multipart_eof_fix (2.5.0)
columnize (0.3.1)
daemons (1.0.10)
ezcrypto (0.7.2)
fastercsv (1.5.3)
fastthread (1.0.7)
gem_plugin (0.2.3)
google-appengine (0.0.10.1)
json (1.2.3)
linecache (0.43)
mime-types (1.16)
mini_magick (1.2.5)
mongrel (1.1.6)
passenger (2.2.11)
rack (1.0.1)
rails (2.3.5)
rake (0.8.7)
RedCloth (4.2.3)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.9)
ruby-openid (2.1.7)
rubyzip (0.9.4)
sqlite3-ruby (1.2.5)
wrest (0.1.0)

-- do bootstrap
rake substruct:db:bootstrap

-- go!
script/server

沒有留言: