Edits history of script submission #20921 for ' Updates project's Postgres config (supabase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Supabase = {
    	key: string
    }
    /**
     * Updates project's Postgres config
     *
     */
    export async function main(
    	auth: Supabase,
    	ref: string,
    	body: {
    		effective_cache_size?: string
    		logical_decoding_work_mem?: string
    		maintenance_work_mem?: string
    		track_activity_query_size?: string
    		max_connections?: number
    		max_locks_per_transaction?: number
    		max_parallel_maintenance_workers?: number
    		max_parallel_workers?: number
    		max_parallel_workers_per_gather?: number
    		max_replication_slots?: number
    		max_slot_wal_keep_size?: string
    		max_standby_archive_delay?: string
    		max_standby_streaming_delay?: string
    		max_wal_size?: string
    		max_wal_senders?: number
    		max_worker_processes?: number
    		session_replication_role?: 'origin' | 'replica' | 'local'
    		shared_buffers?: string
    		statement_timeout?: string
    		track_commit_timestamp?: false | true
    		wal_keep_size?: string
    		wal_sender_timeout?: string
    		work_mem?: string
    		restart_database?: false | true
    	}
    ) {
    	const url = new URL(`https://api.supabase.com/v1/projects/${ref}/config/database/postgres`)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.key
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 207 days ago