Skip to content

Commit fa63628

Browse files
committed
Migrate zoho related changes
1 parent e2c276d commit fa63628

File tree

7 files changed

+63
-1
lines changed

7 files changed

+63
-1
lines changed

app/models/pwb/shard_audit_log.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ module Pwb
1313
# new_shard_name: 'shard_1',
1414
# changed_by_email: 'admin@example.com',
1515
# notes: 'Moving to dedicated shard for performance'
16+
# == Schema Information
17+
#
18+
# Table name: pwb_shard_audit_logs
19+
# Database name: primary
20+
#
21+
# id :bigint not null, primary key
22+
# changed_by_email :string not null
23+
# new_shard_name :string not null
24+
# notes :string
25+
# old_shard_name :string
26+
# status :string default("completed"), not null
27+
# created_at :datetime not null
28+
# updated_at :datetime not null
29+
# website_id :bigint not null
30+
#
31+
# Indexes
32+
#
33+
# index_pwb_shard_audit_logs_on_changed_by_email (changed_by_email)
34+
# index_pwb_shard_audit_logs_on_created_at (created_at)
35+
# index_pwb_shard_audit_logs_on_status (status)
36+
# index_pwb_shard_audit_logs_on_website_id (website_id)
37+
#
38+
# Foreign Keys
39+
#
40+
# fk_rails_... (website_id => pwb_websites.id)
41+
#
1642
# )
1743
class ShardAuditLog < ApplicationRecord
1844
self.table_name = 'pwb_shard_audit_logs'

app/models/pwb/user.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module Pwb
3333
# last_sign_in_at :datetime
3434
# last_sign_in_ip :string
3535
# locked_at :datetime
36+
# metadata :jsonb not null
3637
# onboarding_completed_at :datetime
3738
# onboarding_started_at :datetime
3839
# onboarding_state :string default("active"), not null
@@ -63,6 +64,7 @@ module Pwb
6364
# index_pwb_users_on_site_admin_onboarding_completed_at (site_admin_onboarding_completed_at)
6465
# index_pwb_users_on_unlock_token (unlock_token) UNIQUE
6566
# index_pwb_users_on_website_id (website_id)
67+
# index_pwb_users_on_zoho_lead_id (((metadata ->> 'zoho_lead_id'::text))) WHERE ((metadata ->> 'zoho_lead_id'::text) IS NOT NULL)
6668
#
6769
class User < ApplicationRecord
6870
include AASM

app/models/pwb_tenant/user.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module PwbTenant
3232
# last_sign_in_at :datetime
3333
# last_sign_in_ip :string
3434
# locked_at :datetime
35+
# metadata :jsonb not null
3536
# onboarding_completed_at :datetime
3637
# onboarding_started_at :datetime
3738
# onboarding_state :string default("active"), not null
@@ -62,6 +63,7 @@ module PwbTenant
6263
# index_pwb_users_on_site_admin_onboarding_completed_at (site_admin_onboarding_completed_at)
6364
# index_pwb_users_on_unlock_token (unlock_token) UNIQUE
6465
# index_pwb_users_on_website_id (website_id)
66+
# index_pwb_users_on_zoho_lead_id (((metadata ->> 'zoho_lead_id'::text))) WHERE ((metadata ->> 'zoho_lead_id'::text) IS NOT NULL)
6567
#
6668
class User < Pwb::User
6769
include RequiresTenant

