artists: convert other_names to array (#3987).
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
class ChangeOtherNamesToArrayOnArtists < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
Artist.without_timeout do
|
||||
remove_index :artists, name: "index_artists_on_other_names_trgm"
|
||||
change_column :artists, :other_names, "text[]", using: "array_remove(regexp_split_to_array(other_names, '\\s+'), '')", default: "{}"
|
||||
add_index :artists, :other_names, using: :gin
|
||||
|
||||
remove_column :artists, :other_names_index
|
||||
execute "DROP TRIGGER trigger_artists_on_update ON artists"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Artist.without_timeout do
|
||||
remove_index :artists, :other_names
|
||||
change_column :artists, :other_names, "text", using: "array_to_string(other_names, ' ')", default: nil
|
||||
add_index :artists, :other_names, name: "index_artists_on_other_names_trgm", using: :gin, opclass: :gin_trgm_ops
|
||||
|
||||
add_column :artists, :other_names_index, :tsvector
|
||||
execute "CREATE TRIGGER trigger_artists_on_update BEFORE INSERT OR UPDATE ON artists FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names')"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -765,8 +765,7 @@ CREATE TABLE public.artists (
|
||||
creator_id integer NOT NULL,
|
||||
is_active boolean DEFAULT true NOT NULL,
|
||||
is_banned boolean DEFAULT false NOT NULL,
|
||||
other_names text,
|
||||
other_names_index tsvector,
|
||||
other_names text[] DEFAULT '{}'::text[],
|
||||
group_name character varying,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone
|
||||
@@ -5078,17 +5077,10 @@ CREATE INDEX index_artists_on_name_trgm ON public.artists USING gin (name public
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_artists_on_other_names_index; Type: INDEX; Schema: public; Owner: -
|
||||
-- Name: index_artists_on_other_names; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_artists_on_other_names_index ON public.artists USING gin (other_names_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_artists_on_other_names_trgm; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_artists_on_other_names_trgm ON public.artists USING gin (other_names public.gin_trgm_ops);
|
||||
CREATE INDEX index_artists_on_other_names ON public.artists USING gin (other_names);
|
||||
|
||||
|
||||
--
|
||||
@@ -7345,13 +7337,6 @@ CREATE INDEX index_wiki_pages_on_updated_at ON public.wiki_pages USING btree (up
|
||||
CREATE TRIGGER insert_favorites_trigger BEFORE INSERT ON public.favorites FOR EACH ROW EXECUTE PROCEDURE public.favorites_insert_trigger();
|
||||
|
||||
|
||||
--
|
||||
-- Name: artists trigger_artists_on_update; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TRIGGER trigger_artists_on_update BEFORE INSERT OR UPDATE ON public.artists FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names');
|
||||
|
||||
|
||||
--
|
||||
-- Name: comments trigger_comments_on_update; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
@@ -7574,6 +7559,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20181108205842'),
|
||||
('20181113174914'),
|
||||
('20181114180205'),
|
||||
('20181114185032');
|
||||
('20181114185032'),
|
||||
('20181114202744');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user