1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011 Free Software Foundation, Inc
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 Indexes for the local database.
23 Indexes are recorded in the following format:
27 'identifier': { # key identifier used for possibly deprecating later
28 'index': [index_foo_goes_here]}}
30 ... and anything else being parameters to the create_index function
31 (including unique=True, etc)
33 Current indexes must be registered in ACTIVE_INDEXES... deprecated
34 indexes should be marked in DEPRECATED_INDEXES.
36 Remember, ordering of compound indexes MATTERS. Read below for more.
39 - http://kylebanker.com/blog/2010/09/21/the-joy-of-mongodb-indexes/
41 - http://www.mongodb.org/display/DOCS/Indexes
42 - http://www.mongodb.org/display/DOCS/Indexing+Advice+and+FAQ
45 To remove deprecated indexes
46 ----------------------------
48 Removing deprecated indexes is easier, just do:
52 'deprecated_index_identifier1', 'deprecated_index_identifier2']}
56 If an index has been deprecated that identifier should NEVER BE USED
57 AGAIN. Eg, if you previously had 'awesomepants_unique', you shouldn't
58 use 'awesomepants_unique' again, you should create a totally new name
59 or at worst use 'awesomepants_unique2'.
62 from pymongo
import ASCENDING
, DESCENDING
73 MEDIAENTRY_INDEXES
= {
74 'uploader_slug_unique': {
75 # Matching an object to an uploader + slug.
76 # MediaEntries are unique on these two combined, eg:
77 # /u/${myuser}/m/${myslugname}/
78 'index': [('uploader', ASCENDING
),
83 # A global index for all media entries created, in descending
84 # order. This is used for the site's frontpage.
85 'index': [('created', DESCENDING
)]},
88 # Indexing on uploaders and when media entries are created.
89 # Used for showing a user gallery, etc.
90 'index': [('uploader', ASCENDING
),
91 ('created', DESCENDING
)]}}
94 ACTIVE_INDEXES
['media_entries'] = MEDIAENTRY_INDEXES
102 # Index usernames, and make sure they're unique.
103 # ... I guess we might need to adjust this once we're federated :)
107 # All most recently created users
111 ACTIVE_INDEXES
['users'] = USER_INDEXES
114 # MediaComment indexes
116 MEDIA_COMMENT_INDEXES
= {
117 'mediaentry_created': {
118 'index': [('media_entry', ASCENDING
),
119 ('created', DESCENDING
)]}}
121 ACTIVE_INDEXES
['media_comments'] = MEDIA_COMMENT_INDEXES
128 DEPRECATED_INDEXES
= {}