New table to hold scheduled_notifications.

This commit is contained in:
Rebecca Law
2017-05-15 12:59:44 +01:00
parent cd85550889
commit 75a4dad8c1
2 changed files with 41 additions and 0 deletions

View File

@@ -912,6 +912,16 @@ class NotificationHistory(db.Model, HistoryModel):
INVITED_USER_STATUS_TYPES = ['pending', 'accepted', 'cancelled'] INVITED_USER_STATUS_TYPES = ['pending', 'accepted', 'cancelled']
class ScheduledNotification(db.Model):
__tablename__ = 'scheduled_notifications'
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4())
notification_id = db.Column(UUID(as_uuid=True), db.ForeignKey('notifications.id'), index=True, nullable=False)
notification = db.relationship('Notification')
scheduled_for = db.Column(db.DateTime, index=False, nullable=False)
pending = db.Column(db.Boolean, nullable=False, default=False)
class InvitedUser(db.Model): class InvitedUser(db.Model):
__tablename__ = 'invited_users' __tablename__ = 'invited_users'

View File

@@ -0,0 +1,31 @@
"""empty message
Revision ID: 0083_scheduled_notifications
Revises: 0082_add_go_live_template
Create Date: 2017-05-15 12:50:20.041950
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '0083_scheduled_notifications'
down_revision = '0082_add_go_live_template'
def upgrade():
op.create_table('scheduled_notifications',
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('notification_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('scheduled_for', sa.DateTime(), nullable=False),
sa.Column('pending', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['notification_id'], ['notifications.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_scheduled_notifications_notification_id'), 'scheduled_notifications', ['notification_id'],
unique=False)
def downgrade():
op.drop_index(op.f('ix_scheduled_notifications_notification_id'), table_name='scheduled_notifications')
op.drop_table('scheduled_notifications')