mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-28 01:48:33 -04:00
make notification.key_type not nullable
set to 'normal' for all existing notifications, and all job notifications also created as 'normal' - so if your eg reporting service hits notify, it gets notifications created from both API calls and front-end csv jobs.
This commit is contained in:
@@ -349,7 +349,7 @@ class Notification(db.Model):
|
||||
template_version = db.Column(db.Integer, nullable=False)
|
||||
api_key_id = db.Column(UUID(as_uuid=True), db.ForeignKey('api_keys.id'), index=True, unique=False)
|
||||
api_key = db.relationship('ApiKey')
|
||||
key_type = db.Column(db.String, db.ForeignKey('key_types.name'), index=True, unique=False)
|
||||
key_type = db.Column(db.String, db.ForeignKey('key_types.name'), index=True, unique=False, nullable=False)
|
||||
content_char_count = db.Column(db.Integer, nullable=True)
|
||||
notification_type = db.Column(notification_types, nullable=False)
|
||||
created_at = db.Column(
|
||||
|
||||
27
migrations/versions/0036_notif_key_type_not_null.py
Normal file
27
migrations/versions/0036_notif_key_type_not_null.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""notification_api_key_not_nullable
|
||||
|
||||
Revision ID: 0036_notif_key_type_not_null
|
||||
Revises: 0035_notification_type
|
||||
Create Date: 2016-07-01 16:01:16.892638
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0036_notif_key_type_not_null'
|
||||
down_revision = '0035_notification_type'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("update notifications set key_type = 'normal' where key_type is null")
|
||||
op.alter_column('notifications', 'key_type', existing_type=sa.VARCHAR(length=255), nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('notifications', 'key_type', existing_type=sa.VARCHAR(length=255), nullable=True)
|
||||
### end Alembic commands ###
|
||||
@@ -14,7 +14,8 @@ from app.models import (
|
||||
Job,
|
||||
NotificationStatistics,
|
||||
TemplateStatistics,
|
||||
NOTIFICATION_STATUS_TYPES
|
||||
NOTIFICATION_STATUS_TYPES,
|
||||
KEY_TYPE_NORMAL
|
||||
)
|
||||
|
||||
from app.dao.notifications_dao import (
|
||||
@@ -976,7 +977,8 @@ def _notification_json(sample_template, job_id=None, id=None, status=None):
|
||||
'template_version': sample_template.version,
|
||||
'created_at': datetime.utcnow(),
|
||||
'content_char_count': 160,
|
||||
'notification_type': sample_template.template_type
|
||||
'notification_type': sample_template.template_type,
|
||||
'key_type': KEY_TYPE_NORMAL
|
||||
}
|
||||
if job_id:
|
||||
data.update({'job_id': job_id})
|
||||
|
||||
Reference in New Issue
Block a user