mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
add version to provider_details and _history
set all existing rows to have a version of 1 (also copy across values to populate the new provider_details_history table in the upgrade script) in dao_update_provider_details bump the provider_details.version by 1 and then duplicate into the history table as a new row (done manually as opposed to the decorator used in template_history since this is only edited in this one place and the decorator is icky)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from sqlalchemy import asc
|
||||
from app.dao.dao_utils import transactional
|
||||
from app.models import ProviderDetails
|
||||
from app.models import ProviderDetails, ProviderDetailsHistory
|
||||
from app import db
|
||||
|
||||
|
||||
@@ -20,4 +20,7 @@ def get_provider_details_by_notification_type(notification_type):
|
||||
|
||||
@transactional
|
||||
def dao_update_provider_details(provider_details):
|
||||
provider_details.version += 1
|
||||
history = ProviderDetailsHistory.from_original(provider_details)
|
||||
db.session.add(provider_details)
|
||||
db.session.add(history)
|
||||
|
||||
@@ -367,17 +367,19 @@ class ProviderDetails(db.Model):
|
||||
priority = db.Column(db.Integer, nullable=False)
|
||||
notification_type = db.Column(notification_types, nullable=False)
|
||||
active = db.Column(db.Boolean, default=False, nullable=False)
|
||||
version = db.Column(db.Integer, default=1, nullable=False)
|
||||
|
||||
|
||||
class ProviderDetailsHistory(db.Model, HistoryModel):
|
||||
__tablename__ = 'provider_details_history'
|
||||
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True)
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True, nullable=False)
|
||||
display_name = db.Column(db.String, nullable=False)
|
||||
identifier = db.Column(db.String, nullable=False)
|
||||
priority = db.Column(db.Integer, nullable=False)
|
||||
notification_type = db.Column(notification_types, nullable=False)
|
||||
active = db.Column(db.Boolean, nullable=False)
|
||||
version = db.Column(db.Integer, primary_key=True, nullable=False)
|
||||
|
||||
|
||||
JOB_STATUS_PENDING = 'pending'
|
||||
|
||||
Reference in New Issue
Block a user