Skip to content

Commit 732269b

Browse files
authored
Add missing Good Job migrations (#1346)
During the upgrade from Rails 8.1.1 to 8.1.2 (#1342), I discovered some mess between Rails 8.1 and Minitest 6 caused the app to stop finding tests, meaning it has silently not been running any tests (all 0 of them are passing) in CI since late December or early January. One of those tests was meant to catch Good Job migrations, and did not, since it didn't run. This puts the missing migrations in place.
1 parent 9125593 commit 732269b

File tree

3 files changed

+126
-92
lines changed

3 files changed

+126
-92
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddIndexGoodJobsFinishedAtForCleanup < ActiveRecord::Migration[8.1]
4+
disable_ddl_transaction!
5+
6+
def change
7+
reversible do |dir|
8+
dir.up do
9+
# Ensure this incremental update migration is idempotent
10+
# with monolithic install migration.
11+
return if connection.index_exists? :good_jobs, [:finished_at], name: :index_good_jobs_jobs_on_finished_at_only
12+
end
13+
end
14+
15+
add_index :good_jobs, [:finished_at], where: "finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at_only, algorithm: :concurrently
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class RemoveExtraneousFinishedAtIndex < ActiveRecord::Migration[8.1]
4+
disable_ddl_transaction!
5+
6+
def change
7+
reversible do |dir|
8+
dir.up do
9+
# Ensure this incremental update migration is idempotent
10+
# with monolithic install migration.
11+
return unless connection.index_exists? :good_jobs, [:finished_at], name: :index_good_jobs_jobs_on_finished_at
12+
end
13+
end
14+
15+
remove_index :good_jobs, [:finished_at], where: 'retried_good_job_id IS NULL AND finished_at IS NOT NULL', name: :index_good_jobs_jobs_on_finished_at, algorithm: :concurrently
16+
end
17+
end

db/schema.rb

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -10,116 +10,116 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[8.0].define(version: 2025_10_10_233458) do
13+
ActiveRecord::Schema[8.1].define(version: 2026_02_02_203260) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "citext"
1616
enable_extension "pg_catalog.plpgsql"
1717
enable_extension "pgcrypto"
1818
enable_extension "uuid-ossp"
1919

2020
create_table "annotations", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
21-
t.uuid "change_uuid", null: false
22-
t.bigint "author_id", null: false
2321
t.jsonb "annotation", null: false
22+
t.bigint "author_id", null: false
23+
t.uuid "change_uuid", null: false
2424
t.datetime "created_at", precision: nil, null: false
2525
t.datetime "updated_at", precision: nil, null: false
2626
t.index ["author_id"], name: "index_annotations_on_author_id"
2727
t.index ["change_uuid"], name: "index_annotations_on_change_uuid"
2828
end
2929

3030
create_table "changes", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
31-
t.uuid "uuid_from", null: false
32-
t.uuid "uuid_to", null: false
33-
t.float "priority"
34-
t.jsonb "current_annotation"
3531
t.datetime "created_at", precision: nil, null: false
36-
t.datetime "updated_at", precision: nil, null: false
32+
t.jsonb "current_annotation"
33+
t.float "priority"
3734
t.float "significance"
35+
t.datetime "updated_at", precision: nil, null: false
36+
t.uuid "uuid_from", null: false
37+
t.uuid "uuid_to", null: false
3838
t.index ["uuid_to", "uuid_from"], name: "index_changes_on_uuid_to_and_uuid_from", unique: true
3939
t.index ["uuid_to"], name: "index_changes_on_uuid_to"
4040
end
4141

4242
create_table "good_job_batches", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
43+
t.integer "callback_priority"
44+
t.text "callback_queue_name"
4345
t.datetime "created_at", null: false
44-
t.datetime "updated_at", null: false
4546
t.text "description"
46-
t.jsonb "serialized_properties"
47-
t.text "on_finish"
48-
t.text "on_success"
49-
t.text "on_discard"
50-
t.text "callback_queue_name"
51-
t.integer "callback_priority"
52-
t.datetime "enqueued_at"
5347
t.datetime "discarded_at"
48+
t.datetime "enqueued_at"
5449
t.datetime "finished_at"
5550
t.datetime "jobs_finished_at"
51+
t.text "on_discard"
52+
t.text "on_finish"
53+
t.text "on_success"
54+
t.jsonb "serialized_properties"
55+
t.datetime "updated_at", null: false
5656
end
5757

5858
create_table "good_job_executions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
59-
t.datetime "created_at", null: false
60-
t.datetime "updated_at", null: false
6159
t.uuid "active_job_id", null: false
62-
t.text "job_class"
63-
t.text "queue_name"
64-
t.jsonb "serialized_params"
65-
t.datetime "scheduled_at"
66-
t.datetime "finished_at"
60+
t.datetime "created_at", null: false
61+
t.interval "duration"
6762
t.text "error"
68-
t.integer "error_event", limit: 2
6963
t.text "error_backtrace", array: true
64+
t.integer "error_event", limit: 2
65+
t.datetime "finished_at"
66+
t.text "job_class"
7067
t.uuid "process_id"
71-
t.interval "duration"
68+
t.text "queue_name"
69+
t.datetime "scheduled_at"
70+
t.jsonb "serialized_params"
71+
t.datetime "updated_at", null: false
7272
t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at"
7373
t.index ["process_id", "created_at"], name: "index_good_job_executions_on_process_id_and_created_at"
7474
end
7575

7676
create_table "good_job_processes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
7777
t.datetime "created_at", null: false
78-
t.datetime "updated_at", null: false
79-
t.jsonb "state"
8078
t.integer "lock_type", limit: 2
79+
t.jsonb "state"
80+
t.datetime "updated_at", null: false
8181
end
8282

8383
create_table "good_job_settings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
8484
t.datetime "created_at", null: false
85-
t.datetime "updated_at", null: false
8685
t.text "key"
86+
t.datetime "updated_at", null: false
8787
t.jsonb "value"
8888
t.index ["key"], name: "index_good_job_settings_on_key", unique: true
8989
end
9090

9191
create_table "good_jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
92-
t.text "queue_name"
93-
t.integer "priority"
94-
t.jsonb "serialized_params"
95-
t.datetime "scheduled_at"
96-
t.datetime "performed_at"
97-
t.datetime "finished_at"
98-
t.text "error"
99-
t.datetime "created_at", null: false
100-
t.datetime "updated_at", null: false
10192
t.uuid "active_job_id"
93+
t.uuid "batch_callback_id"
94+
t.uuid "batch_id"
10295
t.text "concurrency_key"
103-
t.text "cron_key"
104-
t.uuid "retried_good_job_id"
96+
t.datetime "created_at", null: false
10597
t.datetime "cron_at"
106-
t.uuid "batch_id"
107-
t.uuid "batch_callback_id"
108-
t.boolean "is_discrete"
98+
t.text "cron_key"
99+
t.text "error"
100+
t.integer "error_event", limit: 2
109101
t.integer "executions_count"
102+
t.datetime "finished_at"
103+
t.boolean "is_discrete"
110104
t.text "job_class"
111-
t.integer "error_event", limit: 2
112105
t.text "labels", array: true
113-
t.uuid "locked_by_id"
114106
t.datetime "locked_at"
107+
t.uuid "locked_by_id"
108+
t.datetime "performed_at"
109+
t.integer "priority"
110+
t.text "queue_name"
111+
t.uuid "retried_good_job_id"
112+
t.datetime "scheduled_at"
113+
t.jsonb "serialized_params"
114+
t.datetime "updated_at", null: false
115115
t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at"
116116
t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)"
117117
t.index ["batch_id"], name: "index_good_jobs_on_batch_id", where: "(batch_id IS NOT NULL)"
118118
t.index ["concurrency_key", "created_at"], name: "index_good_jobs_on_concurrency_key_and_created_at"
119119
t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)"
120120
t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at_cond", where: "(cron_key IS NOT NULL)"
121121
t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at_cond", unique: true, where: "(cron_key IS NOT NULL)"
122-
t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at", where: "((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL))"
122+
t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at_only", where: "(finished_at IS NOT NULL)"
123123
t.index ["job_class"], name: "index_good_jobs_on_job_class"
124124
t.index ["labels"], name: "index_good_jobs_on_labels", where: "(labels IS NOT NULL)", using: :gin
125125
t.index ["locked_by_id"], name: "index_good_jobs_on_locked_by_id", where: "(locked_by_id IS NOT NULL)"
@@ -131,137 +131,137 @@
131131
end
132132

