feat(menu): allow overwriting links #162

merged
opened by a.starrysky.fyi targeting main from private/minion/push-znnulvoxwzkq

Previously when a link was put into menu it was impossible to overwrite it without editing the database. Instead, we can change our INSERT to an UPSERT to allow that. This lets me fix typos (such as y/bsky missing the /profile/ path)

+2 -2
menu/.sqlx/query-735cda2fe387b6b852a03ba7ccba41353667bd505f80c1cfe3ad16b738b45ba5.json menu/.sqlx/query-9eecf9b43e5458bc95fc45fe8e48d6da5edb50cdbf1e7a478faf310d6b9022ad.json
··· 1 { 2 "db_name": "PostgreSQL", 3 - "query": "INSERT INTO direct (\"from\", \"to\", \"owner\") VALUES ($1, $2, $3)", 4 "describe": { 5 "columns": [], 6 "parameters": { ··· 12 }, 13 "nullable": [] 14 }, 15 - "hash": "735cda2fe387b6b852a03ba7ccba41353667bd505f80c1cfe3ad16b738b45ba5" 16 }
··· 1 { 2 "db_name": "PostgreSQL", 3 + "query": "INSERT INTO direct (\"from\", \"to\", \"owner\") VALUES ($1, $2, $3) ON CONFLICT (\"from\") DO UPDATE SET \"to\" = EXCLUDED.to, \"owner\" = EXCLUDED.owner", 4 "describe": { 5 "columns": [], 6 "parameters": { ··· 12 }, 13 "nullable": [] 14 }, 15 + "hash": "9eecf9b43e5458bc95fc45fe8e48d6da5edb50cdbf1e7a478faf310d6b9022ad" 16 }
+1 -1
menu/src/main.rs
··· 139 }; 140 141 let create_call = sqlx::query!( 142 - r#"INSERT INTO direct ("from", "to", "owner") VALUES ($1, $2, $3)"#, 143 create.from.to_lowercase(), 144 create.to, 145 owner,
··· 139 }; 140 141 let create_call = sqlx::query!( 142 + r#"INSERT INTO direct ("from", "to", "owner") VALUES ($1, $2, $3) ON CONFLICT ("from") DO UPDATE SET "to" = EXCLUDED.to, "owner" = EXCLUDED.owner"#, 143 create.from.to_lowercase(), 144 create.to, 145 owner,