mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 09:27:56 -04:00
remove history-meta for templates, replace with hand-made history table
history-meta's dynamic magic is insufficient for templates, where we need to be able to refer to the specific history table to take advantage of sqlalchemy's relationship management (2/3rds of an ORM). So replace it with a custom made version table. Had to change the version decorator slightly for this
This commit is contained in:
@@ -206,7 +206,7 @@ TEMPLATE_TYPES = [SMS_TYPE, EMAIL_TYPE, LETTER_TYPE]
|
||||
template_types = db.Enum(*TEMPLATE_TYPES, name='template_type')
|
||||
|
||||
|
||||
class Template(db.Model, Versioned):
|
||||
class Template(db.Model):
|
||||
__tablename__ = 'templates'
|
||||
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
@@ -231,6 +231,26 @@ class Template(db.Model, Versioned):
|
||||
subject = db.Column(db.Text, index=False, unique=False, nullable=True)
|
||||
created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False)
|
||||
created_by = db.relationship('User')
|
||||
version = db.Column(db.Integer, default=1)
|
||||
|
||||
|
||||
class TemplateHistory(db.Model):
|
||||
__tablename__ = 'templates_history'
|
||||
|
||||
id = db.Column(UUID(as_uuid=True), primary_key=True)
|
||||
name = db.Column(db.String(255), nullable=False)
|
||||
template_type = db.Column(template_types, nullable=False)
|
||||
created_at = db.Column(db.DateTime, nullable=False)
|
||||
updated_at = db.Column(db.DateTime)
|
||||
content = db.Column(db.Text, nullable=False)
|
||||
archived = db.Column(db.Boolean, nullable=False, default=False)
|
||||
service_id = db.Column(UUID(as_uuid=True), db.ForeignKey('services.id'), index=True, nullable=False)
|
||||
service = db.relationship('Service')
|
||||
subject = db.Column(db.Text)
|
||||
created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False)
|
||||
created_by = db.relationship('User')
|
||||
version = db.Column(db.Integer)
|
||||
|
||||
|
||||
MMG_PROVIDER = "mmg"
|
||||
FIRETEXT_PROVIDER = "firetext"
|
||||
|
||||
Reference in New Issue
Block a user