aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/migrations.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-06-22 16:13:41 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-06-22 16:13:41 -0500
commit257b8ab62a6a5e04d60575a9766e5ed3503a15ed (patch)
tree5d998fd1b955cb180ad1010c07ec35b1fd945b1b /mediagoblin/db/migrations.py
parent75ee3de301e7bea30c40fe26d857bb6cc7878f82 (diff)
parent0c7fa7556ced34444db82d2d2d3b51b4f5327586 (diff)
downloadmediagoblin-257b8ab62a6a5e04d60575a9766e5ed3503a15ed.tar.lz
mediagoblin-257b8ab62a6a5e04d60575a9766e5ed3503a15ed.tar.xz
mediagoblin-257b8ab62a6a5e04d60575a9766e5ed3503a15ed.zip
Merge remote-tracking branch 'refs/remotes/joar/notifications'
Conflicts: mediagoblin/db/migrations.py
Diffstat (limited to 'mediagoblin/db/migrations.py')
-rw-r--r--mediagoblin/db/migrations.py58
1 files changed, 56 insertions, 2 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 6c9bf5cc..7074ffec 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -26,7 +26,7 @@ from sqlalchemy.sql import and_
from migrate.changeset.constraint import UniqueConstraint
from mediagoblin.db.migration_tools import RegisterMigration, inspect_table
-from mediagoblin.db.models import MediaEntry, Collection, User
+from mediagoblin.db.models import MediaEntry, Collection, User, MediaComment
MIGRATIONS = {}
@@ -288,7 +288,6 @@ def unique_collections_slug(db):
db.commit()
-
@RegisterMigration(11, MIGRATIONS)
def drop_token_related_User_columns(db):
"""
@@ -307,3 +306,58 @@ def drop_token_related_User_columns(db):
fp_token_expire.drop()
db.commit()
+
+class CommentSubscription_v0(declarative_base()):
+ __tablename__ = 'core__comment_subscriptions'
+ id = Column(Integer, primary_key=True)
+
+ created = Column(DateTime, nullable=False, default=datetime.datetime.now)
+
+ media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=False)
+
+ user_id = Column(Integer, ForeignKey(User.id), nullable=False)
+
+ notify = Column(Boolean, nullable=False, default=True)
+ send_email = Column(Boolean, nullable=False, default=True)
+
+
+class Notification_v0(declarative_base()):
+ __tablename__ = 'core__notifications'
+ id = Column(Integer, primary_key=True)
+ type = Column(Unicode)
+
+ created = Column(DateTime, nullable=False, default=datetime.datetime.now)
+
+ user_id = Column(Integer, ForeignKey(User.id), nullable=False,
+ index=True)
+ seen = Column(Boolean, default=lambda: False, index=True)
+
+
+class CommentNotification_v0(Notification_v0):
+ __tablename__ = 'core__comment_notifications'
+ id = Column(Integer, ForeignKey(Notification_v0.id), primary_key=True)
+
+ subject_id = Column(Integer, ForeignKey(MediaComment.id))
+
+
+class ProcessingNotification_v0(Notification_v0):
+ __tablename__ = 'core__processing_notifications'
+
+ id = Column(Integer, ForeignKey(Notification_v0.id), primary_key=True)
+
+ subject_id = Column(Integer, ForeignKey(MediaEntry.id))
+
+
+@RegisterMigration(12, MIGRATIONS)
+def add_new_notification_tables(db):
+ metadata = MetaData(bind=db.bind)
+
+ user_table = inspect_table(metadata, 'core__users')
+ mediaentry_table = inspect_table(metadata, 'core__media_entries')
+ mediacomment_table = inspect_table(metadata, 'core__media_comments')
+
+ CommentSubscription_v0.__table__.create(db.bind)
+
+ Notification_v0.__table__.create(db.bind)
+ CommentNotification_v0.__table__.create(db.bind)
+ ProcessingNotification_v0.__table__.create(db.bind)