diff options
Diffstat (limited to 'packages/db/src')
-rw-r--r-- | packages/db/src/core/cli/migration-queries.ts | 6 | ||||
-rw-r--r-- | packages/db/src/core/integration/vite-plugin-db.ts | 7 | ||||
-rw-r--r-- | packages/db/src/core/utils.ts | 20 | ||||
-rw-r--r-- | packages/db/src/runtime/db-client.ts | 10 |
4 files changed, 25 insertions, 18 deletions
diff --git a/packages/db/src/core/cli/migration-queries.ts b/packages/db/src/core/cli/migration-queries.ts index 1a16001df..5c4a23557 100644 --- a/packages/db/src/core/cli/migration-queries.ts +++ b/packages/db/src/core/cli/migration-queries.ts @@ -436,7 +436,7 @@ export function getProductionCurrentSnapshot(options: { async function getDbCurrentSnapshot( appToken: string, - remoteUrl: string + remoteUrl: string, ): Promise<DBSnapshot | undefined> { const client = createRemoteDatabaseClient({ dbType: 'libsql', @@ -447,7 +447,7 @@ async function getDbCurrentSnapshot( try { const res = await client.get<{ snapshot: string }>( // Latest snapshot - sql`select snapshot from _astro_db_snapshot order by id desc limit 1;` + sql`select snapshot from _astro_db_snapshot order by id desc limit 1;`, ); return JSON.parse(res.snapshot); @@ -464,7 +464,7 @@ async function getDbCurrentSnapshot( async function getStudioCurrentSnapshot( appToken: string, - remoteUrl: string + remoteUrl: string, ): Promise<DBSnapshot | undefined> { const url = new URL('/db/schema', remoteUrl); diff --git a/packages/db/src/core/integration/vite-plugin-db.ts b/packages/db/src/core/integration/vite-plugin-db.ts index c8e273151..c00a99f3b 100644 --- a/packages/db/src/core/integration/vite-plugin-db.ts +++ b/packages/db/src/core/integration/vite-plugin-db.ts @@ -9,7 +9,12 @@ import { DB_PATH, RUNTIME_IMPORT, RUNTIME_VIRTUAL_IMPORT, VIRTUAL_MODULE_ID } fr import { getResolvedFileUrl } from '../load-file.js'; import { SEED_DEV_FILE_NAME, getCreateIndexQueries, getCreateTableQuery } from '../queries.js'; import type { DBTables } from '../types.js'; -import { type VitePlugin, getAstroEnv, getDbDirectoryUrl, getRemoteDatabaseInfo } from '../utils.js'; +import { + type VitePlugin, + getAstroEnv, + getDbDirectoryUrl, + getRemoteDatabaseInfo, +} from '../utils.js'; export const resolved = { module: '\0' + VIRTUAL_MODULE_ID, diff --git a/packages/db/src/core/utils.ts b/packages/db/src/core/utils.ts index 9797992b8..cf3e37535 100644 --- a/packages/db/src/core/utils.ts +++ b/packages/db/src/core/utils.ts @@ -19,15 +19,17 @@ export function getRemoteDatabaseInfo(): RemoteDatabaseInfo { const astroEnv = getAstroEnv(); const studioEnv = getAstroStudioEnv(); - if (studioEnv.ASTRO_STUDIO_REMOTE_DB_URL) return { - type: 'studio', - url: studioEnv.ASTRO_STUDIO_REMOTE_DB_URL, - }; - - if (astroEnv.ASTRO_DB_REMOTE_URL) return { - type: 'libsql', - url: astroEnv.ASTRO_DB_REMOTE_URL, - }; + if (studioEnv.ASTRO_STUDIO_REMOTE_DB_URL) + return { + type: 'studio', + url: studioEnv.ASTRO_STUDIO_REMOTE_DB_URL, + }; + + if (astroEnv.ASTRO_DB_REMOTE_URL) + return { + type: 'libsql', + url: astroEnv.ASTRO_DB_REMOTE_URL, + }; return { type: 'studio', diff --git a/packages/db/src/runtime/db-client.ts b/packages/db/src/runtime/db-client.ts index 08a68e2e8..d667ecbb2 100644 --- a/packages/db/src/runtime/db-client.ts +++ b/packages/db/src/runtime/db-client.ts @@ -43,10 +43,10 @@ const remoteResultSchema = z.object({ }); type RemoteDbClientOptions = { - dbType: 'studio' | 'libsql', - appToken: string, - remoteUrl: string | URL, -} + dbType: 'studio' | 'libsql'; + appToken: string; + remoteUrl: string | URL; +}; export function createRemoteDatabaseClient(options: RemoteDbClientOptions) { const remoteUrl = new URL(options.remoteUrl); @@ -65,7 +65,7 @@ function createRemoteLibSQLClient(appToken: string, remoteDbURL: URL) { authToken: appToken, url: remoteDbURL.protocol === 'memory:' ? ':memory:' : remoteDbURL.toString(), }); - return drizzleLibsql(client); + return drizzleLibsql(client); } function createStudioDatabaseClient(appToken: string, remoteDbURL: URL) { |