From: Christopher Allan Webber Date: Sat, 18 Feb 2012 16:01:47 +0000 (-0600) Subject: Merge branch 'master' into sqlmigrate X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=63352aaf70d97a37b6277fab0f9b957d34dcb9df;p=mediagoblin.git Merge branch 'master' into sqlmigrate Conflicts: mediagoblin/db/sql/models.py --- 63352aaf70d97a37b6277fab0f9b957d34dcb9df diff --cc mediagoblin/db/sql/models.py index 41b8b490,18e1dfd7..b6377172 --- a/mediagoblin/db/sql/models.py +++ b/mediagoblin/db/sql/models.py @@@ -27,15 -31,8 +31,15 @@@ from sqlalchemy.ext.associationproxy im 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""" @@@ -221,31 -230,14 +237,34 @@@ class MediaComment(Base, MediaCommentMi get_author = relationship(User) + _id = SimpleFieldAlias("id") + +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(): + 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)