133133
create_table "imports", force: :cascade do |t|
134-
t.bigint "user_id"
135-
t.integer "status", default: 0, null: false
134+
t.boolean "create_pages", default: true, null: false
135+
t.datetime "created_at", precision: nil, null: false
136136
t.string "file"
137137
t.jsonb "processing_errors"
138-
t.datetime "created_at", precision: nil, null: false
139-
t.datetime "updated_at", precision: nil, null: false
140-
t.integer "update_behavior", default: 0, null: false
141-
t.boolean "create_pages", default: true, null: false
142138
t.jsonb "processing_warnings"
143139
t.boolean "skip_unchanged_versions", default: false, null: false
140+
t.integer "status", default: 0, null: false
141+
t.integer "update_behavior", default: 0, null: false
142+
t.datetime "updated_at", precision: nil, null: false
143+
t.bigint "user_id"
144144
t.index ["user_id"], name: "index_imports_on_user_id"
145145
end
146146

147147
create_table "invitations", force: :cascade do |t|
148-
t.bigint "issuer_id"
149-
t.bigint "redeemer_id"
150148
t.string "code"
149+
t.datetime "created_at", precision: nil, null: false
151150
t.string "email"
152151
t.datetime "expires_on", precision: nil
153-
t.datetime "created_at", precision: nil, null: false
152+
t.bigint "issuer_id"
153+
t.bigint "redeemer_id"
154154
t.datetime "updated_at", precision: nil, null: false
155155
t.index ["code"], name: "index_invitations_on_code"
156156
t.index ["issuer_id"], name: "index_invitations_on_issuer_id"
157157
t.index ["redeemer_id"], name: "index_invitations_on_redeemer_id"
158158
end
159159

