mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
* Initial account sharing changes * Update schema.rb * Update schema.rb * Change sharing UI to modal * UX fixes and sharing controls * Scope include in finances better * Update totals.rb * Update totals.rb * Scope reports to finance account scope * Update impersonation_sessions_controller_test.rb * Review fixes * Update schema.rb * Update show.html.erb * FIX db validation * Refine edit permissions * Review items * Review * Review * Add application level helper * Critical review * Address remaining review items * Fix modals * more scoping * linter * small UI fix * Fix: Sync broadcasts push unscoped balance sheet to all users * Update sync_complete_event.rb The fix removes the sidebar broadcasts (which rendered unscoped account groups using family.balance_sheet without user context) along with the now-unused sidebar_targets, account_group, and family_balance_sheet private methods. The sidebar will still update correctly — when the sync completes, Family::SyncCompleteEvent#broadcast fires family.broadcast_refresh, which triggers a morph-based page refresh for each user with their own authenticated session, rendering properly scoped sidebar content.
22 lines
1022 B
Ruby
22 lines
1022 B
Ruby
class AddAccountSharingSupport < ActiveRecord::Migration[7.2]
|
|
def change
|
|
# Family-level default: whether new accounts are shared with all members by default
|
|
add_column :families, :default_account_sharing, :string, default: "shared", null: false
|
|
|
|
# Account ownership: who created/owns the account
|
|
add_reference :accounts, :owner, type: :uuid, foreign_key: { to_table: :users }, null: true, index: true
|
|
|
|
# Sharing join table: per-user access to accounts they don't own
|
|
create_table :account_shares, id: :uuid, default: -> { "gen_random_uuid()" } do |t|
|
|
t.references :account, type: :uuid, null: false, foreign_key: true
|
|
t.references :user, type: :uuid, null: false, foreign_key: true
|
|
t.string :permission, null: false, default: "read_only"
|
|
t.boolean :include_in_finances, null: false, default: true
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :account_shares, [ :account_id, :user_id ], unique: true
|
|
add_index :account_shares, [ :user_id, :include_in_finances ]
|
|
end
|
|
end
|