Use a unique id

This commit is contained in:
Rebecca Law
2017-09-12 09:30:55 +01:00
parent e119ced7c1
commit 9bd3ed2dac

View File

@@ -235,14 +235,14 @@ class PopulateServiceEmailReplyTo(Command):
def run(self):
services_to_update = """
INSERT INTO service_email_reply_to(id, service_id, email_address, is_default, created_at)
SELECT '{}', id, reply_to_email_address, true, '{}'
SELECT uuid_in(md5(random()::text || now()::text)::cstring), id, reply_to_email_address, true, '{}'
FROM services
WHERE reply_to_email_address IS NOT NULL
AND id NOT IN(
SELECT service_id
FROM service_email_reply_to
)
""".format(uuid.uuid4(), datetime.utcnow())
""".format(datetime.utcnow())
result = db.session.execute(services_to_update)
db.session.commit()