from mediagoblin.db.sql.extratypes import PathTupleWithSlashes
from mediagoblin.db.sql.base import Base, DictReadAttrProxy
- from mediagoblin.db.mixin import UserMixin, MediaEntryMixin
+ from mediagoblin.db.mixin import UserMixin, MediaEntryMixin, MediaCommentMixin
+# It's actually kind of annoying how sqlalchemy-migrate does this, if
+# I understand it right, but whatever. Anyway, don't remove this :P
+#
+# We could do migration calls more manually instead of relying on
+# this import-based meddling...
+from migrate import changeset
+
class SimpleFieldAlias(object):
"""An alias for any field"""
get_author = relationship(User)
+ _id = SimpleFieldAlias("id")
+
- def show_table_init():
+MODELS = [
+ User, MediaEntry, Tag, MediaTag, MediaComment]
+
+
+######################################################
+# Special, migrations-tracking table
+#
+# Not listed in MODELS because this is special and not
+# really migrated, but used for migrations (for now)
+######################################################
+
+class MigrationData(Base):
+ __tablename__ = "migrations"
+
+ name = Column(Unicode, primary_key=True)
+ version = Column(Integer, nullable=False, default=0)
+
+######################################################
+
+
+ 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)