160160
create_table "maintainers", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
161+
t.datetime "created_at", precision: nil, null: false
161162
t.citext "name", null: false
162163
t.uuid "parent_uuid"
163-
t.datetime "created_at", precision: nil, null: false
164164
t.datetime "updated_at", precision: nil, null: false
165165
t.index ["name"], name: "index_maintainers_on_name", unique: true
166166
end
167167

168168
create_table "maintainerships", id: false, force: :cascade do |t|
169+
t.datetime "created_at", precision: nil, null: false
169170
t.uuid "maintainer_uuid", null: false
170171
t.uuid "page_uuid", null: false
171-
t.datetime "created_at", precision: nil, null: false
172172
t.index ["maintainer_uuid", "page_uuid"], name: "index_maintainerships_on_maintainer_uuid_and_page_uuid", unique: true
173173
t.index ["maintainer_uuid"], name: "index_maintainerships_on_maintainer_uuid"
174174
t.index ["page_uuid"], name: "index_maintainerships_on_page_uuid"
175175
end
176176

177177
create_table "merged_pages", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
178-
t.uuid "target_uuid", null: false
179178
t.jsonb "audit_data"
179+
t.uuid "target_uuid", null: false
180180
t.index ["target_uuid"], name: "index_merged_pages_on_target_uuid"
181181
end
182182

183183
create_table "page_urls", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
184-
t.uuid "page_uuid", null: false
185-
t.string "url", null: false
186-
t.string "url_key", null: false
184+
t.datetime "created_at", null: false
187185
t.datetime "from_time", precision: nil, default: -::Float::INFINITY, null: false
188-
t.datetime "to_time", precision: nil, default: ::Float::INFINITY, null: false
189186
t.string "notes"
190-
t.datetime "created_at", null: false
187+
t.uuid "page_uuid", null: false
188+
t.datetime "to_time", precision: nil, default: ::Float::INFINITY, null: false
191189
t.datetime "updated_at", null: false
190+
t.string "url", null: false
191+
t.string "url_key", null: false
192192
t.index ["page_uuid", "url", "from_time", "to_time"], name: "index_page_urls_on_page_uuid_and_url_and_from_time_and_to_time", unique: true
193193
t.index ["url"], name: "index_page_urls_on_url"
194194
t.index ["url_key"], name: "index_page_urls_on_url_key"
195195
end
196196

197197
create_table "pages", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
198-
t.string "url", null: false
199-
t.string "title"
198+
t.boolean "active", default: true
200199
t.datetime "created_at", precision: nil, null: false
200+
t.integer "status"
201+
t.string "title"
201202
t.datetime "updated_at", precision: nil, null: false
203+
t.string "url", null: false
202204
t.string "url_key"
203-
t.boolean "active", default: true
204-
t.integer "status"
205205
t.index ["url"], name: "index_pages_on_url"
206206
t.index ["url_key"], name: "index_pages_on_url_key"
207207
end
208208

