Correct down migration for photo migration under PostgreSQL.
This commit is contained in:
parent
982e6f9b6b
commit
424e736982
1 changed files with 27 additions and 8 deletions
|
|
@ -40,15 +40,24 @@ SQL
|
||||||
|
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
execute <<SQL
|
|
||||||
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,
|
|
||||||
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,
|
|
||||||
NULL AS actor_url, NULL AS objectId, NULL AS root_guid, status_message_guid, 0 AS likes_count, comments_count, NULL AS o_embed_cache_id
|
|
||||||
FROM photos
|
|
||||||
SQL
|
|
||||||
|
|
||||||
if postgres?
|
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 %{
|
execute %{
|
||||||
UPDATE
|
UPDATE
|
||||||
aspect_visibilities
|
aspect_visibilities
|
||||||
|
|
@ -62,6 +71,7 @@ SQL
|
||||||
posts.guid=photos.guid
|
posts.guid=photos.guid
|
||||||
AND photos.id=aspect_visibilities.shareable_id
|
AND photos.id=aspect_visibilities.shareable_id
|
||||||
}
|
}
|
||||||
|
|
||||||
execute %{
|
execute %{
|
||||||
UPDATE
|
UPDATE
|
||||||
share_visibilities
|
share_visibilities
|
||||||
|
|
@ -76,6 +86,15 @@ SQL
|
||||||
AND photos.id=share_visibilities.shareable_id
|
AND photos.id=share_visibilities.shareable_id
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
execute <<SQL
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
NULL AS actor_url, NULL AS objectId, NULL AS root_guid, status_message_guid, 0 AS likes_count, comments_count, NULL AS o_embed_cache_id
|
||||||
|
FROM photos
|
||||||
|
SQL
|
||||||
|
|
||||||
execute <<SQL
|
execute <<SQL
|
||||||
UPDATE aspect_visibilities, posts, photos
|
UPDATE aspect_visibilities, posts, photos
|
||||||
SET
|
SET
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue