mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-free-sms-limit-history
This commit is contained in:
@@ -337,7 +337,7 @@ class ServiceSmsSender(db.Model):
|
||||
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
sms_sender = db.Column(db.String(11), nullable=False)
|
||||
service_id = db.Column(UUID(as_uuid=True), db.ForeignKey('services.id'), index=True, nullable=False)
|
||||
service_id = db.Column(UUID(as_uuid=True), db.ForeignKey('services.id'), index=True, nullable=False, unique=False)
|
||||
service = db.relationship(Service, backref=db.backref("service_sms_senders", uselist=True))
|
||||
is_default = db.Column(db.Boolean, nullable=False, default=True)
|
||||
inbound_number_id = db.Column(UUID(as_uuid=True), db.ForeignKey('inbound_numbers.id'),
|
||||
@@ -894,7 +894,7 @@ DVLA_RESPONSE_STATUS_SENT = 'Sent'
|
||||
class NotificationStatusTypes(db.Model):
|
||||
__tablename__ = 'notification_status_types'
|
||||
|
||||
name = db.Column(db.String(255), primary_key=True)
|
||||
name = db.Column(db.String(), primary_key=True)
|
||||
|
||||
|
||||
class Notification(db.Model):
|
||||
@@ -1520,3 +1520,24 @@ class NotificationEmailReplyTo(db.Model):
|
||||
nullable=False,
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
|
||||
class NotificationSmsSender(db.Model):
|
||||
__tablename__ = "notification_to_sms_sender"
|
||||
|
||||
notification_id = db.Column(
|
||||
UUID(as_uuid=True),
|
||||
db.ForeignKey('notifications.id'),
|
||||
unique=True,
|
||||
index=True,
|
||||
nullable=False,
|
||||
primary_key=True
|
||||
)
|
||||
service_sms_sender_id = db.Column(
|
||||
UUID(as_uuid=True),
|
||||
db.ForeignKey('service_sms_senders.id'),
|
||||
unique=False,
|
||||
index=True,
|
||||
nullable=False,
|
||||
primary_key=True
|
||||
)
|
||||
|
||||
44
migrations/versions/0128_noti_to_sms_sender.py
Normal file
44
migrations/versions/0128_noti_to_sms_sender.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0128_noti_to_sms_sender
|
||||
Revises: 0127_remove_unique_constraint
|
||||
Create Date: 2017-10-26 15:17:00.752706
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0128_noti_to_sms_sender'
|
||||
down_revision = '0127_remove_unique_constraint'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_index(op.f('ix_service_letter_contacts_service_id'), 'service_letter_contacts', ['service_id'],
|
||||
unique=False)
|
||||
op.drop_index('ix_service_letter_contact_service_id', table_name='service_letter_contacts')
|
||||
op.create_index(op.f('ix_service_sms_senders_service_id'), 'service_sms_senders', ['service_id'], unique=False)
|
||||
op.execute(
|
||||
'ALTER TABLE templates_history ALTER COLUMN template_type TYPE template_type USING template_type::template_type')
|
||||
|
||||
# new table
|
||||
op.create_table('notification_to_sms_sender',
|
||||
sa.Column('notification_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_sms_sender_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['notification_id'], ['notifications.id'], ),
|
||||
sa.ForeignKeyConstraint(['service_sms_sender_id'], ['service_sms_senders.id'], ),
|
||||
sa.PrimaryKeyConstraint('notification_id', 'service_sms_sender_id')
|
||||
)
|
||||
op.create_index(op.f('ix_notification_to_sms_sender_notification_id'), 'notification_to_sms_sender', ['notification_id'], unique=True)
|
||||
op.create_index(op.f('ix_notification_to_sms_sender_service_sms_sender_id'), 'notification_to_sms_sender', ['service_sms_sender_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_service_sms_senders_service_id'), table_name='service_sms_senders')
|
||||
op.create_index('ix_service_letter_contact_service_id', 'service_letter_contacts', ['service_id'], unique=False)
|
||||
op.drop_index(op.f('ix_service_letter_contacts_service_id'), table_name='service_letter_contacts')
|
||||
op.alter_column('templates_history', 'template_type',
|
||||
type_=sa.VARCHAR(),
|
||||
existing_nullable=False)
|
||||
|
||||
op.drop_table('notification_to_sms_sender')
|
||||
Reference in New Issue
Block a user