Merge pull request #2202 from Pistos/postgresql-fix-photo-migration
Postgresql fix photo migration
This commit is contained in:
commit
718cb2c2f4
1 changed files with 50 additions and 3 deletions
|
|
@ -40,7 +40,53 @@ SQL
|
||||||
|
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
execute <<SQL
|
if postgres?
|
||||||
|
execute %{
|
||||||
|
INSERT INTO posts (
|
||||||
|
author_id, public, diaspora_handle, guid, pending, type, text,
|
||||||
|
remote_photo_path, remote_photo_name, random_string, processed_image,
|
||||||
|
youtube_titles, created_at, updated_at, unprocessed_image,
|
||||||
|
object_url, image_url, image_height, image_width,
|
||||||
|
provider_display_name, actor_url, "objectId", root_guid,
|
||||||
|
status_message_guid, likes_count, comments_count, o_embed_cache_id
|
||||||
|
) SELECT
|
||||||
|
author_id, public, diaspora_handle, guid, pending, 'Photo', text,
|
||||||
|
remote_photo_path, remote_photo_name, random_string, processed_image,
|
||||||
|
NULL, created_at, updated_at, unprocessed_image, NULL, NULL, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL,
|
||||||
|
status_message_guid, 0, comments_count, NULL
|
||||||
|
FROM photos
|
||||||
|
}
|
||||||
|
|
||||||
|
execute %{
|
||||||
|
UPDATE
|
||||||
|
aspect_visibilities
|
||||||
|
SET
|
||||||
|
shareable_id=posts.id
|
||||||
|
, shareable_type='Post'
|
||||||
|
FROM
|
||||||
|
posts
|
||||||
|
, photos
|
||||||
|
WHERE
|
||||||
|
posts.guid=photos.guid
|
||||||
|
AND photos.id=aspect_visibilities.shareable_id
|
||||||
|
}
|
||||||
|
|
||||||
|
execute %{
|
||||||
|
UPDATE
|
||||||
|
share_visibilities
|
||||||
|
SET
|
||||||
|
shareable_id=posts.id
|
||||||
|
, shareable_type='Post'
|
||||||
|
FROM
|
||||||
|
posts
|
||||||
|
, photos
|
||||||
|
WHERE
|
||||||
|
posts.guid=photos.guid
|
||||||
|
AND photos.id=share_visibilities.shareable_id
|
||||||
|
}
|
||||||
|
else
|
||||||
|
execute <<SQL
|
||||||
INSERT INTO posts
|
INSERT INTO posts
|
||||||
SELECT NULL AS id, author_id, public, diaspora_handle, guid, pending, 'Photo' AS type, text, remote_photo_path, remote_photo_name, random_string,
|
SELECT NULL AS id, author_id, public, diaspora_handle, guid, pending, 'Photo' AS type, text, remote_photo_path, remote_photo_name, random_string,
|
||||||
processed_image, NULL AS youtube_titles, created_at, updated_at, unprocessed_image, NULL AS object_url, NULL AS image_url, NULL AS image_height, NULL AS image_width, NULL AS provider_display_name,
|
processed_image, NULL AS youtube_titles, created_at, updated_at, unprocessed_image, NULL AS object_url, NULL AS image_url, NULL AS image_height, NULL AS image_width, NULL AS provider_display_name,
|
||||||
|
|
@ -48,7 +94,7 @@ INSERT INTO posts
|
||||||
FROM photos
|
FROM photos
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
execute <<SQL
|
execute <<SQL
|
||||||
UPDATE aspect_visibilities, posts, photos
|
UPDATE aspect_visibilities, posts, photos
|
||||||
SET
|
SET
|
||||||
aspect_visibilities.shareable_id=posts.id,
|
aspect_visibilities.shareable_id=posts.id,
|
||||||
|
|
@ -58,7 +104,7 @@ posts.guid=photos.guid AND
|
||||||
photos.id=aspect_visibilities.shareable_id
|
photos.id=aspect_visibilities.shareable_id
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
execute <<SQL
|
execute <<SQL
|
||||||
UPDATE share_visibilities, posts, photos
|
UPDATE share_visibilities, posts, photos
|
||||||
SET
|
SET
|
||||||
share_visibilities.shareable_id=posts.id,
|
share_visibilities.shareable_id=posts.id,
|
||||||
|
|
@ -67,6 +113,7 @@ WHERE
|
||||||
posts.guid=photos.guid AND
|
posts.guid=photos.guid AND
|
||||||
photos.id=share_visibilities.shareable_id
|
photos.id=share_visibilities.shareable_id
|
||||||
SQL
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
execute "DROP TABLE photos"
|
execute "DROP TABLE photos"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue