db: apply good_jobs migrations
Apply a couple of migrations from `bin/rails generate good_job:update`.
This commit is contained in:
19
db/migrate/20221026084655_create_good_job_settings.rb
Normal file
19
db/migrate/20221026084655_create_good_job_settings.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
class CreateGoodJobSettings < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
# Ensure this incremental update migration is idempotent
|
||||
# with monolithic install migration.
|
||||
return if connection.table_exists?(:good_job_settings)
|
||||
end
|
||||
end
|
||||
|
||||
create_table :good_job_settings, id: :uuid do |t|
|
||||
t.timestamps
|
||||
t.text :key
|
||||
t.jsonb :value
|
||||
t.index :key, unique: true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
class CreateIndexGoodJobsJobsOnPriorityCreatedAtWhenUnfinished < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
# Ensure this incremental update migration is idempotent
|
||||
# with monolithic install migration.
|
||||
return if connection.index_name_exists?(:good_jobs, :index_good_jobs_jobs_on_priority_created_at_when_unfinished)
|
||||
end
|
||||
end
|
||||
|
||||
add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc },
|
||||
where: "finished_at IS NULL", name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished,
|
||||
algorithm: :concurrently
|
||||
end
|
||||
end
|
||||
@@ -808,6 +808,19 @@ CREATE TABLE public.good_job_processes (
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: good_job_settings; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public.good_job_settings (
|
||||
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,
|
||||
key text,
|
||||
value jsonb
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: good_jobs; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
@@ -3101,6 +3114,14 @@ ALTER TABLE ONLY public.good_job_processes
|
||||
ADD CONSTRAINT good_job_processes_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: good_job_settings good_job_settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.good_job_settings
|
||||
ADD CONSTRAINT good_job_settings_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: good_jobs good_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -4204,6 +4225,13 @@ CREATE INDEX index_forum_topics_on_title_tsvector ON public.forum_topics USING g
|
||||
CREATE INDEX index_forum_topics_on_updated_at ON public.forum_topics USING btree (updated_at);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_good_job_settings_on_key; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_good_job_settings_on_key ON public.good_job_settings USING btree (key);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_good_jobs_jobs_on_finished_at; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -4211,6 +4239,13 @@ CREATE INDEX index_forum_topics_on_updated_at ON public.forum_topics USING btree
|
||||
CREATE INDEX index_good_jobs_jobs_on_finished_at ON public.good_jobs USING btree (finished_at) WHERE ((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_good_jobs_jobs_on_priority_created_at_when_unfinished; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_good_jobs_jobs_on_priority_created_at_when_unfinished ON public.good_jobs USING btree (priority DESC NULLS LAST, created_at) WHERE (finished_at IS NULL);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_good_jobs_on_active_job_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -6870,6 +6905,8 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20220925045236'),
|
||||
('20220926050108'),
|
||||
('20221003080342'),
|
||||
('20221010035855');
|
||||
('20221010035855'),
|
||||
('20221026084655'),
|
||||
('20221026084656');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user