separate table for fa post favs
This commit is contained in:
31
db/migrate/20250818235935_create_domain_user_post_favs_fa.rb
Normal file
31
db/migrate/20250818235935_create_domain_user_post_favs_fa.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateDomainUserPostFavsFa < ActiveRecord::Migration[7.2]
|
||||
sig { void }
|
||||
def change
|
||||
create_table :domain_user_post_favs_fa, id: false do |t|
|
||||
t.references :user,
|
||||
null: false,
|
||||
index: false,
|
||||
foreign_key: {
|
||||
to_table: :domain_users,
|
||||
}
|
||||
t.references :post,
|
||||
null: false,
|
||||
index: false,
|
||||
foreign_key: {
|
||||
to_table: :domain_posts,
|
||||
}
|
||||
t.integer :fa_fav_id
|
||||
t.boolean :removed, null: false, default: false
|
||||
t.datetime :explicit_time
|
||||
t.datetime :inferred_time
|
||||
|
||||
t.index %i[user_id post_id], unique: true
|
||||
t.index %i[user_id fa_fav_id]
|
||||
t.index %i[post_id user_id]
|
||||
t.index %i[fa_fav_id], unique: true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MigrateDomainUserPostFavsFa < ActiveRecord::Migration[7.2]
|
||||
sig { void }
|
||||
def change
|
||||
up_only { execute <<-SQL }
|
||||
INSERT INTO
|
||||
domain_user_post_favs_fa (
|
||||
user_id,
|
||||
post_id,
|
||||
fa_fav_id,
|
||||
removed,
|
||||
explicit_time,
|
||||
inferred_time
|
||||
)
|
||||
SELECT
|
||||
user_id,
|
||||
post_id,
|
||||
(json_attributes->>'fav_id')::integer as fa_fav_id,
|
||||
removed,
|
||||
to_timestamp((json_attributes->>'explicit_time')::integer) as explicit_time,
|
||||
to_timestamp((json_attributes->>'inferred_time')::integer) as inferred_time
|
||||
FROM domain_user_post_favs
|
||||
WHERE type = 'Domain::UserPostFav::FaUserPostFav'
|
||||
ON CONFLICT (user_id, post_id) DO NOTHING
|
||||
SQL
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
\restrict PV7fivv6HyCBeB8RbPTrvUNqV5o1GKsYeSTvQt7w3Yb3ncL1S4Z5G5QRdVP2iyM
|
||||
\restrict KVwJHYeb0aiqQld3jGGbHGfD5KiqX3RII26U2Hcgs4ak83J67dMbWwZAAsCuZRh
|
||||
|
||||
-- Dumped from database version 17.6 (Debian 17.6-1.pgdg13+1)
|
||||
-- Dumped by pg_dump version 17.6 (Debian 17.6-1.pgdg12+1)
|
||||
@@ -1972,6 +1972,20 @@ CREATE TABLE public.domain_user_post_favs (
|
||||
WITH (autovacuum_enabled='true');
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_user_post_favs_fa; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public.domain_user_post_favs_fa (
|
||||
user_id bigint NOT NULL,
|
||||
post_id bigint NOT NULL,
|
||||
fa_fav_id integer,
|
||||
removed boolean DEFAULT false NOT NULL,
|
||||
explicit_time timestamp(6) without time zone,
|
||||
inferred_time timestamp(6) without time zone
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_user_search_names; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
@@ -4710,6 +4724,34 @@ CREATE INDEX index_domain_user_post_fav_user_factors_on_embedding ON public.doma
|
||||
CREATE UNIQUE INDEX index_domain_user_post_fav_user_factors_on_user_id ON public.domain_user_post_fav_user_factors USING btree (user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_domain_user_post_favs_fa_on_fa_fav_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_domain_user_post_favs_fa_on_fa_fav_id ON public.domain_user_post_favs_fa USING btree (fa_fav_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_domain_user_post_favs_fa_on_post_id_and_user_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_domain_user_post_favs_fa_on_post_id_and_user_id ON public.domain_user_post_favs_fa USING btree (post_id, user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_domain_user_post_favs_fa_on_user_id_and_fa_fav_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_domain_user_post_favs_fa_on_user_id_and_fa_fav_id ON public.domain_user_post_favs_fa USING btree (user_id, fa_fav_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_domain_user_post_favs_fa_on_user_id_and_post_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_domain_user_post_favs_fa_on_user_id_and_post_id ON public.domain_user_post_favs_fa USING btree (user_id, post_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_domain_user_post_favs_on_post_id_and_user_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -5782,6 +5824,14 @@ ALTER TABLE ONLY public.domain_posts_e621_aux
|
||||
ADD CONSTRAINT fk_rails_73ac068c64 FOREIGN KEY (uploader_user_id) REFERENCES public.domain_users_e621_aux(base_table_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_user_post_favs_fa fk_rails_7d8aaceb23; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.domain_user_post_favs_fa
|
||||
ADD CONSTRAINT fk_rails_7d8aaceb23 FOREIGN KEY (post_id) REFERENCES public.domain_posts(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_posts_e621_aux fk_rails_7deb1f0178; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -5982,6 +6032,14 @@ ALTER TABLE ONLY public.domain_posts_e621_aux
|
||||
ADD CONSTRAINT fk_rails_d691739802 FOREIGN KEY (caused_by_entry_id) REFERENCES public.http_log_entries(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_user_post_favs_fa fk_rails_d8fc01753d; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.domain_user_post_favs_fa
|
||||
ADD CONSTRAINT fk_rails_d8fc01753d FOREIGN KEY (user_id) REFERENCES public.domain_users(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: domain_user_job_event_follow_scans fk_rails_ea2f8b74ab; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -6026,11 +6084,13 @@ ALTER TABLE ONLY public.domain_twitter_tweets
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
\unrestrict PV7fivv6HyCBeB8RbPTrvUNqV5o1GKsYeSTvQt7w3Yb3ncL1S4Z5G5QRdVP2iyM
|
||||
\unrestrict KVwJHYeb0aiqQld3jGGbHGfD5KiqX3RII26U2Hcgs4ak83J67dMbWwZAAsCuZRh
|
||||
|
||||
SET search_path TO "$user", public;
|
||||
|
||||
INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20250819001506'),
|
||||
('20250818235935'),
|
||||
('20250818013611'),
|
||||
('20250814202838'),
|
||||
('20250814202723'),
|
||||
|
||||
Reference in New Issue
Block a user