From 6e330d2b2a73911f227a627b9293996ed54cea3c Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 31 Mar 2025 14:15:50 +0200 Subject: [PATCH] Add `id_scheme` attribute to `Account` --- app/models/account.rb | 7 ++----- db/migrate/20250331120259_add_id_scheme_to_accounts.rb | 7 +++++++ db/schema.rb | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20250331120259_add_id_scheme_to_accounts.rb diff --git a/app/models/account.rb b/app/models/account.rb index c113b8fc16..d9d28c8993 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -51,6 +51,7 @@ # requested_review_at :datetime # indexable :boolean default(FALSE), not null # attribution_domains :string default([]), is an Array +# id_scheme :integer default("username_ap_id") # class Account < ApplicationRecord @@ -102,6 +103,7 @@ class Account < ApplicationRecord enum :protocol, { ostatus: 0, activitypub: 1 } enum :suspension_origin, { local: 0, remote: 1 }, prefix: true + enum :id_scheme, { username_ap_id: 0, numeric_ap_id: 1 } validates :username, presence: true validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? } @@ -184,11 +186,6 @@ class Account < ApplicationRecord update_index('accounts', :self) - def numeric_ap_id? - # TODO: this is a placeholder for now - false - end - def local? domain.nil? end diff --git a/db/migrate/20250331120259_add_id_scheme_to_accounts.rb b/db/migrate/20250331120259_add_id_scheme_to_accounts.rb new file mode 100644 index 0000000000..7dd987dcc0 --- /dev/null +++ b/db/migrate/20250331120259_add_id_scheme_to_accounts.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddIdSchemeToAccounts < ActiveRecord::Migration[8.0] + def change + add_column :accounts, :id_scheme, :integer, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 26db259464..a3ee64e948 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_03_13_123400) do +ActiveRecord::Schema[8.0].define(version: 2025_03_31_120259) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -198,6 +198,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_13_123400) do t.datetime "requested_review_at", precision: nil t.boolean "indexable", default: false, null: false t.string "attribution_domains", default: [], array: true + t.integer "id_scheme", default: 0 t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true t.index ["domain", "id"], name: "index_accounts_on_domain_and_id"