add pghero to rails app, dymk fork

This commit is contained in:
Dylan Knutson
2023-05-19 17:14:35 -07:00
parent ff8e539579
commit c424b7dacd
6 changed files with 66 additions and 1 deletions

View File

@@ -108,6 +108,9 @@ gem "concurrent-ruby-edge", require: "concurrent-edge"
gem "pluck_each"
gem "good_job"
gem "pg_query", ">= 2"
gem "pghero", git: "https://github.com/dymk/pghero", ref: "e314f99"
gem "neighbor"
gem "disco"
gem "faiss"

View File

@@ -1,3 +1,11 @@
GIT
remote: https://github.com/dymk/pghero
revision: e314f9999f83116448085a66d3a806e8296bd4bf
ref: e314f99
specs:
pghero (3.3.3)
activerecord (>= 6)
PATH
remote: ../rb-bsdiff
specs:
@@ -139,6 +147,7 @@ GEM
railties (>= 6.0.0)
thor (>= 0.14.1)
webrick (>= 1.3)
google-protobuf (3.23.1)
htmlbeautifier (1.4.2)
http-cookie (1.0.5)
domain_name (~> 0.5)
@@ -198,6 +207,8 @@ GEM
racc (~> 1.4)
numo-narray (0.9.2.1)
pg (1.4.5)
pg_query (4.2.1)
google-protobuf (>= 3.22.3)
pluck_each (0.2.0)
activerecord (> 3.2.0)
activesupport (> 3.0.0)
@@ -372,6 +383,8 @@ DEPENDENCIES
neighbor
nokogiri
pg
pg_query (>= 2)
pghero!
pluck_each
progressbar
pry

View File

@@ -13,6 +13,7 @@ Rails.application.routes.draw do
get "us/:script", to: "user_scripts#get", constraints: { script: /.*/ }
scope constraints: VpnOnlyRouteConstraint.new do
mount PgHero::Engine => "pghero"
mount GoodJob::Engine => "jobs"
namespace :api do
get "search/user/:prefix", to: "search#user"

View File

@@ -0,0 +1,15 @@
class CreatePgheroQueryStats < ActiveRecord::Migration[7.0]
def change
create_table :pghero_query_stats do |t|
t.text :database
t.text :user
t.text :query
t.integer :query_hash, limit: 8
t.float :total_time
t.integer :calls, limit: 8
t.timestamp :captured_at
end
add_index :pghero_query_stats, [:database, :captured_at]
end
end

View File

@@ -0,0 +1,13 @@
class CreatePgheroSpaceStats < ActiveRecord::Migration[7.0]
def change
create_table :pghero_space_stats do |t|
t.text :database
t.text :schema
t.text :relation
t.integer :size, limit: 8
t.timestamp :captured_at
end
add_index :pghero_space_stats, [:database, :captured_at]
end
end

22
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[7.0].define(version: 2023_05_19_233707) do
ActiveRecord::Schema[7.0].define(version: 2023_05_20_001257) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
@@ -1017,6 +1017,26 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_19_233707) do
t.index ["key"], name: "index_log_store_sst_entries_on_key", unique: true
end
create_table "pghero_query_stats", force: :cascade do |t|
t.text "database"
t.text "user"
t.text "query"
t.bigint "query_hash"
t.float "total_time"
t.bigint "calls"
t.datetime "captured_at", precision: nil
t.index ["database", "captured_at"], name: "index_pghero_query_stats_on_database_and_captured_at"
end
create_table "pghero_space_stats", force: :cascade do |t|
t.text "database"
t.text "schema"
t.text "relation"
t.bigint "size"
t.datetime "captured_at", precision: nil
t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at"
end
create_table "versions", force: :cascade do |t|
t.string "item_type", null: false
t.bigint "item_id", null: false