0

Stop an Online Migration

by
Published Dec 20, 2024

To stop an online migration, send a DELETE request to `/v2/databases/$DATABASE_ID/online-migration/$MIGRATION_ID`. A status of 204 will be given. This indicates that the request was processed successfully, but that no response body is needed.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Stop an Online Migration
7
 * To stop an online migration, send a DELETE request to `/v2/databases/$DATABASE_ID/online-migration/$MIGRATION_ID`.
8

9
A status of 204 will be given. This indicates that the request was processed successfully, but that no response body is needed.
10

11
 */
12
export async function main(
13
  auth: Digitalocean,
14
  database_cluster_uuid: string,
15
  migration_id: string,
16
) {
17
  const url = new URL(
18
    `https://api.digitalocean.com/v2/databases/${database_cluster_uuid}/online-migration/${migration_id}`,
19
  );
20

21
  const response = await fetch(url, {
22
    method: "DELETE",
23
    headers: {
24
      Authorization: "Bearer " + auth.token,
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34