From e6b5b6eae348aa0f6148589a07e9ade0f08bae59 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Fri, 7 Oct 2022 09:16:04 +1100 Subject: [PATCH] DEV: update to patched discourse-seed-fu (#18493) Original seed-fu was cloned and patched with David's fix https://github.com/discourse/discourse-seed-fu/commit/576b69a3687388d760531ec7e8b9bb017d1a6861 --- Gemfile | 2 +- Gemfile.lock | 8 ++++---- lib/freedom_patches/seed_fu.rb | 19 ------------------- spec/lib/freedom_patches/seed_fu_spec.rb | 17 ----------------- 4 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 lib/freedom_patches/seed_fu.rb delete mode 100644 spec/lib/freedom_patches/seed_fu_spec.rb diff --git a/Gemfile b/Gemfile index baca43e5b26..ba96d9a8fd4 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem 'sprockets', '3.7.2' # allows us to precompile all our templates in the unicorn master gem 'actionview_precompiler', require: false -gem 'seed-fu' +gem 'discourse-seed-fu' gem 'mail', git: 'https://github.com/discourse/mail.git' gem 'mini_mime' diff --git a/Gemfile.lock b/Gemfile.lock index 7347c11499d..e7977f67d04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -127,6 +127,9 @@ GEM railties (>= 3.1) discourse-ember-source (3.12.2.3) discourse-fonts (0.0.9) + discourse-seed-fu (2.3.12) + activerecord (>= 3.1) + activesupport (>= 3.1) discourse_dev_assets (0.0.4) faker (~> 2.16) literate_randomizer @@ -437,9 +440,6 @@ GEM sprockets (> 3.0) sprockets-rails tilt - seed-fu (2.3.9) - activerecord (>= 3.1) - activesupport (>= 3.1) selenium-webdriver (4.5.0) childprocess (>= 0.5, < 5.0) rexml (~> 3.2, >= 3.2.5) @@ -545,6 +545,7 @@ DEPENDENCIES discourse-ember-rails (= 0.18.6) discourse-ember-source (~> 3.12.2) discourse-fonts + discourse-seed-fu discourse_dev_assets email_reply_trimmer ember-handlebars-template (= 0.8.0) @@ -628,7 +629,6 @@ DEPENDENCIES sanitize sassc (= 2.0.1) sassc-rails - seed-fu selenium-webdriver shoulda-matchers sidekiq diff --git a/lib/freedom_patches/seed_fu.rb b/lib/freedom_patches/seed_fu.rb deleted file mode 100644 index b24241b3d73..00000000000 --- a/lib/freedom_patches/seed_fu.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -SeedFu::Seeder.prepend(Module.new do - def update_id_sequence - max_seeded_id = @data.filter_map { |d| d["id"] }.max - seq = @model_class.connection.execute(<<~SQL) - SELECT last_value - FROM #{@model_class.sequence_name} - SQL - last_seq_value = seq.first["last_value"] - - if max_seeded_id && last_seq_value < max_seeded_id - # Update the sequence to start from the highest existing id - @model_class.connection.reset_pk_sequence!(@model_class.table_name) - else - # The sequence is already higher than any of our seeded ids - better not touch it - end - end -end) diff --git a/spec/lib/freedom_patches/seed_fu_spec.rb b/spec/lib/freedom_patches/seed_fu_spec.rb deleted file mode 100644 index 12ba1dd745f..00000000000 --- a/spec/lib/freedom_patches/seed_fu_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "seed-fu patch" do - it "does not modify a sequence on an existing table" do - u = User.create!(username: "test1", email: "test1@example.com") - uid1 = u.id - UserDestroyer.new(Discourse.system_user).destroy(u) - - SeedFu.quiet = true - SeedFu.seed - - # Ensure sequence was not reset. A new user should have - # id one greater than the last user - u2 = User.create!(username: "test1", email: "test1@example.com") - expect(u2.id).to eq(uid1 + 1) - end -end