From 755201561ee08e4b9ad26d37e929f2ee57a24bbc Mon Sep 17 00:00:00 2001 From: Ryan Romanchuk Date: Sat, 30 Dec 2023 19:06:34 -0600 Subject: [PATCH] cp --- .../app/controllers/tds/batches_controller.rb | 20 +- personal/app/models/attachment.rb | 2 +- personal/app/models/blob.rb | 2 +- personal/app/models/legacy_record.rb | 9 - personal/app/models/post.rb | 2 +- personal/config/database.yml | 30 +- personal/db/legacy_structure.sql | 639 ------------------ ...231231003512_create_pghero_query_stats.rb} | 2 +- ...231231003521_create_pghero_space_stats.rb} | 2 +- .../db/migrate/20231231005449_add_pg_stats.rb | 5 + personal/db/ro/20231231010416_add_pg_stats.rb | 6 + personal/db/ro_structure.sql | 17 + .../20231231005814_add_pg_stats.rb | 5 + personal/db/ryan_romanchuk_structure.sql | 135 ++-- personal/db/structure.sql | 528 +++++++++++---- .../wx/20231231003005_remove_query_stats.rb | 6 + personal/db/wx/20231231005753_add_pg_stats.rb | 5 + personal/db/wx_structure.sql | 135 +--- 18 files changed, 570 insertions(+), 980 deletions(-) delete mode 100644 personal/app/models/legacy_record.rb delete mode 100644 personal/db/legacy_structure.sql rename personal/db/migrate/{20220908030103_create_pghero_query_stats.rb => 20231231003512_create_pghero_query_stats.rb} (84%) rename personal/db/migrate/{20220908030135_create_pghero_space_stats.rb => 20231231003521_create_pghero_space_stats.rb} (81%) create mode 100644 personal/db/migrate/20231231005449_add_pg_stats.rb create mode 100644 personal/db/ro/20231231010416_add_pg_stats.rb create mode 100644 personal/db/ryan_romanchuk/20231231005814_add_pg_stats.rb create mode 100644 personal/db/wx/20231231003005_remove_query_stats.rb create mode 100644 personal/db/wx/20231231005753_add_pg_stats.rb diff --git a/personal/app/controllers/tds/batches_controller.rb b/personal/app/controllers/tds/batches_controller.rb index daf32209..1454050c 100644 --- a/personal/app/controllers/tds/batches_controller.rb +++ b/personal/app/controllers/tds/batches_controller.rb @@ -60,21 +60,23 @@ def process_csv private - def apply_filter(relation = Batch.all) + def apply_filter + relation = Batch.recent + case params[:filter] when 'metars' - relation.metars + relation = relation.metars when 'pireps' - relation.aircraftreports + relation = relation.aircraftreports when 'tafs' - relation.tafs + relation = relation.tafs when 'failed' - relation.failed + relation = relation.failed when 'pending' - relation.pending - else - relation - end.recent + relation = relation.pending + end + + relation end def apply_sort(relation) diff --git a/personal/app/models/attachment.rb b/personal/app/models/attachment.rb index beec9619..e7791cfb 100644 --- a/personal/app/models/attachment.rb +++ b/personal/app/models/attachment.rb @@ -1,4 +1,4 @@ -class Attachment < LegacyRecord +class Attachment < ApplicationRecord belongs_to :record, polymorphic: true, touch: true belongs_to :blob, autosave: true diff --git a/personal/app/models/blob.rb b/personal/app/models/blob.rb index 6dde0f59..5fd121e3 100644 --- a/personal/app/models/blob.rb +++ b/personal/app/models/blob.rb @@ -1,4 +1,4 @@ -class Blob < LegacyRecord +class Blob < ApplicationRecord include Taggable include Searchable include Sluggable diff --git a/personal/app/models/legacy_record.rb b/personal/app/models/legacy_record.rb deleted file mode 100644 index 21de3e0d..00000000 --- a/personal/app/models/legacy_record.rb +++ /dev/null @@ -1,9 +0,0 @@ -class LegacyRecord < ApplicationRecord - self.abstract_class = true - self.implicit_order_column = 'created_at' - - scope :oldest, ->(column = implicit_order_column) { order(column => :asc) } - scope :recent, ->(column = implicit_order_column) { order(column => :desc) } - scope :random, -> { order(Arel.sql('RANDOM()')) } - connects_to database: { writing: :legacy } -end \ No newline at end of file diff --git a/personal/app/models/post.rb b/personal/app/models/post.rb index 4989a346..b280417a 100644 --- a/personal/app/models/post.rb +++ b/personal/app/models/post.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Post < LegacyRecord +class Post < ApplicationRecord SEARCH_AGAINST = %i[title description markdown_content] include Sluggable diff --git a/personal/config/database.yml b/personal/config/database.yml index f3f946af..7f86c315 100644 --- a/personal/config/database.yml +++ b/personal/config/database.yml @@ -8,16 +8,16 @@ default: &default development: + primary: + <<: *default + database: personal_development + #username: postgres + host: localhost ryan_romanchuk: <<: *default database: ryan_romanchuk_development host: localhost migrations_paths: db/ryan_romanchuk - legacy: - <<: *default - database: personal_development - #username: postgres - host: localhost wx: <<: *default database: wx_development @@ -30,17 +30,17 @@ development: migrations_paths: db/ro test: - ryan_romanchuk: + primary: <<: *default - database: ryan_romanchuk_test + database: personal_test username: postgres host: localhost - migrations_paths: db/ryan_romanchuk - legacy: + ryan_romanchuk: <<: *default - database: personal_test + database: ryan_romanchuk_test username: postgres host: localhost + migrations_paths: db/ryan_romanchuk wx: <<: *default database: wx_test @@ -55,6 +55,11 @@ test: migrations_paths: db/ro production: + primary: + <<: *default + database: personal_production + username: personal + #password: <%= ENV["PERSONAL_DATABASE_PASSWORD"] %> ryan_romanchuk: <<: *default database: ryan_romanchuk_production @@ -62,11 +67,6 @@ production: password: <%= ENV["DATABASE_PASSWORD"] %> host: <%= ENV['DATABASE_HOST'] %> migrations_paths: db/ryan_romanchuk - legacy: - <<: *default - database: personal_production - username: personal - #password: <%= ENV["PERSONAL_DATABASE_PASSWORD"] %> wx: <<: *default database: wx_production diff --git a/personal/db/legacy_structure.sql b/personal/db/legacy_structure.sql deleted file mode 100644 index 14618a9a..00000000 --- a/personal/db/legacy_structure.sql +++ /dev/null @@ -1,639 +0,0 @@ -SET statement_timeout = 0; -SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; -SELECT pg_catalog.set_config('search_path', '', false); -SET check_function_bodies = false; -SET xmloption = content; -SET client_min_messages = warning; -SET row_security = off; - -DROP INDEX IF EXISTS public.unique_taggings; -DROP INDEX IF EXISTS public.index_users_on_slug; -DROP INDEX IF EXISTS public.index_romanchuk_open_tournaments_on_slug; -DROP INDEX IF EXISTS public.index_romanchuk_open_players_on_slug; -DROP INDEX IF EXISTS public.index_romanchuk_open_golfers_on_tournament_id; -DROP INDEX IF EXISTS public.index_romanchuk_open_golfers_on_player_id; -DROP INDEX IF EXISTS public.index_posts_on_slug; -DROP INDEX IF EXISTS public.index_gutentag_tags_on_taggings_count; -DROP INDEX IF EXISTS public.index_gutentag_tags_on_name; -DROP INDEX IF EXISTS public.index_gutentag_taggings_on_taggable_type_and_taggable_id; -DROP INDEX IF EXISTS public.index_gutentag_taggings_on_tag_id; -DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_sluggable_type_and_sluggable_id; -DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope; -DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_slug_and_sluggable_type; -DROP INDEX IF EXISTS public.index_attachments_uniqueness; -DROP INDEX IF EXISTS public.index_attachments_on_blob_id; -ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS users_pkey; -ALTER TABLE IF EXISTS ONLY public.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey; -ALTER TABLE IF EXISTS ONLY public.romanchuk_open_tournaments DROP CONSTRAINT IF EXISTS romanchuk_open_tournaments_pkey; -ALTER TABLE IF EXISTS ONLY public.romanchuk_open_players DROP CONSTRAINT IF EXISTS romanchuk_open_players_pkey; -ALTER TABLE IF EXISTS ONLY public.romanchuk_open_golfers DROP CONSTRAINT IF EXISTS romanchuk_open_golfers_pkey; -ALTER TABLE IF EXISTS ONLY public.posts DROP CONSTRAINT IF EXISTS posts_pkey; -ALTER TABLE IF EXISTS ONLY public.gutentag_tags DROP CONSTRAINT IF EXISTS gutentag_tags_pkey; -ALTER TABLE IF EXISTS ONLY public.gutentag_taggings DROP CONSTRAINT IF EXISTS gutentag_taggings_pkey; -ALTER TABLE IF EXISTS ONLY public.friendly_id_slugs DROP CONSTRAINT IF EXISTS friendly_id_slugs_pkey; -ALTER TABLE IF EXISTS ONLY public.blobs DROP CONSTRAINT IF EXISTS blobs_pkey; -ALTER TABLE IF EXISTS ONLY public.attachments DROP CONSTRAINT IF EXISTS attachments_pkey; -ALTER TABLE IF EXISTS ONLY public.ar_internal_metadata DROP CONSTRAINT IF EXISTS ar_internal_metadata_pkey; -ALTER TABLE IF EXISTS public.gutentag_tags ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public.gutentag_taggings ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public.friendly_id_slugs ALTER COLUMN id DROP DEFAULT; -DROP TABLE IF EXISTS public.users; -DROP TABLE IF EXISTS public.schema_migrations; -DROP TABLE IF EXISTS public.romanchuk_open_tournaments; -DROP TABLE IF EXISTS public.romanchuk_open_players; -DROP TABLE IF EXISTS public.romanchuk_open_golfers; -DROP TABLE IF EXISTS public.posts; -DROP SEQUENCE IF EXISTS public.gutentag_tags_id_seq; -DROP TABLE IF EXISTS public.gutentag_tags; -DROP SEQUENCE IF EXISTS public.gutentag_taggings_id_seq; -DROP TABLE IF EXISTS public.gutentag_taggings; -DROP SEQUENCE IF EXISTS public.friendly_id_slugs_id_seq; -DROP TABLE IF EXISTS public.friendly_id_slugs; -DROP TABLE IF EXISTS public.blobs; -DROP TABLE IF EXISTS public.attachments; -DROP TABLE IF EXISTS public.ar_internal_metadata; -DROP EXTENSION IF EXISTS postgis; -DROP EXTENSION IF EXISTS pg_trgm; --- --- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; - - --- --- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; - - --- --- Name: postgis; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public; - - --- --- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION postgis IS 'PostGIS geometry and geography spatial types and functions'; - - -SET default_tablespace = ''; - -SET default_table_access_method = heap; - --- --- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.ar_internal_metadata ( - key character varying NOT NULL, - value character varying, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: attachments; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.attachments ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - blob_id uuid NOT NULL, - record_type character varying NOT NULL, - record_id uuid NOT NULL, - name character varying NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: blobs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.blobs ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - key character varying NOT NULL, - slug character varying, - data jsonb DEFAULT '{}'::jsonb NOT NULL, - content_type character varying, - title character varying, - description character varying, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: friendly_id_slugs; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.friendly_id_slugs ( - id bigint NOT NULL, - slug character varying NOT NULL, - sluggable_id integer NOT NULL, - sluggable_type character varying(50), - scope character varying, - created_at timestamp(6) without time zone -); - - --- --- Name: friendly_id_slugs_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.friendly_id_slugs_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: friendly_id_slugs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.friendly_id_slugs_id_seq OWNED BY public.friendly_id_slugs.id; - - --- --- Name: gutentag_taggings; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.gutentag_taggings ( - id bigint NOT NULL, - tag_id integer NOT NULL, - taggable_id uuid NOT NULL, - taggable_type character varying NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: gutentag_taggings_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.gutentag_taggings_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: gutentag_taggings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.gutentag_taggings_id_seq OWNED BY public.gutentag_taggings.id; - - --- --- Name: gutentag_tags; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.gutentag_tags ( - id bigint NOT NULL, - name character varying NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - taggings_count integer DEFAULT 0 -); - - --- --- Name: gutentag_tags_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.gutentag_tags_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: gutentag_tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.gutentag_tags_id_seq OWNED BY public.gutentag_tags.id; - - --- --- Name: posts; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.posts ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - title character varying, - description character varying, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - slug character varying, - html_content text, - markdown_content text, - published boolean -); - - --- --- Name: romanchuk_open_golfers; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.romanchuk_open_golfers ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - player_id uuid, - tournament_id uuid, - data jsonb DEFAULT '{}'::jsonb NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: romanchuk_open_players; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.romanchuk_open_players ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - name character varying, - slug character varying, - data jsonb DEFAULT '{}'::jsonb NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: romanchuk_open_tournaments; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.romanchuk_open_tournaments ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - city character varying, - country character varying, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - title character varying, - data jsonb DEFAULT '{}'::jsonb NOT NULL, - ocurred_on timestamp(6) without time zone, - slug character varying -); - - --- --- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.schema_migrations ( - version character varying NOT NULL -); - - --- --- Name: users; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.users ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - cognito_id uuid, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - slug character varying, - username character varying, - data jsonb DEFAULT '{}'::jsonb -); - - --- --- Name: friendly_id_slugs id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.friendly_id_slugs ALTER COLUMN id SET DEFAULT nextval('public.friendly_id_slugs_id_seq'::regclass); - - --- --- Name: gutentag_taggings id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.gutentag_taggings ALTER COLUMN id SET DEFAULT nextval('public.gutentag_taggings_id_seq'::regclass); - - --- --- Name: gutentag_tags id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.gutentag_tags ALTER COLUMN id SET DEFAULT nextval('public.gutentag_tags_id_seq'::regclass); - - --- --- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.ar_internal_metadata - ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); - - --- --- Name: attachments attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.attachments - ADD CONSTRAINT attachments_pkey PRIMARY KEY (id); - - --- --- Name: blobs blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.blobs - ADD CONSTRAINT blobs_pkey PRIMARY KEY (id); - - --- --- Name: friendly_id_slugs friendly_id_slugs_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.friendly_id_slugs - ADD CONSTRAINT friendly_id_slugs_pkey PRIMARY KEY (id); - - --- --- Name: gutentag_taggings gutentag_taggings_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.gutentag_taggings - ADD CONSTRAINT gutentag_taggings_pkey PRIMARY KEY (id); - - --- --- Name: gutentag_tags gutentag_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.gutentag_tags - ADD CONSTRAINT gutentag_tags_pkey PRIMARY KEY (id); - - --- --- Name: posts posts_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.posts - ADD CONSTRAINT posts_pkey PRIMARY KEY (id); - - --- --- Name: romanchuk_open_golfers romanchuk_open_golfers_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.romanchuk_open_golfers - ADD CONSTRAINT romanchuk_open_golfers_pkey PRIMARY KEY (id); - - --- --- Name: romanchuk_open_players romanchuk_open_players_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.romanchuk_open_players - ADD CONSTRAINT romanchuk_open_players_pkey PRIMARY KEY (id); - - --- --- Name: romanchuk_open_tournaments romanchuk_open_tournaments_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.romanchuk_open_tournaments - ADD CONSTRAINT romanchuk_open_tournaments_pkey PRIMARY KEY (id); - - --- --- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.schema_migrations - ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); - - --- --- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_pkey PRIMARY KEY (id); - - --- --- Name: index_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_attachments_on_blob_id ON public.attachments USING btree (blob_id); - - --- --- Name: index_attachments_uniqueness; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_attachments_uniqueness ON public.attachments USING btree (record_type, record_id, name, blob_id); - - --- --- Name: index_friendly_id_slugs_on_slug_and_sluggable_type; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_friendly_id_slugs_on_slug_and_sluggable_type ON public.friendly_id_slugs USING btree (slug, sluggable_type); - - --- --- Name: index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope ON public.friendly_id_slugs USING btree (slug, sluggable_type, scope); - - --- --- Name: index_friendly_id_slugs_on_sluggable_type_and_sluggable_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_friendly_id_slugs_on_sluggable_type_and_sluggable_id ON public.friendly_id_slugs USING btree (sluggable_type, sluggable_id); - - --- --- Name: index_gutentag_taggings_on_tag_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_gutentag_taggings_on_tag_id ON public.gutentag_taggings USING btree (tag_id); - - --- --- Name: index_gutentag_taggings_on_taggable_type_and_taggable_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_gutentag_taggings_on_taggable_type_and_taggable_id ON public.gutentag_taggings USING btree (taggable_type, taggable_id); - - --- --- Name: index_gutentag_tags_on_name; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_gutentag_tags_on_name ON public.gutentag_tags USING btree (name); - - --- --- Name: index_gutentag_tags_on_taggings_count; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_gutentag_tags_on_taggings_count ON public.gutentag_tags USING btree (taggings_count); - - --- --- Name: index_posts_on_slug; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_posts_on_slug ON public.posts USING btree (slug); - - --- --- Name: index_romanchuk_open_golfers_on_player_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_romanchuk_open_golfers_on_player_id ON public.romanchuk_open_golfers USING btree (player_id); - - --- --- Name: index_romanchuk_open_golfers_on_tournament_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_romanchuk_open_golfers_on_tournament_id ON public.romanchuk_open_golfers USING btree (tournament_id); - - --- --- Name: index_romanchuk_open_players_on_slug; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_romanchuk_open_players_on_slug ON public.romanchuk_open_players USING btree (slug); - - --- --- Name: index_romanchuk_open_tournaments_on_slug; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_romanchuk_open_tournaments_on_slug ON public.romanchuk_open_tournaments USING btree (slug); - - --- --- Name: index_users_on_slug; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_users_on_slug ON public.users USING btree (slug); - - --- --- Name: unique_taggings; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX unique_taggings ON public.gutentag_taggings USING btree (taggable_type, taggable_id, tag_id); - - --- --- PostgreSQL database dump complete --- - -SET search_path TO public, postgis; - -INSERT INTO "schema_migrations" (version) VALUES -('20231229222242'), -('20231229222241'), -('20231229222240'), -('20230509000927'), -('20230509000327'), -('20230508230531'), -('20230302171017'), -('20221222083614'), -('20221222083453'), -('20221222081620'), -('20221222081525'), -('20221222080407'), -('20221222074333'), -('20221218192908'), -('20221217055523'), -('20221016052037'), -('20220924080503'), -('20220921060628'), -('20220918231901'), -('20220915172449'), -('20220915095311'), -('20220912170518'), -('20220912160222'), -('20220912032106'), -('20220912023844'), -('20220911031445'), -('20220910222737'), -('20220910200350'), -('20220909221031'), -('20220909215538'), -('20220909202215'), -('20220909194615'), -('20220909190019'), -('20220909141241'), -('20220908030135'), -('20220908030103'), -('20220907202226'), -('20220907201002'), -('20220907063711'), -('20220907061153'), -('20220904211826'), -('20220903210615'), -('20220903195645'), -('20220903083551'), -('20220902213500'), -('20220902173200'), -('20220901182250'), -('20220901053421'), -('20220831102142'), -('20220831094855'), -('20220830200808'), -('20220829165251'), -('20220829054151'), -('20220829035749'), -('20220821012755'), -('20220820234256'), -('20220521080055'), -('20220521071225'), -('20220521051700'), -('20220521030922'), -('20220521025558'), -('20220518024243'), -('20220516065126'), -('20220430012521'), -('20220428191854'), -('20220428093737'), -('20220428093506'), -('20220428075543'), -('20220428074500'), -('20220423051330'), -('20220422185122'), -('20220422095242'), -('20220422094735'), -('20220421233045'), -('20220420221740'), -('20220419065117'), -('20220419065040'), -('20220419065022'), -('20220417222217'), -('20220416012144'), -('20220416012143'), -('20220416012142'), -('20220416005025'); - diff --git a/personal/db/migrate/20220908030103_create_pghero_query_stats.rb b/personal/db/migrate/20231231003512_create_pghero_query_stats.rb similarity index 84% rename from personal/db/migrate/20220908030103_create_pghero_query_stats.rb rename to personal/db/migrate/20231231003512_create_pghero_query_stats.rb index 5571269b..0a900862 100644 --- a/personal/db/migrate/20220908030103_create_pghero_query_stats.rb +++ b/personal/db/migrate/20231231003512_create_pghero_query_stats.rb @@ -1,4 +1,4 @@ -class CreatePgheroQueryStats < ActiveRecord::Migration[7.0] +class CreatePgheroQueryStats < ActiveRecord::Migration[7.1] def change create_table :pghero_query_stats do |t| t.text :database diff --git a/personal/db/migrate/20220908030135_create_pghero_space_stats.rb b/personal/db/migrate/20231231003521_create_pghero_space_stats.rb similarity index 81% rename from personal/db/migrate/20220908030135_create_pghero_space_stats.rb rename to personal/db/migrate/20231231003521_create_pghero_space_stats.rb index c966f220..85e787d5 100644 --- a/personal/db/migrate/20220908030135_create_pghero_space_stats.rb +++ b/personal/db/migrate/20231231003521_create_pghero_space_stats.rb @@ -1,4 +1,4 @@ -class CreatePgheroSpaceStats < ActiveRecord::Migration[7.0] +class CreatePgheroSpaceStats < ActiveRecord::Migration[7.1] def change create_table :pghero_space_stats do |t| t.text :database diff --git a/personal/db/migrate/20231231005449_add_pg_stats.rb b/personal/db/migrate/20231231005449_add_pg_stats.rb new file mode 100644 index 00000000..97b4fe72 --- /dev/null +++ b/personal/db/migrate/20231231005449_add_pg_stats.rb @@ -0,0 +1,5 @@ +class AddPgStats < ActiveRecord::Migration[7.1] + def change + enable_extension 'pg_stat_statements' + end +end diff --git a/personal/db/ro/20231231010416_add_pg_stats.rb b/personal/db/ro/20231231010416_add_pg_stats.rb new file mode 100644 index 00000000..b9409764 --- /dev/null +++ b/personal/db/ro/20231231010416_add_pg_stats.rb @@ -0,0 +1,6 @@ +class AddPgStats < ActiveRecord::Migration[7.1] + def change + enable_extension 'pg_stat_statements' + + end +end diff --git a/personal/db/ro_structure.sql b/personal/db/ro_structure.sql index 2690c152..63d27178 100644 --- a/personal/db/ro_structure.sql +++ b/personal/db/ro_structure.sql @@ -25,6 +25,21 @@ DROP TABLE IF EXISTS public.players; DROP TABLE IF EXISTS public.images; DROP TABLE IF EXISTS public.golfers; DROP TABLE IF EXISTS public.ar_internal_metadata; +DROP EXTENSION IF EXISTS pg_stat_statements; +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; + + SET default_tablespace = ''; SET default_table_access_method = heap; @@ -192,6 +207,8 @@ CREATE INDEX index_players_on_slug ON public.players USING btree (slug); SET search_path TO public, postgis; INSERT INTO "schema_migrations" (version) VALUES +('20231231010416'), +('20231231005823'), ('20230529180823'), ('20230529154437'), ('20230521071142'), diff --git a/personal/db/ryan_romanchuk/20231231005814_add_pg_stats.rb b/personal/db/ryan_romanchuk/20231231005814_add_pg_stats.rb new file mode 100644 index 00000000..97b4fe72 --- /dev/null +++ b/personal/db/ryan_romanchuk/20231231005814_add_pg_stats.rb @@ -0,0 +1,5 @@ +class AddPgStats < ActiveRecord::Migration[7.1] + def change + enable_extension 'pg_stat_statements' + end +end diff --git a/personal/db/ryan_romanchuk_structure.sql b/personal/db/ryan_romanchuk_structure.sql index 88979471..ba70eee2 100644 --- a/personal/db/ryan_romanchuk_structure.sql +++ b/personal/db/ryan_romanchuk_structure.sql @@ -9,14 +9,15 @@ SET xmloption = content; SET client_min_messages = warning; SET row_security = off; +ALTER TABLE IF EXISTS ONLY public.gutentag_taggings DROP CONSTRAINT IF EXISTS fk_rails_cb73a18b77; ALTER TABLE IF EXISTS ONLY public.active_storage_attachments DROP CONSTRAINT IF EXISTS fk_rails_c3b3935057; ALTER TABLE IF EXISTS ONLY public.active_storage_variant_records DROP CONSTRAINT IF EXISTS fk_rails_993965df05; -DROP INDEX IF EXISTS public.unique_taggings; DROP INDEX IF EXISTS public.index_users_on_slug; DROP INDEX IF EXISTS public.index_posts_on_slug; +DROP INDEX IF EXISTS public.index_pg_search_documents_on_searchable; DROP INDEX IF EXISTS public.index_gutentag_tags_on_taggings_count; DROP INDEX IF EXISTS public.index_gutentag_tags_on_name; -DROP INDEX IF EXISTS public.index_gutentag_taggings_on_taggable_type_and_taggable_id; +DROP INDEX IF EXISTS public.index_gutentag_taggings_on_taggable; DROP INDEX IF EXISTS public.index_gutentag_taggings_on_tag_id; DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_sluggable_type_and_sluggable_id; DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope; @@ -25,6 +26,7 @@ DROP INDEX IF EXISTS public.index_active_storage_variant_records_uniqueness; DROP INDEX IF EXISTS public.index_active_storage_blobs_on_key; DROP INDEX IF EXISTS public.index_active_storage_attachments_uniqueness; DROP INDEX IF EXISTS public.index_active_storage_attachments_on_blob_id; +DROP INDEX IF EXISTS public.gutentag_taggings_uniqueness; ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS users_pkey; ALTER TABLE IF EXISTS ONLY public.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey; ALTER TABLE IF EXISTS ONLY public.posts DROP CONSTRAINT IF EXISTS posts_pkey; @@ -36,16 +38,14 @@ ALTER TABLE IF EXISTS ONLY public.ar_internal_metadata DROP CONSTRAINT IF EXISTS ALTER TABLE IF EXISTS ONLY public.active_storage_variant_records DROP CONSTRAINT IF EXISTS active_storage_variant_records_pkey; ALTER TABLE IF EXISTS ONLY public.active_storage_blobs DROP CONSTRAINT IF EXISTS active_storage_blobs_pkey; ALTER TABLE IF EXISTS ONLY public.active_storage_attachments DROP CONSTRAINT IF EXISTS active_storage_attachments_pkey; -ALTER TABLE IF EXISTS public.gutentag_tags ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public.gutentag_taggings ALTER COLUMN id DROP DEFAULT; +ALTER TABLE IF EXISTS public.pg_search_documents ALTER COLUMN id DROP DEFAULT; ALTER TABLE IF EXISTS public.friendly_id_slugs ALTER COLUMN id DROP DEFAULT; DROP TABLE IF EXISTS public.users; DROP TABLE IF EXISTS public.schema_migrations; DROP TABLE IF EXISTS public.posts; +DROP SEQUENCE IF EXISTS public.pg_search_documents_id_seq; DROP TABLE IF EXISTS public.pg_search_documents; -DROP SEQUENCE IF EXISTS public.gutentag_tags_id_seq; DROP TABLE IF EXISTS public.gutentag_tags; -DROP SEQUENCE IF EXISTS public.gutentag_taggings_id_seq; DROP TABLE IF EXISTS public.gutentag_taggings; DROP SEQUENCE IF EXISTS public.friendly_id_slugs_id_seq; DROP TABLE IF EXISTS public.friendly_id_slugs; @@ -53,6 +53,21 @@ DROP TABLE IF EXISTS public.ar_internal_metadata; DROP TABLE IF EXISTS public.active_storage_variant_records; DROP TABLE IF EXISTS public.active_storage_blobs; DROP TABLE IF EXISTS public.active_storage_attachments; +DROP EXTENSION IF EXISTS pg_stat_statements; +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; + + SET default_tablespace = ''; SET default_table_access_method = heap; @@ -149,52 +164,47 @@ ALTER SEQUENCE public.friendly_id_slugs_id_seq OWNED BY public.friendly_id_slugs -- CREATE TABLE public.gutentag_taggings ( - id bigint NOT NULL, - tag_id integer NOT NULL, - taggable_id integer NOT NULL, + id uuid DEFAULT gen_random_uuid() NOT NULL, + tag_id uuid NOT NULL, taggable_type character varying NOT NULL, + taggable_id uuid NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); -- --- Name: gutentag_taggings_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.gutentag_taggings_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: gutentag_taggings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: gutentag_tags; Type: TABLE; Schema: public; Owner: - -- -ALTER SEQUENCE public.gutentag_taggings_id_seq OWNED BY public.gutentag_taggings.id; +CREATE TABLE public.gutentag_tags ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + name character varying NOT NULL, + taggings_count bigint DEFAULT 0 NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); -- --- Name: gutentag_tags; Type: TABLE; Schema: public; Owner: - +-- Name: pg_search_documents; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.gutentag_tags ( +CREATE TABLE public.pg_search_documents ( id bigint NOT NULL, - name character varying NOT NULL, + content text, + searchable_type character varying, + searchable_id bigint, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - taggings_count integer DEFAULT 0 NOT NULL + updated_at timestamp(6) without time zone NOT NULL ); -- --- Name: gutentag_tags_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: pg_search_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE public.gutentag_tags_id_seq +CREATE SEQUENCE public.pg_search_documents_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -203,21 +213,10 @@ CREATE SEQUENCE public.gutentag_tags_id_seq -- --- Name: gutentag_tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: pg_search_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE public.gutentag_tags_id_seq OWNED BY public.gutentag_tags.id; - - --- --- Name: pg_search_documents; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.pg_search_documents ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); +ALTER SEQUENCE public.pg_search_documents_id_seq OWNED BY public.pg_search_documents.id; -- @@ -269,17 +268,10 @@ ALTER TABLE ONLY public.friendly_id_slugs ALTER COLUMN id SET DEFAULT nextval('p -- --- Name: gutentag_taggings id; Type: DEFAULT; Schema: public; Owner: - +-- Name: pg_search_documents id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.gutentag_taggings ALTER COLUMN id SET DEFAULT nextval('public.gutentag_taggings_id_seq'::regclass); - - --- --- Name: gutentag_tags id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.gutentag_tags ALTER COLUMN id SET DEFAULT nextval('public.gutentag_tags_id_seq'::regclass); +ALTER TABLE ONLY public.pg_search_documents ALTER COLUMN id SET DEFAULT nextval('public.pg_search_documents_id_seq'::regclass); -- @@ -370,6 +362,13 @@ ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); +-- +-- Name: gutentag_taggings_uniqueness; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX gutentag_taggings_uniqueness ON public.gutentag_taggings USING btree (taggable_type, taggable_id, tag_id); + + -- -- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: - -- @@ -427,10 +426,10 @@ CREATE INDEX index_gutentag_taggings_on_tag_id ON public.gutentag_taggings USING -- --- Name: index_gutentag_taggings_on_taggable_type_and_taggable_id; Type: INDEX; Schema: public; Owner: - +-- Name: index_gutentag_taggings_on_taggable; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_gutentag_taggings_on_taggable_type_and_taggable_id ON public.gutentag_taggings USING btree (taggable_type, taggable_id); +CREATE INDEX index_gutentag_taggings_on_taggable ON public.gutentag_taggings USING btree (taggable_type, taggable_id); -- @@ -448,24 +447,24 @@ CREATE INDEX index_gutentag_tags_on_taggings_count ON public.gutentag_tags USING -- --- Name: index_posts_on_slug; Type: INDEX; Schema: public; Owner: - +-- Name: index_pg_search_documents_on_searchable; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_slug ON public.posts USING btree (slug); +CREATE INDEX index_pg_search_documents_on_searchable ON public.pg_search_documents USING btree (searchable_type, searchable_id); -- --- Name: index_users_on_slug; Type: INDEX; Schema: public; Owner: - +-- Name: index_posts_on_slug; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_users_on_slug ON public.users USING btree (slug); +CREATE INDEX index_posts_on_slug ON public.posts USING btree (slug); -- --- Name: unique_taggings; Type: INDEX; Schema: public; Owner: - +-- Name: index_users_on_slug; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX unique_taggings ON public.gutentag_taggings USING btree (taggable_type, taggable_id, tag_id); +CREATE INDEX index_users_on_slug ON public.users USING btree (slug); -- @@ -484,6 +483,14 @@ ALTER TABLE ONLY public.active_storage_attachments ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); +-- +-- Name: gutentag_taggings fk_rails_cb73a18b77; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.gutentag_taggings + ADD CONSTRAINT fk_rails_cb73a18b77 FOREIGN KEY (tag_id) REFERENCES public.gutentag_tags(id); + + -- -- PostgreSQL database dump complete -- @@ -491,8 +498,10 @@ ALTER TABLE ONLY public.active_storage_attachments SET search_path TO public, postgis; INSERT INTO "schema_migrations" (version) VALUES -('20230403124303'), +('20231231005814'), +('20230509001859'), +('20230509001025'), +('20230508015328'), ('20230508013707'), -('20230508015328'); - +('20230403124303'); diff --git a/personal/db/structure.sql b/personal/db/structure.sql index c06f6699..73af0ef1 100644 --- a/personal/db/structure.sql +++ b/personal/db/structure.sql @@ -9,103 +9,150 @@ SET xmloption = content; SET client_min_messages = warning; SET row_security = off; -ALTER TABLE IF EXISTS ONLY public.gutentag_taggings DROP CONSTRAINT IF EXISTS fk_rails_cb73a18b77; -ALTER TABLE IF EXISTS ONLY public.active_storage_attachments DROP CONSTRAINT IF EXISTS fk_rails_c3b3935057; -ALTER TABLE IF EXISTS ONLY public.active_storage_variant_records DROP CONSTRAINT IF EXISTS fk_rails_993965df05; +DROP INDEX IF EXISTS public.unique_taggings; DROP INDEX IF EXISTS public.index_users_on_slug; +DROP INDEX IF EXISTS public.index_romanchuk_open_tournaments_on_slug; +DROP INDEX IF EXISTS public.index_romanchuk_open_players_on_slug; +DROP INDEX IF EXISTS public.index_romanchuk_open_golfers_on_tournament_id; +DROP INDEX IF EXISTS public.index_romanchuk_open_golfers_on_player_id; DROP INDEX IF EXISTS public.index_posts_on_slug; -DROP INDEX IF EXISTS public.index_pg_search_documents_on_searchable; +DROP INDEX IF EXISTS public.index_pghero_space_stats_on_database_and_captured_at; +DROP INDEX IF EXISTS public.index_pghero_query_stats_on_database_and_captured_at; DROP INDEX IF EXISTS public.index_gutentag_tags_on_taggings_count; DROP INDEX IF EXISTS public.index_gutentag_tags_on_name; -DROP INDEX IF EXISTS public.index_gutentag_taggings_on_taggable; +DROP INDEX IF EXISTS public.index_gutentag_taggings_on_taggable_type_and_taggable_id; DROP INDEX IF EXISTS public.index_gutentag_taggings_on_tag_id; DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_sluggable_type_and_sluggable_id; DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope; DROP INDEX IF EXISTS public.index_friendly_id_slugs_on_slug_and_sluggable_type; -DROP INDEX IF EXISTS public.index_active_storage_variant_records_uniqueness; -DROP INDEX IF EXISTS public.index_active_storage_blobs_on_key; -DROP INDEX IF EXISTS public.index_active_storage_attachments_uniqueness; -DROP INDEX IF EXISTS public.index_active_storage_attachments_on_blob_id; -DROP INDEX IF EXISTS public.gutentag_taggings_uniqueness; +DROP INDEX IF EXISTS public.index_attachments_uniqueness; +DROP INDEX IF EXISTS public.index_attachments_on_blob_id; ALTER TABLE IF EXISTS ONLY public.users DROP CONSTRAINT IF EXISTS users_pkey; ALTER TABLE IF EXISTS ONLY public.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey; +ALTER TABLE IF EXISTS ONLY public.romanchuk_open_tournaments DROP CONSTRAINT IF EXISTS romanchuk_open_tournaments_pkey; +ALTER TABLE IF EXISTS ONLY public.romanchuk_open_players DROP CONSTRAINT IF EXISTS romanchuk_open_players_pkey; +ALTER TABLE IF EXISTS ONLY public.romanchuk_open_golfers DROP CONSTRAINT IF EXISTS romanchuk_open_golfers_pkey; ALTER TABLE IF EXISTS ONLY public.posts DROP CONSTRAINT IF EXISTS posts_pkey; -ALTER TABLE IF EXISTS ONLY public.pg_search_documents DROP CONSTRAINT IF EXISTS pg_search_documents_pkey; +ALTER TABLE IF EXISTS ONLY public.pghero_space_stats DROP CONSTRAINT IF EXISTS pghero_space_stats_pkey; +ALTER TABLE IF EXISTS ONLY public.pghero_query_stats DROP CONSTRAINT IF EXISTS pghero_query_stats_pkey; ALTER TABLE IF EXISTS ONLY public.gutentag_tags DROP CONSTRAINT IF EXISTS gutentag_tags_pkey; ALTER TABLE IF EXISTS ONLY public.gutentag_taggings DROP CONSTRAINT IF EXISTS gutentag_taggings_pkey; ALTER TABLE IF EXISTS ONLY public.friendly_id_slugs DROP CONSTRAINT IF EXISTS friendly_id_slugs_pkey; +ALTER TABLE IF EXISTS ONLY public.blobs DROP CONSTRAINT IF EXISTS blobs_pkey; +ALTER TABLE IF EXISTS ONLY public.attachments DROP CONSTRAINT IF EXISTS attachments_pkey; ALTER TABLE IF EXISTS ONLY public.ar_internal_metadata DROP CONSTRAINT IF EXISTS ar_internal_metadata_pkey; -ALTER TABLE IF EXISTS ONLY public.active_storage_variant_records DROP CONSTRAINT IF EXISTS active_storage_variant_records_pkey; -ALTER TABLE IF EXISTS ONLY public.active_storage_blobs DROP CONSTRAINT IF EXISTS active_storage_blobs_pkey; -ALTER TABLE IF EXISTS ONLY public.active_storage_attachments DROP CONSTRAINT IF EXISTS active_storage_attachments_pkey; -ALTER TABLE IF EXISTS public.pg_search_documents ALTER COLUMN id DROP DEFAULT; +ALTER TABLE IF EXISTS public.pghero_space_stats ALTER COLUMN id DROP DEFAULT; +ALTER TABLE IF EXISTS public.pghero_query_stats ALTER COLUMN id DROP DEFAULT; +ALTER TABLE IF EXISTS public.gutentag_tags ALTER COLUMN id DROP DEFAULT; +ALTER TABLE IF EXISTS public.gutentag_taggings ALTER COLUMN id DROP DEFAULT; ALTER TABLE IF EXISTS public.friendly_id_slugs ALTER COLUMN id DROP DEFAULT; DROP TABLE IF EXISTS public.users; DROP TABLE IF EXISTS public.schema_migrations; +DROP TABLE IF EXISTS public.romanchuk_open_tournaments; +DROP TABLE IF EXISTS public.romanchuk_open_players; +DROP TABLE IF EXISTS public.romanchuk_open_golfers; DROP TABLE IF EXISTS public.posts; -DROP SEQUENCE IF EXISTS public.pg_search_documents_id_seq; -DROP TABLE IF EXISTS public.pg_search_documents; +DROP SEQUENCE IF EXISTS public.pghero_space_stats_id_seq; +DROP TABLE IF EXISTS public.pghero_space_stats; +DROP SEQUENCE IF EXISTS public.pghero_query_stats_id_seq; +DROP TABLE IF EXISTS public.pghero_query_stats; +DROP SEQUENCE IF EXISTS public.gutentag_tags_id_seq; DROP TABLE IF EXISTS public.gutentag_tags; +DROP SEQUENCE IF EXISTS public.gutentag_taggings_id_seq; DROP TABLE IF EXISTS public.gutentag_taggings; DROP SEQUENCE IF EXISTS public.friendly_id_slugs_id_seq; DROP TABLE IF EXISTS public.friendly_id_slugs; +DROP TABLE IF EXISTS public.blobs; +DROP TABLE IF EXISTS public.attachments; DROP TABLE IF EXISTS public.ar_internal_metadata; -DROP TABLE IF EXISTS public.active_storage_variant_records; -DROP TABLE IF EXISTS public.active_storage_blobs; -DROP TABLE IF EXISTS public.active_storage_attachments; -SET default_tablespace = ''; +DROP EXTENSION IF EXISTS postgis; +DROP EXTENSION IF EXISTS pg_trgm; +DROP EXTENSION IF EXISTS pg_stat_statements; +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; -SET default_table_access_method = heap; -- --- Name: active_storage_attachments; Type: TABLE; Schema: public; Owner: - +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - -- -CREATE TABLE public.active_storage_attachments ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - name character varying NOT NULL, - record_type character varying NOT NULL, - record_id uuid NOT NULL, - blob_id uuid NOT NULL, - created_at timestamp(6) without time zone NOT NULL -); +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; -- --- Name: active_storage_blobs; Type: TABLE; Schema: public; Owner: - +-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - -- -CREATE TABLE public.active_storage_blobs ( - id uuid DEFAULT gen_random_uuid() NOT NULL, +CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; + + +-- +-- Name: postgis; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public; + + +-- +-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION postgis IS 'PostGIS geometry and geography spatial types and functions'; + + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.ar_internal_metadata ( key character varying NOT NULL, - filename character varying NOT NULL, - content_type character varying, - metadata text, - service_name character varying NOT NULL, - byte_size bigint NOT NULL, - checksum character varying, - created_at timestamp(6) without time zone NOT NULL + value character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL ); -- --- Name: active_storage_variant_records; Type: TABLE; Schema: public; Owner: - +-- Name: attachments; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.active_storage_variant_records ( +CREATE TABLE public.attachments ( id uuid DEFAULT gen_random_uuid() NOT NULL, blob_id uuid NOT NULL, - variation_digest character varying NOT NULL + record_type character varying NOT NULL, + record_id uuid NOT NULL, + name character varying NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL ); -- --- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - +-- Name: blobs; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.ar_internal_metadata ( +CREATE TABLE public.blobs ( + id uuid DEFAULT gen_random_uuid() NOT NULL, key character varying NOT NULL, - value character varying, + slug character varying, + data jsonb DEFAULT '{}'::jsonb NOT NULL, + content_type character varying, + title character varying, + description character varying, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); @@ -149,47 +196,87 @@ ALTER SEQUENCE public.friendly_id_slugs_id_seq OWNED BY public.friendly_id_slugs -- CREATE TABLE public.gutentag_taggings ( - id uuid DEFAULT gen_random_uuid() NOT NULL, - tag_id uuid NOT NULL, - taggable_type character varying NOT NULL, + id bigint NOT NULL, + tag_id integer NOT NULL, taggable_id uuid NOT NULL, + taggable_type character varying NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); +-- +-- Name: gutentag_taggings_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.gutentag_taggings_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: gutentag_taggings_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.gutentag_taggings_id_seq OWNED BY public.gutentag_taggings.id; + + -- -- Name: gutentag_tags; Type: TABLE; Schema: public; Owner: - -- CREATE TABLE public.gutentag_tags ( - id uuid DEFAULT gen_random_uuid() NOT NULL, + id bigint NOT NULL, name character varying NOT NULL, - taggings_count bigint DEFAULT 0 NOT NULL, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + taggings_count integer DEFAULT 0 ); -- --- Name: pg_search_documents; Type: TABLE; Schema: public; Owner: - +-- Name: gutentag_tags_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.gutentag_tags_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: gutentag_tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.gutentag_tags_id_seq OWNED BY public.gutentag_tags.id; + + +-- +-- Name: pghero_query_stats; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.pg_search_documents ( +CREATE TABLE public.pghero_query_stats ( id bigint NOT NULL, - content text, - searchable_type character varying, - searchable_id bigint, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + database text, + "user" text, + query text, + query_hash bigint, + total_time double precision, + calls bigint, + captured_at timestamp without time zone ); -- --- Name: pg_search_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: pghero_query_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE public.pg_search_documents_id_seq +CREATE SEQUENCE public.pghero_query_stats_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -198,10 +285,43 @@ CREATE SEQUENCE public.pg_search_documents_id_seq -- --- Name: pg_search_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- Name: pghero_query_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE public.pg_search_documents_id_seq OWNED BY public.pg_search_documents.id; +ALTER SEQUENCE public.pghero_query_stats_id_seq OWNED BY public.pghero_query_stats.id; + + +-- +-- Name: pghero_space_stats; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.pghero_space_stats ( + id bigint NOT NULL, + database text, + schema text, + relation text, + size bigint, + captured_at timestamp without time zone +); + + +-- +-- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.pghero_space_stats_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id; -- @@ -211,16 +331,61 @@ ALTER SEQUENCE public.pg_search_documents_id_seq OWNED BY public.pg_search_docum CREATE TABLE public.posts ( id uuid DEFAULT gen_random_uuid() NOT NULL, title character varying, + description character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, slug character varying, - description text, html_content text, markdown_content text, - published boolean, + published boolean +); + + +-- +-- Name: romanchuk_open_golfers; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.romanchuk_open_golfers ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + player_id uuid, + tournament_id uuid, + data jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: romanchuk_open_players; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.romanchuk_open_players ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + name character varying, + slug character varying, + data jsonb DEFAULT '{}'::jsonb NOT NULL, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); +-- +-- Name: romanchuk_open_tournaments; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.romanchuk_open_tournaments ( + id uuid DEFAULT gen_random_uuid() NOT NULL, + city character varying, + country character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, + title character varying, + data jsonb DEFAULT '{}'::jsonb NOT NULL, + ocurred_on timestamp(6) without time zone, + slug character varying +); + + -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- @@ -237,11 +402,11 @@ CREATE TABLE public.schema_migrations ( CREATE TABLE public.users ( id uuid DEFAULT gen_random_uuid() NOT NULL, cognito_id uuid, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL, slug character varying, username character varying, - data jsonb DEFAULT '{}'::jsonb NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + data jsonb DEFAULT '{}'::jsonb ); @@ -253,34 +418,31 @@ ALTER TABLE ONLY public.friendly_id_slugs ALTER COLUMN id SET DEFAULT nextval('p -- --- Name: pg_search_documents id; Type: DEFAULT; Schema: public; Owner: - +-- Name: gutentag_taggings id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.pg_search_documents ALTER COLUMN id SET DEFAULT nextval('public.pg_search_documents_id_seq'::regclass); +ALTER TABLE ONLY public.gutentag_taggings ALTER COLUMN id SET DEFAULT nextval('public.gutentag_taggings_id_seq'::regclass); -- --- Name: active_storage_attachments active_storage_attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: gutentag_tags id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.active_storage_attachments - ADD CONSTRAINT active_storage_attachments_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.gutentag_tags ALTER COLUMN id SET DEFAULT nextval('public.gutentag_tags_id_seq'::regclass); -- --- Name: active_storage_blobs active_storage_blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: pghero_query_stats id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.active_storage_blobs - ADD CONSTRAINT active_storage_blobs_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_query_stats_id_seq'::regclass); -- --- Name: active_storage_variant_records active_storage_variant_records_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.active_storage_variant_records - ADD CONSTRAINT active_storage_variant_records_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass); -- @@ -291,6 +453,22 @@ ALTER TABLE ONLY public.ar_internal_metadata ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); +-- +-- Name: attachments attachments_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.attachments + ADD CONSTRAINT attachments_pkey PRIMARY KEY (id); + + +-- +-- Name: blobs blobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.blobs + ADD CONSTRAINT blobs_pkey PRIMARY KEY (id); + + -- -- Name: friendly_id_slugs friendly_id_slugs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -316,11 +494,19 @@ ALTER TABLE ONLY public.gutentag_tags -- --- Name: pg_search_documents pg_search_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: pghero_query_stats pghero_query_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.pghero_query_stats + ADD CONSTRAINT pghero_query_stats_pkey PRIMARY KEY (id); + + +-- +-- Name: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.pg_search_documents - ADD CONSTRAINT pg_search_documents_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.pghero_space_stats + ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id); -- @@ -332,54 +518,57 @@ ALTER TABLE ONLY public.posts -- --- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: romanchuk_open_golfers romanchuk_open_golfers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.schema_migrations - ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); +ALTER TABLE ONLY public.romanchuk_open_golfers + ADD CONSTRAINT romanchuk_open_golfers_pkey PRIMARY KEY (id); -- --- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: romanchuk_open_players romanchuk_open_players_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public.users - ADD CONSTRAINT users_pkey PRIMARY KEY (id); +ALTER TABLE ONLY public.romanchuk_open_players + ADD CONSTRAINT romanchuk_open_players_pkey PRIMARY KEY (id); -- --- Name: gutentag_taggings_uniqueness; Type: INDEX; Schema: public; Owner: - +-- Name: romanchuk_open_tournaments romanchuk_open_tournaments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE UNIQUE INDEX gutentag_taggings_uniqueness ON public.gutentag_taggings USING btree (taggable_type, taggable_id, tag_id); +ALTER TABLE ONLY public.romanchuk_open_tournaments + ADD CONSTRAINT romanchuk_open_tournaments_pkey PRIMARY KEY (id); -- --- Name: index_active_storage_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: - +-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE INDEX index_active_storage_attachments_on_blob_id ON public.active_storage_attachments USING btree (blob_id); +ALTER TABLE ONLY public.schema_migrations + ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); -- --- Name: index_active_storage_attachments_uniqueness; Type: INDEX; Schema: public; Owner: - +-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_active_storage_attachments_uniqueness ON public.active_storage_attachments USING btree (record_type, record_id, name, blob_id); +ALTER TABLE ONLY public.users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); -- --- Name: index_active_storage_blobs_on_key; Type: INDEX; Schema: public; Owner: - +-- Name: index_attachments_on_blob_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_active_storage_blobs_on_key ON public.active_storage_blobs USING btree (key); +CREATE INDEX index_attachments_on_blob_id ON public.attachments USING btree (blob_id); -- --- Name: index_active_storage_variant_records_uniqueness; Type: INDEX; Schema: public; Owner: - +-- Name: index_attachments_uniqueness; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_active_storage_variant_records_uniqueness ON public.active_storage_variant_records USING btree (blob_id, variation_digest); +CREATE UNIQUE INDEX index_attachments_uniqueness ON public.attachments USING btree (record_type, record_id, name, blob_id); -- @@ -411,10 +600,10 @@ CREATE INDEX index_gutentag_taggings_on_tag_id ON public.gutentag_taggings USING -- --- Name: index_gutentag_taggings_on_taggable; Type: INDEX; Schema: public; Owner: - +-- Name: index_gutentag_taggings_on_taggable_type_and_taggable_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_gutentag_taggings_on_taggable ON public.gutentag_taggings USING btree (taggable_type, taggable_id); +CREATE INDEX index_gutentag_taggings_on_taggable_type_and_taggable_id ON public.gutentag_taggings USING btree (taggable_type, taggable_id); -- @@ -432,48 +621,66 @@ CREATE INDEX index_gutentag_tags_on_taggings_count ON public.gutentag_tags USING -- --- Name: index_pg_search_documents_on_searchable; Type: INDEX; Schema: public; Owner: - +-- Name: index_pghero_query_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_pg_search_documents_on_searchable ON public.pg_search_documents USING btree (searchable_type, searchable_id); +CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghero_query_stats USING btree (database, captured_at); + + +-- +-- Name: index_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at); -- -- Name: index_posts_on_slug; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_slug ON public.posts USING btree (slug); +CREATE UNIQUE INDEX index_posts_on_slug ON public.posts USING btree (slug); -- --- Name: index_users_on_slug; Type: INDEX; Schema: public; Owner: - +-- Name: index_romanchuk_open_golfers_on_player_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_users_on_slug ON public.users USING btree (slug); +CREATE INDEX index_romanchuk_open_golfers_on_player_id ON public.romanchuk_open_golfers USING btree (player_id); -- --- Name: active_storage_variant_records fk_rails_993965df05; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: index_romanchuk_open_golfers_on_tournament_id; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.active_storage_variant_records - ADD CONSTRAINT fk_rails_993965df05 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); +CREATE INDEX index_romanchuk_open_golfers_on_tournament_id ON public.romanchuk_open_golfers USING btree (tournament_id); -- --- Name: active_storage_attachments fk_rails_c3b3935057; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: index_romanchuk_open_players_on_slug; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.active_storage_attachments - ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id); +CREATE INDEX index_romanchuk_open_players_on_slug ON public.romanchuk_open_players USING btree (slug); -- --- Name: gutentag_taggings fk_rails_cb73a18b77; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: index_romanchuk_open_tournaments_on_slug; Type: INDEX; Schema: public; Owner: - -- -ALTER TABLE ONLY public.gutentag_taggings - ADD CONSTRAINT fk_rails_cb73a18b77 FOREIGN KEY (tag_id) REFERENCES public.gutentag_tags(id); +CREATE UNIQUE INDEX index_romanchuk_open_tournaments_on_slug ON public.romanchuk_open_tournaments USING btree (slug); + + +-- +-- Name: index_users_on_slug; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_users_on_slug ON public.users USING btree (slug); + + +-- +-- Name: unique_taggings; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX unique_taggings ON public.gutentag_taggings USING btree (taggable_type, taggable_id, tag_id); -- @@ -483,9 +690,90 @@ ALTER TABLE ONLY public.gutentag_taggings SET search_path TO public, postgis; INSERT INTO "schema_migrations" (version) VALUES -('20230509001859'), -('20230509001025'), -('20230508015328'), -('20230508013707'), -('20230403124303'); +('20231231005449'), +('20231231003521'), +('20231231003512'), +('20231229222242'), +('20231229222241'), +('20231229222240'), +('20230509000927'), +('20230509000327'), +('20230508230531'), +('20230302171017'), +('20221222083614'), +('20221222083453'), +('20221222081620'), +('20221222081525'), +('20221222080407'), +('20221222074333'), +('20221218192908'), +('20221217055523'), +('20221016052037'), +('20220924080503'), +('20220921060628'), +('20220918231901'), +('20220915172449'), +('20220915095311'), +('20220912170518'), +('20220912160222'), +('20220912032106'), +('20220912023844'), +('20220911031445'), +('20220910222737'), +('20220910200350'), +('20220909221031'), +('20220909215538'), +('20220909202215'), +('20220909194615'), +('20220909190019'), +('20220909141241'), +('20220908030135'), +('20220908030103'), +('20220907202226'), +('20220907201002'), +('20220907063711'), +('20220907061153'), +('20220904211826'), +('20220903210615'), +('20220903195645'), +('20220903083551'), +('20220902213500'), +('20220902173200'), +('20220901182250'), +('20220901053421'), +('20220831102142'), +('20220831094855'), +('20220830200808'), +('20220829165251'), +('20220829054151'), +('20220829035749'), +('20220821012755'), +('20220820234256'), +('20220521080055'), +('20220521071225'), +('20220521051700'), +('20220521030922'), +('20220521025558'), +('20220518024243'), +('20220516065126'), +('20220430012521'), +('20220428191854'), +('20220428093737'), +('20220428093506'), +('20220428075543'), +('20220428074500'), +('20220423051330'), +('20220422185122'), +('20220422095242'), +('20220422094735'), +('20220421233045'), +('20220420221740'), +('20220419065117'), +('20220419065040'), +('20220419065022'), +('20220417222217'), +('20220416012144'), +('20220416012143'), +('20220416012142'), +('20220416005025'); diff --git a/personal/db/wx/20231231003005_remove_query_stats.rb b/personal/db/wx/20231231003005_remove_query_stats.rb new file mode 100644 index 00000000..dc78f08d --- /dev/null +++ b/personal/db/wx/20231231003005_remove_query_stats.rb @@ -0,0 +1,6 @@ +class RemoveQueryStats < ActiveRecord::Migration[7.1] + def change + drop_table :pghero_query_stats + drop_table :pghero_space_stats + end +end diff --git a/personal/db/wx/20231231005753_add_pg_stats.rb b/personal/db/wx/20231231005753_add_pg_stats.rb new file mode 100644 index 00000000..97b4fe72 --- /dev/null +++ b/personal/db/wx/20231231005753_add_pg_stats.rb @@ -0,0 +1,5 @@ +class AddPgStats < ActiveRecord::Migration[7.1] + def change + enable_extension 'pg_stat_statements' + end +end diff --git a/personal/db/wx_structure.sql b/personal/db/wx_structure.sql index 2a4d8ad3..6f0c9b64 100644 --- a/personal/db/wx_structure.sql +++ b/personal/db/wx_structure.sql @@ -39,8 +39,6 @@ DROP INDEX IF EXISTS public.index_tds_aireps_uniqueness; DROP INDEX IF EXISTS public.index_tds_aireps_on_observation_time; DROP INDEX IF EXISTS public.index_tds_aireps_on_batch_id; DROP INDEX IF EXISTS public.index_tds_aircraft_type_designators_on_slug; -DROP INDEX IF EXISTS public.index_pghero_space_stats_on_database_and_captured_at; -DROP INDEX IF EXISTS public.index_pghero_query_stats_on_database_and_captured_at; ALTER TABLE IF EXISTS ONLY public.wx_station_observations DROP CONSTRAINT IF EXISTS wx_station_observations_pkey; ALTER TABLE IF EXISTS ONLY public.tds_tafs DROP CONSTRAINT IF EXISTS tds_tafs_pkey; ALTER TABLE IF EXISTS ONLY public.tds_stations DROP CONSTRAINT IF EXISTS tds_stations_pkey; @@ -50,11 +48,7 @@ ALTER TABLE IF EXISTS ONLY public.tds_batches DROP CONSTRAINT IF EXISTS tds_batc ALTER TABLE IF EXISTS ONLY public.tds_aireps DROP CONSTRAINT IF EXISTS tds_aireps_pkey; ALTER TABLE IF EXISTS ONLY public.tds_aircraft_type_designators DROP CONSTRAINT IF EXISTS tds_aircraft_type_designators_pkey; ALTER TABLE IF EXISTS ONLY public.schema_migrations DROP CONSTRAINT IF EXISTS schema_migrations_pkey; -ALTER TABLE IF EXISTS ONLY public.pghero_space_stats DROP CONSTRAINT IF EXISTS pghero_space_stats_pkey; -ALTER TABLE IF EXISTS ONLY public.pghero_query_stats DROP CONSTRAINT IF EXISTS pghero_query_stats_pkey; ALTER TABLE IF EXISTS ONLY public.ar_internal_metadata DROP CONSTRAINT IF EXISTS ar_internal_metadata_pkey; -ALTER TABLE IF EXISTS public.pghero_space_stats ALTER COLUMN id DROP DEFAULT; -ALTER TABLE IF EXISTS public.pghero_query_stats ALTER COLUMN id DROP DEFAULT; DROP TABLE IF EXISTS public.wx_station_observations; DROP TABLE IF EXISTS public.tds_tafs; DROP TABLE IF EXISTS public.tds_stations; @@ -64,95 +58,38 @@ DROP TABLE IF EXISTS public.tds_batches; DROP TABLE IF EXISTS public.tds_aireps; DROP TABLE IF EXISTS public.tds_aircraft_type_designators; DROP TABLE IF EXISTS public.schema_migrations; -DROP SEQUENCE IF EXISTS public.pghero_space_stats_id_seq; -DROP TABLE IF EXISTS public.pghero_space_stats; -DROP SEQUENCE IF EXISTS public.pghero_query_stats_id_seq; -DROP TABLE IF EXISTS public.pghero_query_stats; DROP TABLE IF EXISTS public.ar_internal_metadata; -SET default_tablespace = ''; - -SET default_table_access_method = heap; - +DROP EXTENSION IF EXISTS pg_stat_statements; -- --- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - -- -CREATE TABLE public.ar_internal_metadata ( - key character varying NOT NULL, - value character varying, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - --- --- Name: pghero_query_stats; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.pghero_query_stats ( - id bigint NOT NULL, - database text, - "user" text, - query text, - query_hash bigint, - total_time double precision, - calls bigint, - captured_at timestamp without time zone -); +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; -- --- Name: pghero_query_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - -- -CREATE SEQUENCE public.pghero_query_stats_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; --- --- Name: pghero_query_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.pghero_query_stats_id_seq OWNED BY public.pghero_query_stats.id; +SET default_tablespace = ''; +SET default_table_access_method = heap; -- --- Name: pghero_space_stats; Type: TABLE; Schema: public; Owner: - +-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE public.pghero_space_stats ( - id bigint NOT NULL, - database text, - schema text, - relation text, - size bigint, - captured_at timestamp without time zone +CREATE TABLE public.ar_internal_metadata ( + key character varying NOT NULL, + value character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL ); --- --- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.pghero_space_stats_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id; - - -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- @@ -393,20 +330,6 @@ CREATE TABLE public.wx_station_observations ( ); --- --- Name: pghero_query_stats id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_query_stats_id_seq'::regclass); - - --- --- Name: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass); - - -- -- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -415,22 +338,6 @@ ALTER TABLE ONLY public.ar_internal_metadata ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); --- --- Name: pghero_query_stats pghero_query_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.pghero_query_stats - ADD CONSTRAINT pghero_query_stats_pkey PRIMARY KEY (id); - - --- --- Name: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.pghero_space_stats - ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id); - - -- -- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -503,20 +410,6 @@ ALTER TABLE ONLY public.wx_station_observations ADD CONSTRAINT wx_station_observations_pkey PRIMARY KEY (id); --- --- Name: index_pghero_query_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghero_query_stats USING btree (database, captured_at); - - --- --- Name: index_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at); - - -- -- Name: index_tds_aircraft_type_designators_on_slug; Type: INDEX; Schema: public; Owner: - -- @@ -742,6 +635,8 @@ ALTER TABLE ONLY public.tds_tafs SET search_path TO public, postgis; INSERT INTO "schema_migrations" (version) VALUES +('20231231005753'), +('20231231003005'), ('20230403001620'), ('20230301150937'), ('20230227043115'),