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