discourse/db/post_migrate
Andrei Prigorshnev 932a2fe419
FIX: PG::StringDataRightTruncation when linking posts (#13134)
Users who use encoded slugs on their sites sometimes run into 500 error when pasting a link to another topic in a post. The problem happens when generating a backward "reflection" link that would appear in a linked topic. Link URL restricted on the database level to 500 chars in length. At first glance, it should work since we have a restriction on topic title length.

But it doesn't work when a site uses encoded slugs, like here (take a look at the URL). The link to a topic, in this case, can be much longer than 500 characters.

By the way, an error happens only when generating a "reflection" link and doesn't happen with a direct link, we truncate that link. It works because, in this case, the original long link is still present in the post body and can be used for navigation. But we can't do the same for backward "reflection" links (without rewriting their implementation), the whole link must be saved to the database.

The simplest and cleanest solution will be just to remove the restriction on the database level. Abuse is impossible here since we are already protected by the restriction on topic title length. There aren’t performance benefits in using length-constrained columns in Postgres, in fact, length-constrained columns need a few extra CPU cycles to check the length when storing data.
2021-06-02 15:27:04 +04:00
..
20180917024729_remove_superfluous_columns.rb
20180917034056_remove_superfluous_tables.rb
20181012123001_drop_group_locked_trust_level_from_user.rb
20181112013117_migrate_url_site_settings.rb
20190103065652_remove_uploaded_meta_id_from_category.rb
20190121203023_drop_queued_post_id_from_user_actions.rb
20190123171817_drop_queued_posts.rb
20190205104116_drop_unused_auth_tables.rb
20190208144706_drop_unused_auth_tables_again.rb
20190312194528_drop_email_user_options_columns.rb
20190508141824_drop_claimed_by_id.rb
20190716124050_remove_via_email_from_invite.rb
20191107032231_change_notification_level.rb
20191107190330_remove_suppress_from_latest_from_category.rb
20191129144706_drop_unused_google_instagram_auth_tables.rb
20191219112000_remove_key_from_api_keys.rb
20200117174646_make_post_reply_id_column_read_only.rb
20200120131338_drop_unused_columns.rb
20200330233427_drop_old_unread_pm_notification_indices.rb
20200408121312_remove_key_from_user_api_key.rb
20200415140830_drop_automatic_membership_retroactive_from_group.rb UX: drop the `automatic_membership_retroactive` column from groups model. (#9430) 2020-04-22 22:07:39 +05:30
20200424032633_remove_canonical_email_from_user_emails.rb Revert "FEATURE: enforce_canonical_emails site setting" 2020-04-24 13:52:06 +10:00
20200430010528_remove_avg_time_from_topics_posts.rb DEV: correct drop logic for columns in post table 2020-04-30 12:58:09 +10:00
20200508141209_allow_null_old_email_on_email_change_requests.rb FEATURE: Improve UX support for multiple email addresses (#9691) 2020-06-10 19:11:49 +03:00
20200513185052_drop_topic_reply_count.rb PERF: Dematerialize topic_reply_count (#9769) 2020-05-14 15:42:00 -07:00
20200520001619_remove_fks_from_bookmarks.rb Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse"" 2020-05-23 00:56:13 -04:00
20200522004855_remove_access_control_post_fk.rb Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse"" 2020-05-23 00:56:13 -04:00
20200601111500_remove_image_url_from_post_and_topic.rb DEV: Drop unused image_url column from posts and topics (#9953) 2020-06-02 16:21:38 +10:00
20200610150900_correct_posts_schema.rb DEV: Update rubocop-discourse from 2.3.2 to 2.4.0 (#11079) 2020-10-30 15:04:29 +01:00
20200715045152_remove_bookmarks_delete_when_reminder_sent.rb FEATURE: Add "delete on owner reply" bookmark functionality (#10231) 2020-07-21 10:00:39 +10:00
20200724060632_remove_deprecated_allowlist_settings.rb FIX: use allowlist and blocklist terminology (#10209) 2020-07-27 10:23:54 +10:00
20200728004302_drop_path_whitelist_from_embeddable_hosts.rb FIX: Improve allowed_path column migration (#10321) 2020-07-28 13:31:51 +10:00
20200818084329_update_private_message_on_post_search_data.rb DEV: Drop search index on non-pm posts. 2020-08-21 07:21:34 +08:00
20200903045539_add_index_topics_on_timestamps_private.rb PERF: Keep track of first unread PM and first unread group PM for user. 2020-09-09 14:05:41 +08:00
20201110110952_drop_github_user_infos.rb DEV: Drop github_user_infos table (#11181) 2020-11-10 11:33:27 +00:00
20210125100452_migrate_search_data_after_default_locale_rename.rb FIX: move post_search_data migration into onceoff job (#11851) 2021-01-26 16:29:00 +01:00
20210127140730_undo_add_processed_to_notifications.rb DEV: Replace 'processed' column on notifications with new table (#11864) 2021-01-27 10:29:24 -06:00
20210207232853_fix_topic_timer_duration_minutes.rb FIX: Delete topic timers far in the future (#12125) 2021-02-18 14:18:43 +02:00
20210215231312_fix_group_flair_avatar_upload_security_and_acls.rb FIX: Do not mark group_flair images as secure on upload (#12081) 2021-02-16 12:34:03 +10:00
20210218022739_move_new_since_to_new_table_again.rb FIX: ensure corrected migration runs (#12137) 2021-02-19 11:48:32 +11:00
20210219171329_drop_old_sso_site_settings.rb DEV: Drop old SSO site setting rows from the database (#12148) 2021-02-19 19:05:49 +00:00
20210302164429_drop_flash_onebox_site_setting.rb Drop flash video onebox (#12261) 2021-03-02 17:11:14 +00:00
20210324043327_delete_orphan_post_revisions.rb FIX: delete orphan post revisions (#12502) 2021-03-25 12:34:53 +11:00
20210328233843_fix_bookmarks_with_incorrect_topic_id.rb FIX: Bookmark topics were not being updated when the post moved (#12542) 2021-03-29 11:25:48 +10:00
20210513125608_remove_length_constrain_from_topic_excerpt.rb FIX: errors that're triggering by too long excerpts (#13056) 2021-05-31 14:59:40 +04:00
20210525112226_remove_length_constrain_from_topic_link_url.rb FIX: PG::StringDataRightTruncation when linking posts (#13134) 2021-06-02 15:27:04 +04:00
20210528003603_fix_badge_image_avatar_upload_security_and_acls.rb FIX: Do not mark badge image uploads as secure (#13193) 2021-05-28 12:35:52 +10:00