Skip to content

Commit

Permalink
Preserve registrations_mode setting for existing servers
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Feb 19, 2024
1 parent 9ce5fd4 commit 4ab9e38
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/settings.yml
Expand Up @@ -9,7 +9,7 @@ defaults: &defaults
site_terms: ''
site_contact_username: ''
site_contact_email: ''
registrations_mode: 'none'
registrations_mode: 'none' # if you had changed this, check out `db/migrate/20240219170215_save_default_registrations_mode.rb`
profile_directory: true
closed_registrations_message: ''
timeline_preview: true
Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20240219170215_save_default_registrations_mode.rb
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class SaveDefaultRegistrationsMode < ActiveRecord::Migration[7.1]
class MigrationSetting < ApplicationRecord
self.table_name = :settings
end

def up
MigrationSetting.create!(thing_id: nil, thing_type: nil, var: 'registrations_mode', value: "--- open\n") unless MigrationSetting.exists?(thing_id: nil, thing_type: nil, var: 'registrations_mode')
end

def down; end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_01_11_033014) do
ActiveRecord::Schema[7.1].define(version: 2024_02_19_170215) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down
5 changes: 5 additions & 0 deletions lib/tasks/tests.rake
Expand Up @@ -105,6 +105,11 @@ namespace :tests do
exit(1)
end

unless Setting.registrations_mode == 'open'
puts "Unexpected registrations mode: #{Setting.registrations_mode}"
exit(1)
end

puts 'No errors found. Database state is consistent with a successful migration process.'
end

Expand Down

0 comments on commit 4ab9e38

Please sign in to comment.