Browse Source

Add index for date in table diffs

master
Norore 1 year ago
parent
commit
b284e3a2e0
2 changed files with 11 additions and 1 deletions
  1. +9
    -0
      db/migrate/20190120155929_add_creation_day_index_to_diffs.rb
  2. +2
    -1
      db/schema.rb

+ 9
- 0
db/migrate/20190120155929_add_creation_day_index_to_diffs.rb View File

@@ -0,0 +1,9 @@
class AddCreationDayIndexToDiffs < ActiveRecord::Migration[5.2]
def up
add_index :diffs, "date_trunc('day', created_at) DESC", name: "diffs_creation_day_index"
end

def down
remove_index :diffs, name: "diffs_creation_day_index"
end
end

+ 2
- 1
db/schema.rb View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2018_11_27_204747) do
ActiveRecord::Schema.define(version: 2019_01_20_155929) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -19,6 +19,7 @@ ActiveRecord::Schema.define(version: 2018_11_27_204747) do
t.json "content", null: false
t.bigint "site_id", null: false
t.datetime "created_at", null: false
t.index "date_trunc('day'::text, created_at) DESC", name: "diffs_creation_day_index"
t.index ["site_id"], name: "index_diffs_on_site_id"
end



Loading…
Cancel
Save