db/schema.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[8.1].define(version: 2026_01_08_135240) do
13+
ActiveRecord::Schema[8.1].define(version: 2026_01_09_114702) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pg_catalog.plpgsql"
1616
enable_extension "pgcrypto"
@@ -1018,6 +1018,7 @@
10181018
t.datetime "last_sign_in_at", precision: nil
10191019
t.string "last_sign_in_ip"
10201020
t.datetime "locked_at", precision: nil
1021+
t.jsonb "metadata", default: {}, null: false
10211022
t.datetime "onboarding_completed_at"
10221023
t.datetime "onboarding_started_at"
10231024
t.string "onboarding_state", default: "active", null: false
@@ -1035,6 +1036,7 @@
10351036
t.string "unlock_token"
10361037
t.datetime "updated_at", precision: nil, null: false
10371038
t.integer "website_id"
1039+
t.index "((metadata ->> 'zoho_lead_id'::text))", name: "index_pwb_users_on_zoho_lead_id", where: "((metadata ->> 'zoho_lead_id'::text) IS NOT NULL)"
10381040
t.index ["confirmation_token"], name: "index_pwb_users_on_confirmation_token", unique: true
10391041
t.index ["email"], name: "index_pwb_users_on_email", unique: true
10401042
t.index ["firebase_uid"], name: "index_pwb_users_on_firebase_uid", unique: true

spec/factories/pwb_shard_audit_logs.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# frozen_string_literal: true
22

3+
# == Schema Information
4+
#
5+
# Table name: pwb_shard_audit_logs
6+
# Database name: primary
7+
#
8+
# id :bigint not null, primary key
9+
# changed_by_email :string not null
10+
# new_shard_name :string not null
11+
# notes :string
12+
# old_shard_name :string
13+
# status :string default("completed"), not null
14+
# created_at :datetime not null
15+
# updated_at :datetime not null
16+
# website_id :bigint not null
17+
#
18+
# Indexes
19+
#
20+
# index_pwb_shard_audit_logs_on_changed_by_email (changed_by_email)
21+
# index_pwb_shard_audit_logs_on_created_at (created_at)
22+
# index_pwb_shard_audit_logs_on_status (status)
23+
# index_pwb_shard_audit_logs_on_website_id (website_id)
24+
#
25+
# Foreign Keys
26+
#
27+
# fk_rails_... (website_id => pwb_websites.id)
28+
#
329
FactoryBot.define do
430
factory :pwb_shard_audit_log, class: 'Pwb::ShardAuditLog' do
531
association :website, factory: :pwb_website

spec/factories/pwb_users.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# last_sign_in_at :datetime
2626
# last_sign_in_ip :string
2727
# locked_at :datetime
28+
# metadata :jsonb not null
2829
# onboarding_completed_at :datetime
2930
# onboarding_started_at :datetime
3031
# onboarding_state :string default("active"), not null
@@ -55,6 +56,7 @@
5556
# index_pwb_users_on_site_admin_onboarding_completed_at (site_admin_onboarding_completed_at)
5657
# index_pwb_users_on_unlock_token (unlock_token) UNIQUE
5758
# index_pwb_users_on_website_id (website_id)
59+
# index_pwb_users_on_zoho_lead_id (((metadata ->> 'zoho_lead_id'::text))) WHERE ((metadata ->> 'zoho_lead_id'::text) IS NOT NULL)
5860
#
5961
FactoryBot.define do
6062
factory :pwb_user, class: 'Pwb::User', aliases: [:user] do

spec/models/pwb/user_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# last_sign_in_at :datetime
2626
# last_sign_in_ip :string
2727
# locked_at :datetime
28+
# metadata :jsonb not null
2829
# onboarding_completed_at :datetime
2930
# onboarding_started_at :datetime
3031
# onboarding_state :string default("active"), not null
@@ -55,6 +56,7 @@
5556
# index_pwb_users_on_site_admin_onboarding_completed_at (site_admin_onboarding_completed_at)
5657
# index_pwb_users_on_unlock_token (unlock_token) UNIQUE
5758
# index_pwb_users_on_website_id (website_id)
59+
# index_pwb_users_on_zoho_lead_id (((metadata ->> 'zoho_lead_id'::text))) WHERE ((metadata ->> 'zoho_lead_id'::text) IS NOT NULL)
5860
#
5961
require 'rails_helper'
6062

0 commit comments

Comments
 (0)