Include users in the list of models affected by tenant
This commit is contained in:
parent
682b5cb5fd
commit
63bb32f2a7
@ -18,6 +18,7 @@
|
||||
# unlock_token :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# wedding_id :uuid not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
@ -25,8 +26,15 @@
|
||||
# index_users_on_email (email) UNIQUE
|
||||
# index_users_on_reset_password_token (reset_password_token) UNIQUE
|
||||
# index_users_on_unlock_token (unlock_token) UNIQUE
|
||||
# index_users_on_wedding_id (wedding_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (wedding_id => weddings.id)
|
||||
#
|
||||
class User < ApplicationRecord
|
||||
acts_as_tenant :wedding
|
||||
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :validatable, :confirmable, :lockable
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class AddWeddingIdToModels < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
[:expenses, :guests, :seats, :tables_arrangements, :groups].each do |table|
|
||||
[:expenses, :guests, :seats, :tables_arrangements, :groups, :users].each do |table|
|
||||
add_reference table, :wedding, type: :uuid, null: false, foreign_key: true
|
||||
end
|
||||
end
|
||||
|
5
db/schema.rb
generated
5
db/schema.rb
generated
@ -1,5 +1,3 @@
|
||||
# Copyright (C) 2024 Manuel Bustillo
|
||||
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
@ -212,10 +210,12 @@ ActiveRecord::Schema[8.0].define(version: 2024_11_30_185731) do
|
||||
t.datetime "locked_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.uuid "wedding_id", null: false
|
||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
|
||||
t.index ["wedding_id"], name: "index_users_on_wedding_id"
|
||||
end
|
||||
|
||||
create_table "weddings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
@ -241,4 +241,5 @@ ActiveRecord::Schema[8.0].define(version: 2024_11_30_185731) do
|
||||
add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "tables_arrangements", "weddings"
|
||||
add_foreign_key "users", "weddings"
|
||||
end
|
||||
|
13
db/seeds.rb
13
db/seeds.rb
@ -71,10 +71,11 @@ ActsAsTenant.with_tenant(Wedding.create!(slug: :default, date: 1.year.from_now))
|
||||
'red'.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) }
|
||||
|
||||
Group.roots.each(&:colorize_children)
|
||||
|
||||
User.create!(
|
||||
email: 'development@example.com',
|
||||
confirmed_at: Time.zone.now,
|
||||
password: 'supersecretpassword',
|
||||
password_confirmation: 'supersecretpassword',
|
||||
)
|
||||
end
|
||||
User.create!(
|
||||
email: 'development@example.com',
|
||||
confirmed_at: Time.zone.now,
|
||||
password: 'supersecretpassword',
|
||||
password_confirmation: 'supersecretpassword',
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user