add indexes for better performance

This commit is contained in:
dinedine 2010-09-15 18:09:07 +02:00
parent 9533df3e43
commit 962c04a615
4 changed files with 15 additions and 0 deletions

View File

@ -19,6 +19,9 @@ class ContentType
end
end
## indexes ##
index [[:site_id, Mongo::ASCENDING], [:slug, Mongo::ASCENDING]]
## callbacks ##
before_validation :normalize_slug
before_save :set_default_values

View File

@ -20,6 +20,11 @@ class Page
## associations ##
referenced_in :site
## indexes ##
index :site_id
index :parent_id
index [[:fullpath, Mongo::ASCENDING], [:site_id, Mongo::ASCENDING]]
## callbacks ##
before_validation :normalize_slug
before_save { |p| p.fullpath = p.fullpath(true) }

View File

@ -17,6 +17,9 @@ class Site
references_many :content_types, :dependent => :destroy
embeds_many :memberships
## indexes
index :domains
## validations ##
validates_presence_of :name, :subdomain
validates_uniqueness_of :subdomain

View File

@ -17,6 +17,10 @@ class ThemeAsset
## associations ##
referenced_in :site
## indexes ##
index :site_id
index [[:content_type, Mongo::ASCENDING], [:slug, Mongo::ASCENDING], [:site_id, Mongo::ASCENDING]]
## callbacks ##
before_validation :sanitize_slug
before_validation :store_plain_text