support setting for writing supabase migration files (#427)

This commit is contained in:
Will Chen
2025-06-17 15:14:02 -07:00
committed by GitHub
parent ff4e93d747
commit 382fe9bab5
10 changed files with 206 additions and 20 deletions

View File

@@ -1,7 +1,12 @@
import { IS_TEST_BUILD } from "@/ipc/utils/test_utils";
import { getSupabaseClient } from "./supabase_management_client";
import { SUPABASE_SCHEMA_QUERY } from "./supabase_schema_query";
async function getPublishableKey({ projectId }: { projectId: string }) {
if (IS_TEST_BUILD) {
return "test-publishable-key";
}
const supabase = await getSupabaseClient();
let keys;
try {
@@ -50,6 +55,10 @@ export async function getSupabaseContext({
}: {
supabaseProjectId: string;
}) {
if (IS_TEST_BUILD) {
return "[[TEST_BUILD_SUPABASE_CONTEXT]]";
}
const supabase = await getSupabaseClient();
const publishableKey = await getPublishableKey({
projectId: supabaseProjectId,

View File

@@ -140,6 +140,10 @@ export async function executeSupabaseSql({
supabaseProjectId: string;
query: string;
}): Promise<string> {
if (IS_TEST_BUILD) {
return "{}";
}
const supabase = await getSupabaseClient();
const result = await supabase.runQuery(supabaseProjectId, query);
return JSON.stringify(result);