209209
create_table "taggings", id: false, force: :cascade do |t|
210-
t.uuid "taggable_uuid", null: false
211-
t.string "taggable_type"
212-
t.uuid "tag_uuid", null: false
213210
t.datetime "created_at", precision: nil, null: false
211+
t.uuid "tag_uuid", null: false
212+
t.string "taggable_type"
213+
t.uuid "taggable_uuid", null: false
214214
t.index ["tag_uuid"], name: "index_taggings_on_tag_uuid"
215215
t.index ["taggable_uuid", "tag_uuid"], name: "index_taggings_on_taggable_uuid_and_tag_uuid", unique: true
216216
t.index ["taggable_uuid"], name: "index_taggings_on_taggable_uuid"
217217
end
218218

219219
create_table "tags", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
220-
t.citext "name", null: false
221220
t.datetime "created_at", precision: nil, null: false
221+
t.citext "name", null: false
222222
t.datetime "updated_at", precision: nil, null: false
223223
t.index ["name"], name: "index_tags_on_name", unique: true
224224
end
225225

226226
create_table "users", force: :cascade do |t|
227+
t.datetime "confirmation_sent_at", precision: nil
228+
t.string "confirmation_token"
229+
t.datetime "confirmed_at", precision: nil
230+
t.datetime "created_at", precision: nil, null: false
231+
t.datetime "current_sign_in_at", precision: nil
232+
t.inet "current_sign_in_ip"
227233
t.string "email", default: "", null: false
228234
t.string "encrypted_password", default: "", null: false
229-
t.string "reset_password_token"
230-
t.datetime "reset_password_sent_at", precision: nil
231-
t.datetime "remember_created_at", precision: nil
232-
t.integer "sign_in_count", default: 0, null: false
233-
t.datetime "current_sign_in_at", precision: nil
234235
t.datetime "last_sign_in_at", precision: nil
235-
t.inet "current_sign_in_ip"
236236
t.inet "last_sign_in_ip"
237-
t.string "confirmation_token"
238-
t.datetime "confirmed_at", precision: nil
239-
t.datetime "confirmation_sent_at", precision: nil
237+
t.string "permissions", default: [], array: true
238+
t.datetime "remember_created_at", precision: nil
239+
t.datetime "reset_password_sent_at", precision: nil
240+
t.string "reset_password_token"
241+
t.integer "sign_in_count", default: 0, null: false
240242
t.string "unconfirmed_email"
241-
t.datetime "created_at", precision: nil, null: false
242243
t.datetime "updated_at", precision: nil, null: false
243-
t.string "permissions", default: [], array: true
244244
t.index ["email"], name: "index_users_on_email", unique: true
245245
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
246246
end
247247

248248
create_table "versions", primary_key: "uuid", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
249-
t.uuid "page_uuid"
250-
t.datetime "capture_time", precision: nil, null: false
251-
t.string "body_url"
252249
t.string "body_hash"
253-
t.string "source_type"
254-
t.jsonb "source_metadata"
250+
t.string "body_url"
251+
t.datetime "capture_time", precision: nil, null: false
252+
t.integer "content_length"
255253
t.datetime "created_at", precision: nil, null: false
256-
t.datetime "updated_at", precision: nil, null: false
257-
t.string "title"
258-
t.string "url"
259254
t.boolean "different", default: true
260-
t.integer "status"
261-
t.integer "content_length"
262-
t.string "media_type"
263255
t.jsonb "headers"
256+
t.string "media_type"
264257
t.string "network_error"
258+
t.uuid "page_uuid"
259+
t.jsonb "source_metadata"
260+
t.string "source_type"
261+
t.integer "status"
262+
t.string "title"
263+
t.datetime "updated_at", precision: nil, null: false
264+
t.string "url"
265265
t.index ["body_hash"], name: "index_versions_on_body_hash"
266266
t.index ["capture_time", "uuid"], name: "index_versions_on_capture_time_and_uuid"
267267
t.index ["created_at", "uuid"], name: "index_versions_on_created_at_and_uuid"

0 commit comments

Comments
 (0)