diff --git a/db/migrate/20250122204932_create_pghero_stats_tables.rb b/db/migrate/20250122204932_create_pghero_stats_tables.rb new file mode 100644 index 0000000..e3a541c --- /dev/null +++ b/db/migrate/20250122204932_create_pghero_stats_tables.rb @@ -0,0 +1,21 @@ +class CreatePgheroStatsTables < ActiveRecord::Migration[8.0] + def up + execute <<~SQL + CREATE TABLE "pghero_query_stats" ( + "id" bigserial primary key, + "database" text, + "user" text, + "query" text, + "query_hash" bigint, + "total_time" float, + "calls" bigint, + "captured_at" timestamp + ); + CREATE INDEX ON "pghero_query_stats" ("database", "captured_at"); + SQL + end + + def down + drop_table :pghero_query_stats, if_exists: true, force: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index 197a8b1..03f31cb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_01_22_202836) do +ActiveRecord::Schema[8.0].define(version: 2025_01_22_204932) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" enable_extension "pg_stat_statements" @@ -68,6 +68,17 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_22_202836) do t.index ["wedding_id"], name: "index_guests_on_wedding_id" 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: "pghero_query_stats_database_captured_at_idx" + end + create_table "seats", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "guest_id", null: false t.uuid "tables_arrangement_id", null: false