Add account_id to everything
This commit is contained in:
committed by
Mike Dalessio
parent
bca4318cd4
commit
ba3f6b188e
@@ -1,6 +1,8 @@
|
|||||||
class Account < ApplicationRecord
|
class Account < ApplicationRecord
|
||||||
include Entropic, Seedeable
|
include Entropic, Seedeable
|
||||||
|
|
||||||
|
has_one :join_code
|
||||||
|
|
||||||
has_many_attached :uploads
|
has_many_attached :uploads
|
||||||
|
|
||||||
after_create :create_join_code
|
after_create :create_join_code
|
||||||
@@ -9,9 +11,9 @@ class Account < ApplicationRecord
|
|||||||
|
|
||||||
class << self
|
class << self
|
||||||
def create_with_admin_user(account:, owner:)
|
def create_with_admin_user(account:, owner:)
|
||||||
create!(**account).tap do
|
create!(**account).tap do |account|
|
||||||
User.system
|
User.create!(account: account, role: :system, name: "System")
|
||||||
User.create!(**owner.reverse_merge(role: "admin"))
|
User.create!(**owner.reverse_merge(role: "admin", account: account))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -24,9 +26,4 @@ class Account < ApplicationRecord
|
|||||||
def slug
|
def slug
|
||||||
"/#{external_account_id}"
|
"/#{external_account_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def create_join_code
|
|
||||||
Account::JoinCode.create!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
class Account::JoinCode < ApplicationRecord
|
class Account::JoinCode < ApplicationRecord
|
||||||
CODE_LENGTH = 12
|
CODE_LENGTH = 12
|
||||||
|
|
||||||
|
belongs_to :account
|
||||||
|
|
||||||
scope :active, -> { where("usage_count < usage_limit") }
|
scope :active, -> { where("usage_count < usage_limit") }
|
||||||
|
|
||||||
before_create :generate_code, if: -> { code.blank? }
|
before_create :generate_code, if: -> { code.blank? }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Board < ApplicationRecord
|
class Board < ApplicationRecord
|
||||||
include Accessible, AutoPostponing, Broadcastable, Cards, Entropic, Filterable, Publishable, Triageable
|
include Accessible, AutoPostponing, Broadcastable, Cards, Entropic, Filterable, Publishable, Triageable
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
||||||
|
|
||||||
has_rich_text :public_description
|
has_rich_text :public_description
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ class Card < ApplicationRecord
|
|||||||
Golden, Mentions, Multistep, Pinnable, Postponable, Promptable,
|
Golden, Mentions, Multistep, Pinnable, Postponable, Promptable,
|
||||||
Readable, Searchable, Stallable, Statuses, Taggable, Triageable, Watchable
|
Readable, Searchable, Stallable, Statuses, Taggable, Triageable, Watchable
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :board, touch: true
|
belongs_to :board, touch: true
|
||||||
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Column < ApplicationRecord
|
class Column < ApplicationRecord
|
||||||
include Colored, Positioned
|
include Colored, Positioned
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :board, touch: true
|
belongs_to :board, touch: true
|
||||||
has_many :cards, dependent: :nullify
|
has_many :cards, dependent: :nullify
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class Comment < ApplicationRecord
|
class Comment < ApplicationRecord
|
||||||
include Attachments, Eventable, Mentions, Promptable, Searchable
|
include Attachments, Eventable, Mentions, Promptable, Searchable
|
||||||
belongs_to :card, touch: true
|
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
|
belongs_to :card, touch: true
|
||||||
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
||||||
has_many :reactions, dependent: :delete_all
|
has_many :reactions, dependent: :delete_all
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Event < ApplicationRecord
|
class Event < ApplicationRecord
|
||||||
include Notifiable, Particulars, Promptable
|
include Notifiable, Particulars, Promptable
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :board
|
belongs_to :board
|
||||||
belongs_to :creator, class_name: "User"
|
belongs_to :creator, class_name: "User"
|
||||||
belongs_to :eventable, polymorphic: true
|
belongs_to :eventable, polymorphic: true
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
class Filter < ApplicationRecord
|
class Filter < ApplicationRecord
|
||||||
include Fields, Params, Resources, Summarized
|
include Fields, Params, Resources, Summarized
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
belongs_to :creator, class_name: "User", default: -> { Current.user }
|
||||||
has_one :account, through: :creator
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def from_params(params)
|
def from_params(params)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Mention < ApplicationRecord
|
class Mention < ApplicationRecord
|
||||||
include Notifiable
|
include Notifiable
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :source, polymorphic: true
|
belongs_to :source, polymorphic: true
|
||||||
belongs_to :mentioner, class_name: "User"
|
belongs_to :mentioner, class_name: "User"
|
||||||
belongs_to :mentionee, class_name: "User", inverse_of: :mentions
|
belongs_to :mentionee, class_name: "User", inverse_of: :mentions
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Notification < ApplicationRecord
|
class Notification < ApplicationRecord
|
||||||
include PushNotifiable
|
include PushNotifiable
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :creator, class_name: "User"
|
belongs_to :creator, class_name: "User"
|
||||||
belongs_to :source, polymorphic: true
|
belongs_to :source, polymorphic: true
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class Notification::Bundle < ApplicationRecord
|
class Notification::Bundle < ApplicationRecord
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
enum :status, %i[ pending processing delivered ]
|
enum :status, %i[ pending processing delivered ]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class Push::Subscription < ApplicationRecord
|
class Push::Subscription < ApplicationRecord
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
def notification(**params)
|
def notification(**params)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class Reaction < ApplicationRecord
|
class Reaction < ApplicationRecord
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :comment, touch: true
|
belongs_to :comment, touch: true
|
||||||
belongs_to :reacter, class_name: "User", default: -> { Current.user }
|
belongs_to :reacter, class_name: "User", default: -> { Current.user }
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class Step < ApplicationRecord
|
class Step < ApplicationRecord
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :card, touch: true
|
belongs_to :card, touch: true
|
||||||
|
|
||||||
scope :completed, -> { where(completed: true) }
|
scope :completed, -> { where(completed: true) }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class Tag < ApplicationRecord
|
class Tag < ApplicationRecord
|
||||||
include Attachable, Filterable
|
include Attachable, Filterable
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
has_many :taggings, dependent: :destroy
|
has_many :taggings, dependent: :destroy
|
||||||
has_many :cards, through: :taggings
|
has_many :cards, through: :taggings
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
has_one_attached :avatar
|
has_one_attached :avatar
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :membership, optional: true
|
belongs_to :membership, optional: true
|
||||||
|
|
||||||
has_one :identity, through: :membership, disable_joins: true
|
has_one :identity, through: :membership, disable_joins: true
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Webhook < ApplicationRecord
|
|||||||
has_many :deliveries, dependent: :delete_all
|
has_many :deliveries, dependent: :delete_all
|
||||||
has_one :delinquency_tracker, dependent: :delete
|
has_one :delinquency_tracker, dependent: :delete
|
||||||
|
|
||||||
|
belongs_to :account, default: -> { Current.account }
|
||||||
belongs_to :board
|
belongs_to :board
|
||||||
|
|
||||||
serialize :subscribed_actions, type: Array, coder: JSON
|
serialize :subscribed_actions, type: Array, coder: JSON
|
||||||
|
|||||||
+3
-3
@@ -11,11 +11,11 @@
|
|||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.2].define(version: 1) do
|
ActiveRecord::Schema[8.2].define(version: 1) do
|
||||||
create_table "solid_cable_messages", force: :cascade do |t|
|
create_table "solid_cable_messages", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.binary "channel", limit: 1024, null: false
|
t.binary "channel", limit: 1024, null: false
|
||||||
t.integer "channel_hash", limit: 8, null: false
|
t.bigint "channel_hash", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.binary "payload", limit: 536870912, null: false
|
t.binary "payload", size: :long, null: false
|
||||||
t.index ["channel"], name: "index_solid_cable_messages_on_channel"
|
t.index ["channel"], name: "index_solid_cable_messages_on_channel"
|
||||||
t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash"
|
t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash"
|
||||||
t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
|
t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
|
||||||
|
|||||||
+4
-4
@@ -11,12 +11,12 @@
|
|||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.2].define(version: 1) do
|
ActiveRecord::Schema[8.2].define(version: 1) do
|
||||||
create_table "solid_cache_entries", force: :cascade do |t|
|
create_table "solid_cache_entries", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.integer "byte_size", limit: 4, null: false
|
t.integer "byte_size", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.binary "key", limit: 1024, null: false
|
t.binary "key", limit: 1024, null: false
|
||||||
t.integer "key_hash", limit: 8, null: false
|
t.bigint "key_hash", null: false
|
||||||
t.binary "value", limit: 536870912, null: false
|
t.binary "value", size: :long, null: false
|
||||||
t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
|
t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
|
||||||
t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
|
t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
|
||||||
t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
|
t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
class AddAccountIdEverywhere < ActiveRecord::Migration[8.2]
|
||||||
|
def change
|
||||||
|
add_column :account_join_codes, :account_id, :integer
|
||||||
|
add_column :users, :account_id, :integer
|
||||||
|
add_column :boards, :account_id, :integer
|
||||||
|
add_column :columns, :account_id, :integer
|
||||||
|
add_column :cards, :account_id, :integer
|
||||||
|
add_column :steps, :account_id, :integer
|
||||||
|
add_column :comments, :account_id, :integer
|
||||||
|
add_column :mentions, :account_id, :integer
|
||||||
|
add_column :notifications, :account_id, :integer
|
||||||
|
add_column :notification_bundles, :account_id, :integer
|
||||||
|
add_column :filters, :account_id, :integer
|
||||||
|
add_column :events, :account_id, :integer
|
||||||
|
add_column :reactions, :account_id, :integer
|
||||||
|
add_column :tags, :account_id, :integer
|
||||||
|
add_column :webhooks, :account_id, :integer
|
||||||
|
add_column :push_subscriptions, :account_id, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
+11
-11
@@ -11,7 +11,7 @@
|
|||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.2].define(version: 1) do
|
ActiveRecord::Schema[8.2].define(version: 1) do
|
||||||
create_table "solid_queue_blocked_executions", force: :cascade do |t|
|
create_table "solid_queue_blocked_executions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.string "concurrency_key", null: false
|
t.string "concurrency_key", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "expires_at", null: false
|
t.datetime "expires_at", null: false
|
||||||
@@ -23,7 +23,7 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["job_id"], name: "index_solid_queue_blocked_executions_on_job_id", unique: true
|
t.index ["job_id"], name: "index_solid_queue_blocked_executions_on_job_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_claimed_executions", force: :cascade do |t|
|
create_table "solid_queue_claimed_executions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "job_id", null: false
|
t.bigint "job_id", null: false
|
||||||
t.bigint "process_id"
|
t.bigint "process_id"
|
||||||
@@ -31,14 +31,14 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["process_id", "job_id"], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id"
|
t.index ["process_id", "job_id"], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_failed_executions", force: :cascade do |t|
|
create_table "solid_queue_failed_executions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.text "error"
|
t.text "error"
|
||||||
t.bigint "job_id", null: false
|
t.bigint "job_id", null: false
|
||||||
t.index ["job_id"], name: "index_solid_queue_failed_executions_on_job_id", unique: true
|
t.index ["job_id"], name: "index_solid_queue_failed_executions_on_job_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_jobs", force: :cascade do |t|
|
create_table "solid_queue_jobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.string "active_job_id"
|
t.string "active_job_id"
|
||||||
t.text "arguments"
|
t.text "arguments"
|
||||||
t.string "class_name", null: false
|
t.string "class_name", null: false
|
||||||
@@ -56,13 +56,13 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["scheduled_at", "finished_at"], name: "index_solid_queue_jobs_for_alerting"
|
t.index ["scheduled_at", "finished_at"], name: "index_solid_queue_jobs_for_alerting"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_pauses", force: :cascade do |t|
|
create_table "solid_queue_pauses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.string "queue_name", null: false
|
t.string "queue_name", null: false
|
||||||
t.index ["queue_name"], name: "index_solid_queue_pauses_on_queue_name", unique: true
|
t.index ["queue_name"], name: "index_solid_queue_pauses_on_queue_name", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_processes", force: :cascade do |t|
|
create_table "solid_queue_processes", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.string "hostname"
|
t.string "hostname"
|
||||||
t.string "kind", null: false
|
t.string "kind", null: false
|
||||||
@@ -76,7 +76,7 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["supervisor_id"], name: "index_solid_queue_processes_on_supervisor_id"
|
t.index ["supervisor_id"], name: "index_solid_queue_processes_on_supervisor_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_ready_executions", force: :cascade do |t|
|
create_table "solid_queue_ready_executions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "job_id", null: false
|
t.bigint "job_id", null: false
|
||||||
t.integer "priority", default: 0, null: false
|
t.integer "priority", default: 0, null: false
|
||||||
@@ -86,7 +86,7 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["queue_name", "priority", "job_id"], name: "index_solid_queue_poll_by_queue"
|
t.index ["queue_name", "priority", "job_id"], name: "index_solid_queue_poll_by_queue"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_recurring_executions", force: :cascade do |t|
|
create_table "solid_queue_recurring_executions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "job_id", null: false
|
t.bigint "job_id", null: false
|
||||||
t.datetime "run_at", null: false
|
t.datetime "run_at", null: false
|
||||||
@@ -95,7 +95,7 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["task_key", "run_at"], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true
|
t.index ["task_key", "run_at"], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_recurring_tasks", force: :cascade do |t|
|
create_table "solid_queue_recurring_tasks", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.text "arguments"
|
t.text "arguments"
|
||||||
t.string "class_name"
|
t.string "class_name"
|
||||||
t.string "command", limit: 2048
|
t.string "command", limit: 2048
|
||||||
@@ -111,7 +111,7 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["static"], name: "index_solid_queue_recurring_tasks_on_static"
|
t.index ["static"], name: "index_solid_queue_recurring_tasks_on_static"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_scheduled_executions", force: :cascade do |t|
|
create_table "solid_queue_scheduled_executions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "job_id", null: false
|
t.bigint "job_id", null: false
|
||||||
t.integer "priority", default: 0, null: false
|
t.integer "priority", default: 0, null: false
|
||||||
@@ -121,7 +121,7 @@ ActiveRecord::Schema[8.2].define(version: 1) do
|
|||||||
t.index ["scheduled_at", "priority", "job_id"], name: "index_solid_queue_dispatch_all"
|
t.index ["scheduled_at", "priority", "job_id"], name: "index_solid_queue_dispatch_all"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "solid_queue_semaphores", force: :cascade do |t|
|
create_table "solid_queue_semaphores", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "expires_at", null: false
|
t.datetime "expires_at", null: false
|
||||||
t.string "key", null: false
|
t.string "key", null: false
|
||||||
|
|||||||
Generated
+17
-1
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
ActiveRecord::Schema[8.2].define(version: 2025_11_10_175021) do
|
||||||
create_table "accesses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "accesses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.datetime "accessed_at"
|
t.datetime "accessed_at"
|
||||||
t.bigint "board_id", null: false
|
t.bigint "board_id", null: false
|
||||||
@@ -25,6 +25,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "account_join_codes", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "account_join_codes", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.string "code", null: false
|
t.string "code", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
@@ -113,6 +114,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "boards", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "boards", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.boolean "all_access", default: false, null: false
|
t.boolean "all_access", default: false, null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "creator_id", null: false
|
t.bigint "creator_id", null: false
|
||||||
@@ -161,6 +163,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "cards", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "cards", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.bigint "board_id", null: false
|
t.bigint "board_id", null: false
|
||||||
t.bigint "column_id"
|
t.bigint "column_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@@ -193,6 +196,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "columns", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "columns", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.bigint "board_id", null: false
|
t.bigint "board_id", null: false
|
||||||
t.string "color", null: false
|
t.string "color", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@@ -204,6 +208,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "comments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "comments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.bigint "card_id", null: false
|
t.bigint "card_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.integer "creator_id", null: false
|
t.integer "creator_id", null: false
|
||||||
@@ -229,6 +234,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "events", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "events", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.string "action", null: false
|
t.string "action", null: false
|
||||||
t.bigint "board_id", null: false
|
t.bigint "board_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@@ -245,6 +251,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "filters", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "filters", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "creator_id", null: false
|
t.bigint "creator_id", null: false
|
||||||
t.json "fields", default: -> { "(json_object())" }, null: false
|
t.json "fields", default: -> { "(json_object())" }, null: false
|
||||||
@@ -290,6 +297,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "mentions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "mentions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "mentionee_id", null: false
|
t.bigint "mentionee_id", null: false
|
||||||
t.bigint "mentioner_id", null: false
|
t.bigint "mentioner_id", null: false
|
||||||
@@ -302,6 +310,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "notification_bundles", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "notification_bundles", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "ends_at", null: false
|
t.datetime "ends_at", null: false
|
||||||
t.datetime "starts_at", null: false
|
t.datetime "starts_at", null: false
|
||||||
@@ -314,6 +323,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "notifications", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "notifications", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "creator_id"
|
t.bigint "creator_id"
|
||||||
t.datetime "read_at"
|
t.datetime "read_at"
|
||||||
@@ -338,6 +348,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "push_subscriptions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "push_subscriptions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.string "auth_key"
|
t.string "auth_key"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.string "endpoint"
|
t.string "endpoint"
|
||||||
@@ -353,6 +364,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "reactions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "reactions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.integer "comment_id", null: false
|
t.integer "comment_id", null: false
|
||||||
t.string "content", limit: 16, null: false
|
t.string "content", limit: 16, null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
@@ -387,6 +399,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "steps", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "steps", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.bigint "card_id", null: false
|
t.bigint "card_id", null: false
|
||||||
t.boolean "completed", default: false, null: false
|
t.boolean "completed", default: false, null: false
|
||||||
t.text "content", null: false
|
t.text "content", null: false
|
||||||
@@ -406,6 +419,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "tags", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "tags", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
@@ -423,6 +437,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.boolean "active", default: true, null: false
|
t.boolean "active", default: true, null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.integer "membership_id"
|
t.integer "membership_id"
|
||||||
@@ -466,6 +481,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_06_154151) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "webhooks", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "webhooks", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
|
t.integer "account_id"
|
||||||
t.boolean "active", default: true, null: false
|
t.boolean "active", default: true, null: false
|
||||||
t.bigint "board_id", null: false
|
t.bigint "board_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
|
|||||||
@@ -25,17 +25,15 @@ class Import
|
|||||||
Event.suppress do
|
Event.suppress do
|
||||||
Current.with(account: account) do
|
Current.with(account: account) do
|
||||||
Webhook.skip_callback(:create, :after, :create_delinquency_tracker!)
|
Webhook.skip_callback(:create, :after, :create_delinquency_tracker!)
|
||||||
Comment.skip_callback(:create, :after_create_commit, :watch_card_by_creator)
|
Comment.skip_callback(:commit, :after, :watch_card_by_creator)
|
||||||
Mention.skip_callback(:create, :after_create_commit, :watch_source_by_mentionee)
|
Mention.skip_callback(:commit, :after, :watch_source_by_mentionee)
|
||||||
Mention.skip_callback(:create, :after_create_commit, :notify_recipients)
|
Notification.skip_callback(:commit, :after, :broadcast_unread)
|
||||||
Notification.skip_callback(:create, :after_create_commit, :broadcast_unread)
|
|
||||||
Notification.skip_callback(:create, :after, :bundle)
|
Notification.skip_callback(:create, :after, :bundle)
|
||||||
Notification.skip_callback(:create, :after_create_commit, :push_notification)
|
|
||||||
Reaction.skip_callback(:create, :after, :register_card_activity)
|
Reaction.skip_callback(:create, :after, :register_card_activity)
|
||||||
Card.skip_callback(:save, :before, :set_default_title)
|
Card.skip_callback(:save, :before, :set_default_title)
|
||||||
Card.skip_callback(:update, :after, :handle_board_change)
|
Card.skip_callback(:update, :after, :handle_board_change)
|
||||||
|
|
||||||
copy_entropies
|
# copy_entropies
|
||||||
copy_users
|
copy_users
|
||||||
copy_boards
|
copy_boards
|
||||||
copy_accesses
|
copy_accesses
|
||||||
@@ -54,6 +52,8 @@ class Import
|
|||||||
copy_notification_bundles
|
copy_notification_bundles
|
||||||
copy_filters
|
copy_filters
|
||||||
copy_events
|
copy_events
|
||||||
|
|
||||||
|
fix_links
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -63,6 +63,7 @@ class Import
|
|||||||
|
|
||||||
private
|
private
|
||||||
def setup_account
|
def setup_account
|
||||||
|
puts "⏩ Setting up account"
|
||||||
oldest_admin = import.users.order(id: :asc).where(role: :admin, active: true).first
|
oldest_admin = import.users.order(id: :asc).where(role: :admin, active: true).first
|
||||||
raise "No admin user found in the database" unless oldest_admin
|
raise "No admin user found in the database" unless oldest_admin
|
||||||
|
|
||||||
@@ -70,41 +71,46 @@ class Import
|
|||||||
account = import.accounts.sole
|
account = import.accounts.sole
|
||||||
|
|
||||||
new_identity = Identity.find_or_create_by!(email_address: membership.identity.email_address)
|
new_identity = Identity.find_or_create_by!(email_address: membership.identity.email_address)
|
||||||
new_membership = new_identity.memberships.create!(tenant: account.external_account_id.to_s)
|
new_membership = new_identity.memberships.find_or_create_by!(tenant: account.external_account_id.to_s)
|
||||||
|
|
||||||
signup = Signup.new(
|
if Account.all.exists?(external_account_id: account.external_account_id)
|
||||||
email_address: membership.identity.email_address,
|
@account = Account.find_by!(external_account_id: account.external_account_id)
|
||||||
full_name: oldest_admin.name,
|
@tenant = @account.external_account_id
|
||||||
account_name: account.name,
|
else
|
||||||
identity: new_identity,
|
@account = Account.create_with_admin_user(
|
||||||
membership_id: new_membership.signed_id(purpose: Signup::MEMBERSHIP_PURPOSE)
|
account: {
|
||||||
)
|
external_account_id: account.external_account_id.to_s,
|
||||||
|
name: account.name
|
||||||
unless signup.complete
|
},
|
||||||
raise "Failed to complete signup: #{signup.errors.full_messages.join(', ')}"
|
owner: {
|
||||||
|
name: oldest_admin.name,
|
||||||
|
membership_id: new_membership.id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@tenant = @account.external_account_id
|
||||||
end
|
end
|
||||||
|
|
||||||
@tenant = signup.tenant
|
|
||||||
@account = signup.account
|
|
||||||
|
|
||||||
old_join_code = import.account_join_codes.sole
|
old_join_code = import.account_join_codes.sole
|
||||||
|
|
||||||
attributes = {
|
attributes = {
|
||||||
usage_count: old_join_code.usage_count,
|
usage_count: old_join_code.usage_count,
|
||||||
usage_limit: old_join_code.usage_limit
|
usage_limit: old_join_code.usage_limit
|
||||||
}
|
}
|
||||||
attributes[:code] = old_join_code.code unless Account::JoinCode.exist?(code: old_join_code.code)
|
attributes[:code] = old_join_code.code unless Account::JoinCode.all.exists?(code: old_join_code.code)
|
||||||
|
|
||||||
account.join_code.update_columns(**attributes)
|
@account.join_code.update_columns(**attributes)
|
||||||
|
puts "✅ Account set up!"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_users
|
def copy_users
|
||||||
|
puts "⏩ Copying users"
|
||||||
|
mapping[:users] ||= {}
|
||||||
import.users.find_each do |old_user|
|
import.users.find_each do |old_user|
|
||||||
new_membership = nil
|
new_membership = nil
|
||||||
|
|
||||||
if user.active
|
if old_user.active && old_user.membership_id
|
||||||
membership = untenanted.memberships.find(old_user.membership_id)
|
membership = untenanted.memberships.find(old_user.membership_id)
|
||||||
new_identity = Identity.find_or_create_by!(email_address: identity.email_address)
|
new_identity = Identity.find_or_create_by!(email_address: membership.identity.email_address)
|
||||||
new_membership = new_identity.memberships.find_or_create_by!(tenant: tenant)
|
new_membership = new_identity.memberships.find_or_create_by!(tenant: tenant)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -122,12 +128,14 @@ class Import
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mapping[:users] ||= {}
|
|
||||||
mapping[:users][old_user.id] = new_user.id
|
mapping[:users][old_user.id] = new_user.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:users].size} users"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_boards
|
def copy_boards
|
||||||
|
puts "⏩ Copying boards"
|
||||||
|
mapping[:boards] ||= {}
|
||||||
import.boards.find_each do |old_board|
|
import.boards.find_each do |old_board|
|
||||||
new_board = Board.create!(
|
new_board = Board.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -148,12 +156,15 @@ class Import
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
mapping[:boards] ||= {}
|
|
||||||
mapping[:boards][old_board.id] = new_board.id
|
mapping[:boards][old_board.id] = new_board.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:boards].size} boards"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_columns
|
def copy_columns
|
||||||
|
puts "⏩ Copying columns"
|
||||||
|
mapping[:columns] ||= {}
|
||||||
|
|
||||||
import.columns.find_each do |old_column|
|
import.columns.find_each do |old_column|
|
||||||
new_column = Column.create!(
|
new_column = Column.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -165,12 +176,14 @@ class Import
|
|||||||
updated_at: old_column.updated_at
|
updated_at: old_column.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:columns] ||= {}
|
|
||||||
mapping[:columns][old_column.id] = new_column.id
|
mapping[:columns][old_column.id] = new_column.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:columns].size} columns"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_cards
|
def copy_cards
|
||||||
|
puts "⏩ Copying cards"
|
||||||
|
mapping[:cards] ||= {}
|
||||||
import.cards.find_each do |old_card|
|
import.cards.find_each do |old_card|
|
||||||
new_card = Card.create!(
|
new_card = Card.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -228,7 +241,6 @@ class Import
|
|||||||
|
|
||||||
old_card.assignments.each do |old_assignment|
|
old_card.assignments.each do |old_assignment|
|
||||||
Assignment.create!(
|
Assignment.create!(
|
||||||
account_id: account.id,
|
|
||||||
card_id: new_card.id,
|
card_id: new_card.id,
|
||||||
assignee_id: mapping[:users][old_assignment.assignee_id],
|
assignee_id: mapping[:users][old_assignment.assignee_id],
|
||||||
assigner_id: mapping[:users][old_assignment.assigner_id],
|
assigner_id: mapping[:users][old_assignment.assigner_id],
|
||||||
@@ -240,7 +252,6 @@ class Import
|
|||||||
old_closure = old_card.closure
|
old_closure = old_card.closure
|
||||||
if old_closure
|
if old_closure
|
||||||
Closure.create!(
|
Closure.create!(
|
||||||
account_id: account.id,
|
|
||||||
card_id: new_card.id,
|
card_id: new_card.id,
|
||||||
user_id: old_closure.user_id ? mapping[:users][old_closure.user_id] : nil,
|
user_id: old_closure.user_id ? mapping[:users][old_closure.user_id] : nil,
|
||||||
created_at: old_closure.created_at,
|
created_at: old_closure.created_at,
|
||||||
@@ -248,12 +259,13 @@ class Import
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
mapping[:cards] ||= {}
|
|
||||||
mapping[:cards][old_card.id] = new_card.id
|
mapping[:cards][old_card.id] = new_card.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:cards].size} cards"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_steps
|
def copy_steps
|
||||||
|
puts "⏩ Copying steps"
|
||||||
import.steps.find_each do |old_step|
|
import.steps.find_each do |old_step|
|
||||||
Step.create!(
|
Step.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -264,9 +276,12 @@ class Import
|
|||||||
updated_at: old_step.updated_at
|
updated_at: old_step.updated_at
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied steps"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_comments
|
def copy_comments
|
||||||
|
puts "⏩ Copying comments"
|
||||||
|
mapping[:comments] ||= {}
|
||||||
import.comments.find_each do |old_comment|
|
import.comments.find_each do |old_comment|
|
||||||
new_comment = Comment.create!(
|
new_comment = Comment.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -278,12 +293,14 @@ class Import
|
|||||||
|
|
||||||
copy_rich_text(old_comment, new_comment, "Comment", "body")
|
copy_rich_text(old_comment, new_comment, "Comment", "body")
|
||||||
|
|
||||||
mapping[:comments] ||= {}
|
|
||||||
mapping[:comments][old_comment.id] = new_comment.id
|
mapping[:comments][old_comment.id] = new_comment.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:comments].size} comments"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_mentions
|
def copy_mentions
|
||||||
|
puts "⏩ Copying mentions"
|
||||||
|
mapping[:mentions] ||= {}
|
||||||
import.mentions.find_each do |old_mention|
|
import.mentions.find_each do |old_mention|
|
||||||
new_mention = Mention.create!(
|
new_mention = Mention.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -295,29 +312,34 @@ class Import
|
|||||||
updated_at: old_mention.updated_at
|
updated_at: old_mention.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:mentions] ||= {}
|
|
||||||
mapping[:mentions][old_mention.id] = new_mention.id
|
mapping[:mentions][old_mention.id] = new_mention.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:mentions].size} mentions"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_accesses
|
def copy_accesses
|
||||||
|
puts "⏩ Copying accesses"
|
||||||
import.accesses.find_each do |old_access|
|
import.accesses.find_each do |old_access|
|
||||||
new_access = Access.create!(
|
new_access = Access.find_or_create_by!(
|
||||||
account_id: account.id,
|
|
||||||
board_id: mapping[:boards][old_access.board_id],
|
board_id: mapping[:boards][old_access.board_id],
|
||||||
user_id: mapping[:users][old_access.user_id],
|
user_id: mapping[:users][old_access.user_id]
|
||||||
involvement: old_access.involvement,
|
) do |access|
|
||||||
accessed_at: old_access.accessed_at,
|
access.involvement = old_access.involvement
|
||||||
created_at: old_access.created_at,
|
access.accessed_at = old_access.accessed_at
|
||||||
updated_at: old_access.updated_at
|
access.created_at = old_access.created_at
|
||||||
)
|
access.updated_at = old_access.updated_at
|
||||||
|
end
|
||||||
|
|
||||||
mapping[:accesses] ||= {}
|
mapping[:accesses] ||= {}
|
||||||
mapping[:accesses][old_access.id] = new_access.id
|
mapping[:accesses][old_access.id] = new_access.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:accesses].size} accesses"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_notifications
|
def copy_notifications
|
||||||
|
puts "⏩ Copying notifications"
|
||||||
|
mapping[:notifications] ||= {}
|
||||||
|
|
||||||
import.notifications.find_each do |old_notification|
|
import.notifications.find_each do |old_notification|
|
||||||
new_notification = Notification.create!(
|
new_notification = Notification.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -330,12 +352,15 @@ class Import
|
|||||||
updated_at: old_notification.updated_at
|
updated_at: old_notification.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:notifications] ||= {}
|
|
||||||
mapping[:notifications][old_notification.id] = new_notification.id
|
mapping[:notifications][old_notification.id] = new_notification.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:notifications].size} notifications"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_notification_bundles
|
def copy_notification_bundles
|
||||||
|
puts "⏩ Copying notification bundles"
|
||||||
|
mapping[:notification_bundles] ||= {}
|
||||||
|
|
||||||
import.notification_bundles.find_each do |old_bundle|
|
import.notification_bundles.find_each do |old_bundle|
|
||||||
new_bundle = Notification::Bundle.create!(
|
new_bundle = Notification::Bundle.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -347,12 +372,13 @@ class Import
|
|||||||
updated_at: old_bundle.updated_at
|
updated_at: old_bundle.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:notification_bundles] ||= {}
|
|
||||||
mapping[:notification_bundles][old_bundle.id] = new_bundle.id
|
mapping[:notification_bundles][old_bundle.id] = new_bundle.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:notification_bundles].size} notification bundles"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_entropies
|
def copy_entropies
|
||||||
|
puts "⏩ Copying entropies"
|
||||||
import.entropies.find_each do |old_entropy|
|
import.entropies.find_each do |old_entropy|
|
||||||
container_id = case old_entropy.container_type
|
container_id = case old_entropy.container_type
|
||||||
when "Account" then account.id
|
when "Account" then account.id
|
||||||
@@ -369,9 +395,13 @@ class Import
|
|||||||
updated_at: old_entropy.updated_at
|
updated_at: old_entropy.updated_at
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied entropies"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_filters
|
def copy_filters
|
||||||
|
puts "⏩ Copying filters"
|
||||||
|
mapping[:filters] ||= {}
|
||||||
|
|
||||||
import.filters.find_each do |old_filter|
|
import.filters.find_each do |old_filter|
|
||||||
new_filter = Filter.create!(
|
new_filter = Filter.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -406,12 +436,13 @@ class Import
|
|||||||
FiltersTag.find_or_create_by!(filter_id: new_filter.id, tag_id: mapping[:tags][join.tag_id])
|
FiltersTag.find_or_create_by!(filter_id: new_filter.id, tag_id: mapping[:tags][join.tag_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
mapping[:filters] ||= {}
|
|
||||||
mapping[:filters][old_filter.id] = new_filter.id
|
mapping[:filters][old_filter.id] = new_filter.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:filters].size} filters"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_events
|
def copy_events
|
||||||
|
puts "⏩ Copying events"
|
||||||
import.events.find_each do |old_event|
|
import.events.find_each do |old_event|
|
||||||
new_event = Event.create!(
|
new_event = Event.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -428,6 +459,7 @@ class Import
|
|||||||
mapping[:events] ||= {}
|
mapping[:events] ||= {}
|
||||||
mapping[:events][old_event.id] = new_event.id
|
mapping[:events][old_event.id] = new_event.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:events].size} events"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_rich_text(old_record, new_record, record_type, name)
|
def copy_rich_text(old_record, new_record, record_type, name)
|
||||||
@@ -478,6 +510,8 @@ class Import
|
|||||||
end
|
end
|
||||||
|
|
||||||
def copy_reactions
|
def copy_reactions
|
||||||
|
puts "⏩ Copying reactions"
|
||||||
|
mapping[:reactions] ||= {}
|
||||||
import.reactions.find_each do |old_reaction|
|
import.reactions.find_each do |old_reaction|
|
||||||
new_reaction = Reaction.create!(
|
new_reaction = Reaction.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -488,12 +522,16 @@ class Import
|
|||||||
updated_at: old_reaction.updated_at
|
updated_at: old_reaction.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:reactions] ||= {}
|
|
||||||
mapping[:reactions][old_reaction.id] = new_reaction.id
|
mapping[:reactions][old_reaction.id] = new_reaction.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:reactions].size} reactions"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_tags
|
def copy_tags
|
||||||
|
puts "⏩ Copying tags"
|
||||||
|
mapping[:tags] ||= {}
|
||||||
|
mapping[:taggings] ||= {}
|
||||||
|
|
||||||
import.tags.find_each do |old_tag|
|
import.tags.find_each do |old_tag|
|
||||||
new_tag = Tag.find_or_create_by!(title: old_tag.title) do |t|
|
new_tag = Tag.find_or_create_by!(title: old_tag.title) do |t|
|
||||||
t.account_id = account.id
|
t.account_id = account.id
|
||||||
@@ -501,28 +539,28 @@ class Import
|
|||||||
t.updated_at = old_tag.updated_at
|
t.updated_at = old_tag.updated_at
|
||||||
end
|
end
|
||||||
|
|
||||||
mapping[:tags] ||= {}
|
|
||||||
mapping[:tags][old_tag.id] = new_tag.id
|
mapping[:tags][old_tag.id] = new_tag.id
|
||||||
end
|
end
|
||||||
|
|
||||||
import.taggings.find_each do |old_tagging|
|
import.taggings.find_each do |old_tagging|
|
||||||
new_tagging = Tagging.create!(
|
new_tagging = Tagging.create!(
|
||||||
account_id: account.id,
|
|
||||||
tag_id: mapping[:tags][old_tagging.tag_id],
|
tag_id: mapping[:tags][old_tagging.tag_id],
|
||||||
card_id: mapping[:cards][old_tagging.card_id],
|
card_id: mapping[:cards][old_tagging.card_id],
|
||||||
created_at: old_tagging.created_at,
|
created_at: old_tagging.created_at,
|
||||||
updated_at: old_tagging.updated_at
|
updated_at: old_tagging.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:taggings] ||= {}
|
|
||||||
mapping[:taggings][old_tagging.id] = new_tagging.id
|
mapping[:taggings][old_tagging.id] = new_tagging.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:tags].size} tags and #{mapping[:taggings].size} taggings"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_watches
|
def copy_watches
|
||||||
|
puts "⏩ Copying watches"
|
||||||
|
mapping[:watches] ||= {}
|
||||||
|
|
||||||
import.watches.find_each do |old_watch|
|
import.watches.find_each do |old_watch|
|
||||||
new_watch = Watch.create!(
|
new_watch = Watch.create!(
|
||||||
account_id: account.id,
|
|
||||||
user_id: mapping[:users][old_watch.user_id],
|
user_id: mapping[:users][old_watch.user_id],
|
||||||
card_id: mapping[:cards][old_watch.card_id],
|
card_id: mapping[:cards][old_watch.card_id],
|
||||||
watching: old_watch.watching,
|
watching: old_watch.watching,
|
||||||
@@ -530,27 +568,33 @@ class Import
|
|||||||
updated_at: old_watch.updated_at
|
updated_at: old_watch.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:watches] ||= {}
|
|
||||||
mapping[:watches][old_watch.id] = new_watch.id
|
mapping[:watches][old_watch.id] = new_watch.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:watches].size} watches"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_pins
|
def copy_pins
|
||||||
|
puts "⏩ Copying pins"
|
||||||
|
mapping[:pins] ||= {}
|
||||||
|
|
||||||
import.pins.find_each do |old_pin|
|
import.pins.find_each do |old_pin|
|
||||||
new_pin = Pin.create!(
|
new_pin = Pin.create!(
|
||||||
account_id: account.id,
|
|
||||||
user_id: mapping[:users][old_pin.user_id],
|
user_id: mapping[:users][old_pin.user_id],
|
||||||
card_id: mapping[:cards][old_pin.card_id],
|
card_id: mapping[:cards][old_pin.card_id],
|
||||||
created_at: old_pin.created_at,
|
created_at: old_pin.created_at,
|
||||||
updated_at: old_pin.updated_at
|
updated_at: old_pin.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:pins] ||= {}
|
|
||||||
mapping[:pins][old_pin.id] = new_pin.id
|
mapping[:pins][old_pin.id] = new_pin.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:pins].size} pins"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_webhooks
|
def copy_webhooks
|
||||||
|
puts "⏩ Copying webhooks"
|
||||||
|
mapping[:webhooks] ||= {}
|
||||||
|
mapping[:webhook_deliveries] ||= {}
|
||||||
|
|
||||||
import.webhooks.find_each do |old_webhook|
|
import.webhooks.find_each do |old_webhook|
|
||||||
new_webhook = Webhook.create!(
|
new_webhook = Webhook.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -564,7 +608,6 @@ class Import
|
|||||||
updated_at: old_webhook.updated_at
|
updated_at: old_webhook.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:webhooks] ||= {}
|
|
||||||
mapping[:webhooks][old_webhook.id] = new_webhook.id
|
mapping[:webhooks][old_webhook.id] = new_webhook.id
|
||||||
|
|
||||||
old_tracker = import.webhook_delinquency_trackers.find_by(webhook_id: old_webhook.id)
|
old_tracker = import.webhook_delinquency_trackers.find_by(webhook_id: old_webhook.id)
|
||||||
@@ -588,12 +631,15 @@ class Import
|
|||||||
updated_at: old_delivery.updated_at
|
updated_at: old_delivery.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:webhook_deliveries] ||= {}
|
|
||||||
mapping[:webhook_deliveries][old_delivery.id] = new_delivery.id
|
mapping[:webhook_deliveries][old_delivery.id] = new_delivery.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:webhooks].size} webhooks and #{mapping[:webhook_deliveries].size} deliveries"
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_push_subscriptions
|
def copy_push_subscriptions
|
||||||
|
puts "⏩ Copying push subscriptions"
|
||||||
|
mapping[:push_subscriptions] ||= {}
|
||||||
|
|
||||||
import.push_subscriptions.find_each do |old_subscription|
|
import.push_subscriptions.find_each do |old_subscription|
|
||||||
new_subscription = Push::Subscription.create!(
|
new_subscription = Push::Subscription.create!(
|
||||||
account_id: account.id,
|
account_id: account.id,
|
||||||
@@ -606,9 +652,14 @@ class Import
|
|||||||
updated_at: old_subscription.updated_at
|
updated_at: old_subscription.updated_at
|
||||||
)
|
)
|
||||||
|
|
||||||
mapping[:push_subscriptions] ||= {}
|
|
||||||
mapping[:push_subscriptions][old_subscription.id] = new_subscription.id
|
mapping[:push_subscriptions][old_subscription.id] = new_subscription.id
|
||||||
end
|
end
|
||||||
|
puts "✅ Copied #{mapping[:push_subscriptions].size} push subscriptions"
|
||||||
|
end
|
||||||
|
|
||||||
|
def fix_links
|
||||||
|
puts "⏩ Fixing links"
|
||||||
|
puts "✅ Fixed #{mapping[:cards].size} links"
|
||||||
end
|
end
|
||||||
|
|
||||||
def import
|
def import
|
||||||
|
|||||||
Reference in New Issue
Block a user