Add virtual md5 column to external_api_images
This commit is contained in:
parent
58c0cd8983
commit
9e4b59b665
@ -0,0 +1,15 @@
|
||||
class AddExternalAPIImagesGeneratedMd5ColumnAndSiteIndex < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_index(:external_api_images, :site)
|
||||
reversible do |r|
|
||||
r.up do
|
||||
exec_query("ALTER TABLE external_api_images ADD COLUMN md5 TEXT GENERATED ALWAYS AS (cached_data->'file'->>'md5') STORED")
|
||||
add_index(:external_api_images, :md5)
|
||||
end
|
||||
r.down do
|
||||
exec_query("ALTER TABLE external_api_images DROP COLUMN md5")
|
||||
remove_index(:external_api_images, :md5)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
5
db/schema.rb
generated
5
db/schema.rb
generated
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_10_21_212746) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2025_01_12_032852) do
|
||||
create_schema "e621"
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
@ -157,7 +157,10 @@ ActiveRecord::Schema[7.1].define(version: 2024_10_21_212746) do
|
||||
t.datetime "cache_last_updated_at", default: -> { "CURRENT_TIMESTAMP(3)" }, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
r t.virtual "md5", type: :text, as: "((cached_data -> 'file'::text) ->> 'md5'::text)", stored: true
|
||||
t.index ["api_image_id"], name: "index_external_api_images_on_api_image_id"
|
||||
t.index ["md5"], name: "index_external_api_images_on_md5"
|
||||
t.index ["site"], name: "index_external_api_images_on_site"
|
||||
end
|
||||
|
||||
create_table "good_job_batches", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
|
Loading…
Reference in New Issue
Block a user