migrate fa posts to aux table

This commit is contained in:
Dylan Knutson
2025-07-26 05:39:32 +00:00
parent ca4729f7d1
commit bc4143ae12
9 changed files with 51 additions and 103 deletions

View File

@@ -19,33 +19,13 @@ class MigrateFaPostsToAux < ActiveRecord::Migration[7.2]
[:num_views, :integer, {}],
[:scanned_at, :timestamp, {}],
[:scan_file_error, :string, {}],
[
:last_user_page,
:references,
{ foreign_key: { to_table: :http_log_entries }, index: false },
],
[
:first_browse_page,
:references,
{ foreign_key: { to_table: :http_log_entries }, index: false },
],
[
:first_gallery_page,
:references,
{ foreign_key: { to_table: :http_log_entries }, index: false },
],
[
:first_seen_entry,
:references,
{ foreign_key: { to_table: :http_log_entries }, index: false },
],
[:last_user_page_id, :integer, {}],
[:first_browse_page_id, :integer, {}],
[:first_gallery_page_id, :integer, {}],
[:first_seen_entry_id, :integer, {}],
[:fuzzysearch_checked_at, :timestamp, {}],
[:fuzzysearch_json, :jsonb, {}],
[
:fuzzysearch_entry,
:references,
{ foreign_key: { to_table: :http_log_entries }, index: false },
],
[:fuzzysearch_entry_id, :integer, {}],
[:tried_from_fur_archiver, :boolean, { default: false }],
[:tried_from_tor, :boolean, { default: false }],
]

View File

@@ -0,0 +1,5 @@
class CreateIndexOnFaId < ActiveRecord::Migration[7.2]
def change
add_index :domain_posts_fa_aux, :fa_id
end
end

View File

@@ -0,0 +1,17 @@
class MakeIndexUniqueOnFaId < ActiveRecord::Migration[7.2]
def change
# make the exisitng index a unique index
add_index :domain_posts_fa_aux,
:fa_id,
name: "index_domain_posts_fa_aux_on_fa_id_unique",
unique: true
remove_index :domain_posts_fa_aux,
:fa_id,
name: "index_domain_posts_fa_aux_on_fa_id"
rename_index :domain_posts_fa_aux,
"index_domain_posts_fa_aux_on_fa_id_unique",
"index_domain_posts_fa_aux_on_fa_id"
end
end

View File

@@ -1410,13 +1410,13 @@ CREATE TABLE public.domain_posts_fa_aux (
num_views integer,
scanned_at timestamp without time zone,
scan_file_error character varying,
last_user_page_id bigint,
first_browse_page_id bigint,
first_gallery_page_id bigint,
first_seen_entry_id bigint,
last_user_page_id integer,
first_browse_page_id integer,
first_gallery_page_id integer,
first_seen_entry_id integer,
fuzzysearch_checked_at timestamp without time zone,
fuzzysearch_json jsonb,
fuzzysearch_entry_id bigint,
fuzzysearch_entry_id integer,
tried_from_fur_archiver boolean DEFAULT false,
tried_from_tor boolean DEFAULT false
);
@@ -4033,6 +4033,13 @@ CREATE INDEX index_domain_posts_e621_aux_on_base_table_id ON public.domain_posts
CREATE INDEX index_domain_posts_fa_aux_on_base_table_id ON public.domain_posts_fa_aux USING btree (base_table_id);
--
-- Name: index_domain_posts_fa_aux_on_fa_id; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_domain_posts_fa_aux_on_fa_id ON public.domain_posts_fa_aux USING btree (fa_id);
--
-- Name: index_domain_posts_on_posted_at; Type: INDEX; Schema: public; Owner: -
--
@@ -5128,14 +5135,6 @@ ALTER TABLE ONLY public.domain_user_user_follows
ADD CONSTRAINT fk_rails_4b2ab65400 FOREIGN KEY (from_id) REFERENCES public.domain_users(id);
--
-- Name: domain_posts_fa_aux fk_rails_5ec6ca402e; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.domain_posts_fa_aux
ADD CONSTRAINT fk_rails_5ec6ca402e FOREIGN KEY (first_seen_entry_id) REFERENCES public.http_log_entries(id);
--
-- Name: domain_twitter_medias fk_rails_5fffa41fa6; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -5184,14 +5183,6 @@ ALTER TABLE ONLY public.domain_user_search_names
ADD CONSTRAINT fk_rails_8475fe75b5 FOREIGN KEY (user_id) REFERENCES public.domain_users(id);
--
-- Name: domain_posts_fa_aux fk_rails_9231b05b1c; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.domain_posts_fa_aux
ADD CONSTRAINT fk_rails_9231b05b1c FOREIGN KEY (first_browse_page_id) REFERENCES public.http_log_entries(id);
--
-- Name: good_job_execution_log_lines_collections fk_rails_98c288034f; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -5216,14 +5207,6 @@ ALTER TABLE ONLY public.domain_posts_e621_aux
ADD CONSTRAINT fk_rails_a90522803d FOREIGN KEY (last_index_page_id) REFERENCES public.http_log_entries(id);
--
-- Name: domain_posts_fa_aux fk_rails_addb1e1118; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.domain_posts_fa_aux
ADD CONSTRAINT fk_rails_addb1e1118 FOREIGN KEY (first_gallery_page_id) REFERENCES public.http_log_entries(id);
--
-- Name: domain_posts_e621_aux fk_rails_ae368c64c2; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -5232,14 +5215,6 @@ ALTER TABLE ONLY public.domain_posts_e621_aux
ADD CONSTRAINT fk_rails_ae368c64c2 FOREIGN KEY (base_table_id) REFERENCES public.domain_posts(id);
--
-- Name: domain_posts_fa_aux fk_rails_ae8beb22db; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.domain_posts_fa_aux
ADD CONSTRAINT fk_rails_ae8beb22db FOREIGN KEY (fuzzysearch_entry_id) REFERENCES public.http_log_entries(id);
--
-- Name: domain_user_user_follows fk_rails_b45e6e3979; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -5328,14 +5303,6 @@ ALTER TABLE ONLY public.domain_post_files
ADD CONSTRAINT fk_rails_d059c07f77 FOREIGN KEY (log_entry_id) REFERENCES public.http_log_entries(id);
--
-- Name: domain_posts_fa_aux fk_rails_d5abc02732; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.domain_posts_fa_aux
ADD CONSTRAINT fk_rails_d5abc02732 FOREIGN KEY (last_user_page_id) REFERENCES public.http_log_entries(id);
--
-- Name: domain_posts_e621_aux fk_rails_d691739802; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -5383,6 +5350,8 @@ ALTER TABLE ONLY public.domain_twitter_tweets
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20250726051748'),
('20250726051451'),
('20250725192431'),
('20250724213505'),
('20250723194407'),