Update database branch config

Updates the configuration of the specified database branch

Script supabase Verified

by hugo697 ยท 10/17/2025

The script

Submitted by hugo697 Bun
Verified 207 days ago
1
//native
2
type Supabase = {
3
	key: string
4
}
5
/**
6
 * Update database branch config
7
 * Updates the configuration of the specified database branch
8
 */
9
export async function main(
10
	auth: Supabase,
11
	branch_id: string,
12
	body: {
13
		branch_name?: string
14
		git_branch?: string
15
		reset_on_push?: false | true
16
		persistent?: false | true
17
		status?:
18
			| 'CREATING_PROJECT'
19
			| 'RUNNING_MIGRATIONS'
20
			| 'MIGRATIONS_PASSED'
21
			| 'MIGRATIONS_FAILED'
22
			| 'FUNCTIONS_DEPLOYED'
23
			| 'FUNCTIONS_FAILED'
24
	}
25
) {
26
	const url = new URL(`https://api.supabase.com/v1/branches/${branch_id}`)
27

28
	const response = await fetch(url, {
29
		method: 'PATCH',
30
		headers: {
31
			'Content-Type': 'application/json',
32
			Authorization: 'Bearer ' + auth.key
33
		},
34
		body: JSON.stringify(body)
35
	})
36
	if (!response.ok) {
37
		const text = await response.text()
38
		throw new Error(`${response.status} ${text}`)
39
	}
40
	return await response.json()
41
}
42