Add a type table for broadcast providers

This adds a type table for broadcast providers, which is the pattern we
follow with our models (e.g. we have a `broadcast_channel_types` table).

As well as the four providers, the migration populates it with `all`
which is the value that will replace `null` in a later change.

It should be safe to add the foreign key constraint to the
`service_broadcast_settings` in the same migration since the column is
still nullable and we don't have data in that column that is not in the
types table.
This commit is contained in:
Katie Smith
2021-05-05 15:24:49 +01:00
parent 46fe3fca23
commit aec631f208
3 changed files with 41 additions and 2 deletions

View File

@@ -2553,7 +2553,7 @@ class ServiceBroadcastSettings(db.Model):
channel = db.Column(
db.String(255), db.ForeignKey('broadcast_channel_types.name'), nullable=False
)
provider = db.Column(db.String, nullable=True)
provider = db.Column(db.String, db.ForeignKey('broadcast_provider_types.name'), nullable=True)
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
updated_at = db.Column(db.DateTime, nullable=True, onupdate=datetime.datetime.utcnow)
@@ -2564,6 +2564,12 @@ class BroadcastChannelTypes(db.Model):
name = db.Column(db.String(255), primary_key=True)
class BroadcastProviderTypes(db.Model):
__tablename__ = 'broadcast_provider_types'
name = db.Column(db.String(255), primary_key=True)
class ServiceBroadcastProviderRestriction(db.Model):
"""
TODO: Drop this table as no longer used