Fixing post.url migration.

This commit is contained in:
Dessalines 2023-06-08 09:24:34 -04:00
parent 1d338d56f1
commit f203abd4e1
4 changed files with 14 additions and 3 deletions

View file

@ -636,7 +636,8 @@ diesel::table! {
id -> Int4,
#[max_length = 200]
name -> Varchar,
url -> Nullable<Text>,
#[max_length = 512]
url -> Nullable<Varchar>,
body -> Nullable<Text>,
creator_id -> Int4,
community_id -> Int4,

View file

@ -1 +1,5 @@
-- Change back the column type
alter table post alter column url type text;
-- Drop the index
drop index idx_post_url;

View file

@ -1 +1,9 @@
-- Make a hard limit of 512 for the post.url column
-- Truncate existing long rows.
update post set url = left(url, 512) where length(url) > 512;
-- Enforce the limit
alter table post alter column url type varchar (512);
-- Add the index
create index idx_post_url on post(url);

View file

@ -72,8 +72,6 @@ pub fn setup(db_url: String, user_agent: String) -> Result<(), LemmyError> {
/// Update the hot_rank columns for the aggregates tables
fn update_hot_ranks(conn: &mut PgConnection, last_week_only: bool) {
info!("Updating hot ranks...");
let mut post_update = diesel::update(post_aggregates::table).into_boxed();
let mut comment_update = diesel::update(comment_aggregates::table).into_boxed();
let mut community_update = diesel::update(community_aggregates::table).into_boxed();