Skip to content

Commit

Permalink
Subdomain customizations field defaults to {}
Browse files Browse the repository at this point in the history
  • Loading branch information
tkriplean committed Jul 29, 2023
1 parent 7c521e0 commit 098f999
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions @server/models/subdomain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Subdomain < ApplicationRecord

scope :public_fields, -> { select(self.my_public_fields) }

before_validation :set_default_customizations

def users(registered=true)
qry = User
if registered
Expand Down Expand Up @@ -125,6 +127,10 @@ def rename(new_name)
self.save
end

def set_default_customizations
self.customizations ||= {}
end

def customization_json
begin
config = self.customizations || {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeDefaultJsonValueSubdomainCustomizations < ActiveRecord::Migration[6.1]
def change
Subdomain.where(customizations: nil).update_all(customizations: {}.to_json)
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_07_22_175101) do
ActiveRecord::Schema.define(version: 2023_07_29_022044) do

create_table "ahoy_events", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "subdomain_id"
Expand Down

0 comments on commit 098f999

Please sign in to comment.