refactor: ⚡ Username and slug unique indexes, before actions for set link and user
confirm_password_validation around action, unnecessary helpers removed, rubocop-rails suggestions applied Add username index and unique slug index migrations
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddUsernameIndexToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :users, :username, unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UniqueSlugIndex < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_index :links, column: :slug
|
||||
add_index :links, :slug, unique: true
|
||||
end
|
||||
end
|
||||
+19
-19
@@ -1,5 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
@@ -12,27 +10,29 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20_210_614_114_837) do
|
||||
ActiveRecord::Schema.define(version: 2021_06_15_200050) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension 'plpgsql'
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table 'links', force: :cascade do |t|
|
||||
t.string 'slug', null: false
|
||||
t.text 'url'
|
||||
t.integer 'click_counter', default: 0
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
t.bigint 'user_id'
|
||||
t.index ['slug'], name: 'index_links_on_slug'
|
||||
t.index ['user_id'], name: 'index_links_on_user_id'
|
||||
create_table "links", force: :cascade do |t|
|
||||
t.string "slug", null: false
|
||||
t.text "url"
|
||||
t.integer "click_counter", default: 0
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id"
|
||||
t.index ["slug"], name: "index_links_on_slug", unique: true
|
||||
t.index ["user_id"], name: "index_links_on_user_id"
|
||||
end
|
||||
|
||||
create_table 'users', force: :cascade do |t|
|
||||
t.string 'username'
|
||||
t.string 'password_digest'
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "username"
|
||||
t.string "password_digest"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["username"], name: "index_users_on_username", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key 'links', 'users'
|
||||
add_foreign_key "links", "users"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user