From 94df840b3bf100a3fdd33e2fef2d4201d4a4ac45 Mon Sep 17 00:00:00 2001 From: Elrond Date: Thu, 1 Mar 2012 21:34:21 +0100 Subject: [PATCH] SQL: Improve video media_data table 1. Make the foreignkey the primary_key. 2. Add width/height, as those are currently in use for the media_data --- mediagoblin/db/sql/convert.py | 1 + mediagoblin/media_types/video/models.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mediagoblin/db/sql/convert.py b/mediagoblin/db/sql/convert.py index 79717913..250c559b 100644 --- a/mediagoblin/db/sql/convert.py +++ b/mediagoblin/db/sql/convert.py @@ -20,6 +20,7 @@ from mediagoblin.db.mongo.util import ObjectId from mediagoblin.db.sql.models import (Base, User, MediaEntry, MediaComment, Tag, MediaTag, MediaFile, MediaAttachmentFile) +from mediagoblin.media_types.video.models import VideoData from mediagoblin.db.sql.open import setup_connection_and_db_from_config as \ sql_connect from mediagoblin.db.mongo.open import setup_connection_and_db_from_config as \ diff --git a/mediagoblin/media_types/video/models.py b/mediagoblin/media_types/video/models.py index 741c329b..709d7910 100644 --- a/mediagoblin/media_types/video/models.py +++ b/mediagoblin/media_types/video/models.py @@ -18,16 +18,17 @@ from mediagoblin.db.sql.models import Base from sqlalchemy import ( - Column, Integer, Unicode, UnicodeText, DateTime, Boolean, ForeignKey, - UniqueConstraint) + Column, Integer, SmallInteger, ForeignKey) class VideoData(Base): __tablename__ = "video_data" - id = Column(Integer, primary_key=True) - media_entry = Column( - Integer, ForeignKey('media_entries.id'), nullable=False) + # The primary key *and* reference to the main media_entry + media_entry = Column(Integer, ForeignKey('media_entries.id'), + primary_key=True) + width = Column(SmallInteger) + height = Column(SmallInteger) DATA_MODEL = VideoData