Skip to content

Commit 2c57921

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Migrate existing open_registrations setting to the new registrations_mode (mastodon#10269)
* Migrate existing `open_registrations` setting to the new `registrations_mode` Fixes mastodon#10263 * Remove unrelated db changes that have creeped in
1 parent 5c71049 commit 2c57921

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2]
2+
def up
3+
open_registrations = Setting.find_by(var: 'open_registrations')
4+
return if open_registrations.nil? || open_registrations.value
5+
setting = Setting.where(var: 'registrations_mode').first_or_initialize(var: 'registrations_mode')
6+
setting.update(value: 'none')
7+
end
8+
9+
def down
10+
registrations_mode = Setting.find_by(var: 'registrations_mode')
11+
return if registrations_mode.nil?
12+
setting = Setting.where(var: 'open_registrations').first_or_initialize(var: 'open_registrations')
13+
setting.update(value: registrations_mode.value == 'open')
14+
end
15+
end

db/schema.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2019_03_07_234537) do
13+
ActiveRecord::Schema.define(version: 2019_03_14_181829) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -36,19 +36,6 @@
3636
t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
3737
end
3838

39-
create_table "account_identity_proofs", force: :cascade do |t|
40-
t.bigint "account_id"
41-
t.string "provider", null: false
42-
t.string "provider_username", null: false
43-
t.text "token", null: false
44-
t.boolean "proof_valid"
45-
t.boolean "proof_live"
46-
t.datetime "created_at", null: false
47-
t.datetime "updated_at", null: false
48-
t.index ["account_id", "provider", "provider_username"], name: "index_account_proofs_on_account_and_provider_and_username", unique: true
49-
t.index ["account_id"], name: "index_account_identity_proofs_on_account_id"
50-
end
51-
5239
create_table "account_moderation_notes", force: :cascade do |t|
5340
t.text "content", null: false
5441
t.bigint "account_id", null: false

0 commit comments

Comments
 (0)