fix: better D1 error handling in migration
parent
e2ff649ebd
commit
821beb2a87
|
|
@ -78,7 +78,15 @@ r = requests.post(
|
|||
}
|
||||
).json()
|
||||
|
||||
if r['success'] :
|
||||
if not r['success']:
|
||||
# UNIQUE constraint failed: uptimeflare.key: SQLITE_CONSTRAINT
|
||||
if r['errors'][0]['code'] == 7500 and "UNIQUE" in r['errors'][0]['message']:
|
||||
print("State probably already migrated to D1. Migration skipped.")
|
||||
else:
|
||||
print("Error writing state to D1: ", r)
|
||||
print("Migration failed. Please report this issue at https://github.com/lyc8503/UptimeFlare/issues.")
|
||||
exit(1)
|
||||
|
||||
print("State migrated to D1 successfully. Trying to delete unused KV namespace...")
|
||||
r = requests.delete(
|
||||
api_endpoint + f"/storage/kv/namespaces/{kv_id}",
|
||||
|
|
@ -88,7 +96,3 @@ if r['success'] :
|
|||
print("KV namespace deleted successfully.")
|
||||
else:
|
||||
print("Error deleting KV namespace: ", r)
|
||||
else:
|
||||
print("Error writing state to D1: ", r)
|
||||
print("Migration failed. Please report this issue at https://github.com/lyc8503/UptimeFlare/issues.")
|
||||
exit(1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue