From 1d2c3bf66036c08dce35e6083efb05f1f53f3bc4 Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Thu, 16 Apr 2026 21:58:46 +0200 Subject: [PATCH] Add seeder for initial runtime --- db/fixtures/production/02_runtimes.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 db/fixtures/production/02_runtimes.rb diff --git a/db/fixtures/production/02_runtimes.rb b/db/fixtures/production/02_runtimes.rb new file mode 100644 index 00000000..4947aaa3 --- /dev/null +++ b/db/fixtures/production/02_runtimes.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +initial_runtime_token = ENV.fetch('INITIAL_RUNTIME_TOKEN', nil) +return if initial_runtime_token.blank? + +return unless Runtime.count.zero? + +runtime = Runtime.new( + name: 'Initial Runtime', + description: 'Provisioned with token from INITIAL_RUNTIME_TOKEN environment variable', + token: initial_runtime_token +) + +# rubocop:disable Code0/ZeroTrack/Logs/RailsLogger -- we can't include a module here +if runtime.save + Rails.logger.info(message: 'Initial runtime created') +else + Rails.logger.warn(message: 'Failed to create initial runtime', errors: runtime.errors.full_messages) +end +# rubocop:enable Code0/ZeroTrack/Logs/RailsLogger