Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryuni authored and astrobot-houston committed Oct 7, 2024
1 parent 6e06e6e commit c87ae80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions packages/db/src/core/cli/migration-queries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { stripVTControlCharacters } from 'node:util';
import { LibsqlError } from '@libsql/client';
import deepDiff from 'deep-diff';
import { sql } from 'drizzle-orm';
import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core';
Expand Down Expand Up @@ -36,7 +37,6 @@ import type {
TextColumn,
} from '../types.js';
import type { RemoteDatabaseInfo, Result } from '../utils.js';
import { LibsqlError } from '@libsql/client';

const sqlite = new SQLiteAsyncDialect();
const genTempTableName = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10);
Expand Down Expand Up @@ -453,16 +453,19 @@ async function getDbCurrentSnapshot(
return JSON.parse(res.snapshot);
} catch (error) {
// Don't handle errors that are not from libSQL
if (error instanceof LibsqlError &&
if (
error instanceof LibsqlError &&
// If the schema was never pushed to the database yet the table won't exist.
// Treat a missing snapshot table as an empty table.
(
// When connecting to a remote database in that condition
// the query will fail with the following error code and message.
(error.code === 'SQLITE_UNKNOWN' && error.message === 'SQLITE_UNKNOWN: SQLite error: no such table: _astro_db_snapshot') ||

// When connecting to a remote database in that condition
// the query will fail with the following error code and message.
((error.code === 'SQLITE_UNKNOWN' &&
error.message === 'SQLITE_UNKNOWN: SQLite error: no such table: _astro_db_snapshot') ||
// When connecting to a local or in-memory database that does not have a snapshot table yet
// the query will fail with the following error code and message.
(error.code === 'SQLITE_ERROR' && error.message === 'SQLITE_ERROR: no such table: _astro_db_snapshot'))
(error.code === 'SQLITE_ERROR' &&
error.message === 'SQLITE_ERROR: no such table: _astro_db_snapshot'))
) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/db/test/libsql-remote.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { relative } from 'node:path';
import { rm } from 'node:fs/promises';
import { relative } from 'node:path';
import { after, before, describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
import testAdapter from '../../astro/test/test-adapter.js';
Expand Down

0 comments on commit c87ae80

Please sign in to comment.