From 55fc4945a8b160bdc6a14ab47137fb6bd7770245 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Mon, 3 Jul 2023 12:37:43 +0200 Subject: [PATCH] add migration --- db/migrate/20230703103209_create_default_favorites.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20230703103209_create_default_favorites.rb diff --git a/db/migrate/20230703103209_create_default_favorites.rb b/db/migrate/20230703103209_create_default_favorites.rb new file mode 100644 index 000000000..32e6f2747 --- /dev/null +++ b/db/migrate/20230703103209_create_default_favorites.rb @@ -0,0 +1,9 @@ +class CreateDefaultFavorites < ActiveRecord::Migration[7.0] + def up + User.not_visitor.not_contributor.not_author.not_teacher.not_program_manager.each do |user| + return if user.favorites.any? + return if user.university.websites.many? + user.favorites.create(about: user.university.websites.first) + end + end +end -- GitLab