mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #1275 from ZogStriP/enable-thumbnailing-on-s3
Enable thumbnailing on s3
This commit is contained in:
22
db/migrate/20130728172550_add_url_to_optimized_images.rb
Normal file
22
db/migrate/20130728172550_add_url_to_optimized_images.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class AddUrlToOptimizedImages < ActiveRecord::Migration
|
||||
def up
|
||||
# add a nullable url column
|
||||
add_column :optimized_images, :url, :string
|
||||
# compute the url for existing images
|
||||
execute "UPDATE optimized_images
|
||||
SET url = substring(u.url from '^\/uploads\/[^/]+\/')
|
||||
|| '_optimized/'
|
||||
|| substring(oi.sha1 for 3) || '/'
|
||||
|| substring(oi.sha1 from 4 for 3) || '/'
|
||||
|| substring(oi.sha1 from 7 for 11) || oi.extension
|
||||
FROM optimized_images oi
|
||||
JOIN uploads u ON u.id = oi.upload_id
|
||||
WHERE optimized_images.id = oi.id;"
|
||||
# change the column to be non nullable
|
||||
change_column :optimized_images, :url, :string, null: false
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :optimized_images, :url
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user