mirror of
https://github.com/docusealco/docuseal.git
synced 2026-06-23 04:10:11 +00:00
add uuid to accounts
This commit is contained in:
@@ -8,10 +8,17 @@
|
||||
# locale :string not null
|
||||
# name :string not null
|
||||
# timezone :string not null
|
||||
# uuid :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_accounts_on_uuid (uuid) UNIQUE
|
||||
#
|
||||
class Account < ApplicationRecord
|
||||
attribute :uuid, :string, default: -> { SecureRandom.uuid }
|
||||
|
||||
has_many :users, dependent: :destroy
|
||||
has_many :encrypted_configs, dependent: :destroy
|
||||
has_many :account_configs, dependent: :destroy
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddUuidToAccounts < ActiveRecord::Migration[7.1]
|
||||
class MigrationAccount < ApplicationRecord
|
||||
self.table_name = 'accounts'
|
||||
end
|
||||
|
||||
def up
|
||||
add_column :accounts, :uuid, :string
|
||||
|
||||
MigrationAccount.all.each do |account|
|
||||
account.update_columns(uuid: SecureRandom.uuid)
|
||||
end
|
||||
|
||||
add_index :accounts, :uuid, unique: true
|
||||
|
||||
change_column_null :accounts, :uuid, false
|
||||
end
|
||||
|
||||
def down
|
||||
drop_column :account, :uuid
|
||||
end
|
||||
end
|
||||
+3
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_02_28_083356) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_04_05_165329) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -51,6 +51,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_28_083356) do
|
||||
t.string "locale", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "uuid", null: false
|
||||
t.index ["uuid"], name: "index_accounts_on_uuid", unique: true
|
||||
end
|
||||
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
|
||||
Reference in New Issue
Block a user