Skip to content

Commit

Permalink
Merge pull request #14633 from eduardoj/refactoring/remove_unused_use…
Browse files Browse the repository at this point in the history
…r_registrations

Drop unused `user_registrations` table
  • Loading branch information
eduardoj committed Jul 13, 2023
2 parents 1e00d78 + 716959e commit f862510
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
15 changes: 0 additions & 15 deletions src/api/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class User < ApplicationRecord
has_many :bs_request_actions_seen_by_users, dependent: :nullify
has_many :bs_request_actions_seen, through: :bs_request_actions_seen_by_users, source: :bs_request_action

# users have 0..1 user_registration records assigned to them
has_one :user_registration

has_one :ec2_configuration, class_name: 'Cloud::Ec2::Configuration', dependent: :destroy
has_one :azure_configuration, class_name: 'Cloud::Azure::Configuration', dependent: :destroy
has_many :upload_jobs, class_name: 'Cloud::User::UploadJob', dependent: :destroy
Expand Down Expand Up @@ -314,18 +311,6 @@ def has_role?(*role_titles)
!obj.nil?
end

# This method creates a new registration token for the current user. Raises
# a MultipleRegistrationTokens Exception if the user already has a
# registration token assigned to him.
#
# Use this method instead of creating user_registration objects directly!
def create_user_registration
raise unless user_registration.nil?

token = UserRegistration.new
self.user_registration = token
end

# This method checks whether the given value equals the password when
# hashed with this user's password hash type. Returns a boolean.
def deprecated_password_equals?(value)
Expand Down
9 changes: 9 additions & 0 deletions src/api/db/migrate/20230712141001_drop_user_registrations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class DropUserRegistrations < ActiveRecord::Migration[7.0]
def up
drop_table :user_registrations
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
12 changes: 1 addition & 11 deletions src/api/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_06_26_092852) do
ActiveRecord::Schema[7.0].define(version: 2023_07_12_141001) do
create_table "architectures", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.string "name", null: false, collation: "utf8mb3_general_ci"
t.boolean "available", default: false
Expand Down Expand Up @@ -1046,15 +1046,6 @@
t.integer "counter", default: 0
end

create_table "user_registrations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.integer "user_id", default: 0, null: false
t.text "token", null: false, collation: "utf8mb3_general_ci"
t.datetime "created_at", precision: nil
t.datetime "expires_at", precision: nil
t.index ["expires_at"], name: "user_registrations_expires_at_index"
t.index ["user_id"], name: "user_registrations_user_id_index", unique: true
end

create_table "users", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.datetime "created_at", precision: nil
t.datetime "updated_at"
Expand Down Expand Up @@ -1232,6 +1223,5 @@
add_foreign_key "status_checks", "status_reports", column: "status_reports_id"
add_foreign_key "tokens", "packages", name: "tokens_ibfk_2"
add_foreign_key "tokens", "users", column: "executor_id", name: "tokens_ibfk_1"
add_foreign_key "user_registrations", "users", name: "user_registrations_ibfk_1"
add_foreign_key "watched_projects", "users", name: "watched_projects_ibfk_1"
end

0 comments on commit f862510

Please sign in to comment.