From c3bc1fb6e2766b6da492a70bb86c193f034cadea Mon Sep 17 00:00:00 2001 From: Jingchao Zhong <92573736+perryzjc@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:23:08 -0800 Subject: [PATCH] Update email reseed implementation to avoid purge old email templates --- db/seeds.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 10512ca9..5523552b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2,8 +2,11 @@ require_relative "seed_data" -EmailTemplate.delete_all -SeedData.emails.each { |email| EmailTemplate.create!(email) } +SeedData.emails.each do |email_attrs| + # to, body fields are updated through development, should be be used as part of the uniqueness check + email_template = EmailTemplate.find_or_initialize_by(email_attrs.except(:to, :body)) + email_template.update(email_attrs) +end SeedData.create_schools