Add active_until to users

This commit is contained in:
Eugene Burmakin 2025-04-04 20:27:46 +02:00
parent af8af43bcd
commit 2f41b0dd57
4 changed files with 25 additions and 2 deletions

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
class SetActiveUntilForSelfhostedUsers < ActiveRecord::Migration[8.0]
def up
return unless DawarichSettings.self_hosted?
# rubocop:disable Rails/SkipsModelValidations
User.where(active_until: nil).update_all(active_until: 1000.years.from_now)
# rubocop:enable Rails/SkipsModelValidations
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -1 +1 @@
DataMigrate::Data.define(version: 20250403204658)
DataMigrate::Data.define(version: 20250404182629)

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddActiveUntilToUsers < ActiveRecord::Migration[8.0]
def change
add_column :users, :active_until, :datetime
end
end

3
db/schema.rb generated
View file

@ -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_24_180755) do
ActiveRecord::Schema[8.0].define(version: 2025_04_04_182437) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
enable_extension "postgis"
@ -230,6 +230,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_24_180755) do
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "status", default: 0
t.datetime "active_until"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end