aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2012-02-11 00:38:21 +0100
committerElrond <elrond+mediagoblin.org@samba-tng.org>2012-02-11 12:11:51 +0100
commiteea6d276bc03bbbea7bba325f3cb6ebf6663b451 (patch)
tree369c4861d910af34c92fe9c73b17289ec9e08e78 /mediagoblin
parent937c7ea5d90db6678ae08a3524cce872d21d24ad (diff)
downloadmediagoblin-eea6d276bc03bbbea7bba325f3cb6ebf6663b451.tar.lz
mediagoblin-eea6d276bc03bbbea7bba325f3cb6ebf6663b451.tar.xz
mediagoblin-eea6d276bc03bbbea7bba325f3cb6ebf6663b451.zip
sql db design suggestions by Svavar Kjarrval
Many thanks go to Svavar Kjarrval who has taken a deeper look at our current sql db design and made a bunch of suggestions. The suggestions are currently put as TODO items in the docstrings. This way we can keep track of them directly where we need it.
Diffstat (limited to 'mediagoblin')
-rw-r--r--mediagoblin/db/sql/models.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py
index 36f94b25..9d06f79c 100644
--- a/mediagoblin/db/sql/models.py
+++ b/mediagoblin/db/sql/models.py
@@ -14,6 +14,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+TODO: indexes on foreignkeys, where useful.
+"""
+
import datetime
@@ -43,6 +47,10 @@ class SimpleFieldAlias(object):
class User(Base, UserMixin):
+ """
+ TODO: We should consider moving some rarely used fields
+ into some sort of "shadow" table.
+ """
__tablename__ = "users"
id = Column(Integer, primary_key=True)
@@ -67,6 +75,9 @@ class User(Base, UserMixin):
class MediaEntry(Base, MediaEntryMixin):
+ """
+ TODO: Consider fetching the media_files using join
+ """
__tablename__ = "media_entries"
id = Column(Integer, primary_key=True)
@@ -145,6 +156,10 @@ class MediaEntry(Base, MediaEntryMixin):
class MediaFile(Base):
+ """
+ TODO: Highly consider moving "name" into a new table.
+ TODO: Consider preloading said table in software
+ """
__tablename__ = "mediafiles"
media_entry = Column(
@@ -221,12 +236,20 @@ class MediaComment(Base):
_id = SimpleFieldAlias("id")
-def show_table_init():
+def show_table_init(engine_uri):
+ if engine_uri is None:
+ engine_uri = 'sqlite:///:memory:'
from sqlalchemy import create_engine
- engine = create_engine('sqlite:///:memory:', echo=True)
+ engine = create_engine(engine_uri, echo=True)
Base.metadata.create_all(engine)
if __name__ == '__main__':
- show_table_init()
+ from sys import argv
+ print repr(argv)
+ if len(argv) == 2:
+ uri = argv[1]
+ else:
+ uri = None
+ show_table_init(uri)