@stacksjs/database 0.75.487 → 0.75.490
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +1 -1
- package/dist/table-exists.d.ts +19 -0
- package/dist/table-exists.js +1 -0
- package/package.json +16 -16
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,7 @@ export * from './erd';
|
|
|
138
138
|
export * from './vschema';
|
|
139
139
|
// SQL dialect helpers & connection defaults
|
|
140
140
|
export * from './sql-helpers';
|
|
141
|
+
export * from './table-exists';
|
|
141
142
|
export * from './defaults';
|
|
142
143
|
// Dialect classification for the committed migration corpus, so a corpus
|
|
143
144
|
// emitted for one database fails loudly before a single statement runs.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Database,createDatabase,createMysqlDatabase,createPostgresDatabase,createSqliteDatabase,createTursoDatabase}from"./database";export{detectDriver,driverDefaults,getConfigFromEnv,getConnectionString,mergeWithDefaults,validateDriverConfig}from"./driver-config";export*from"./utils";export*from"./row-lock";export*from"./types";export*from"./migrations";export*from"./framework-renames";export{setQueryTracker,logQuery}from"./query-logger";export{addColumnSafely,backfillInBatches,renameColumnSafely}from"./safe-migrations";export{matchedRows,mutationCount}from"./affected-rows";export*from"./seeder";export*from"./drivers";export*from"./custom";export*from"./auth-tables";export*from"./utc-defaults";export*from"./uuid-columns";export*from"./managed-columns";export*from"./relation-columns";export{ensureNotificationForeignKeys,migrateNotificationTables}from"./notification-tables";export{migrateRbacTables}from"./rbac-tables";export*from"./trait-tables";export*from"./datetime-columns";export*from"./dialect";export*from"./replicas";export*from"./ddl-constraints";export*from"./erd";export*from"./vschema";export*from"./sql-helpers";export*from"./defaults";export*from"./migration-dialect";export*from"./migration-path";export*from"./migration-ledger";export*from"./schema-align";export*from"./hand-written-migrations";export*from"./migration-names";export{comparableIndexKey,postgresIndexStatement}from"./index-shape";export*from"./model-sources";export*from"./package-migrations";export*from"./package-models";export*from"./shadowed-models";export*from"./ensure-database";export{auditForeignKeys,classifyDeclaredFKs,findFkOrphans,fkKey,getDeclaredFKs,getLiveFKs,getLiveTables}from"./fk-audit";export{frameworkRouteAdmission}from"./framework-route-admission";export{auditSchemaDrift,formatSchemaDrift}from"./schema-drift";export{describeIgnoreRule,findIgnoredMigrations,formatIgnoredMigrations,trackIgnoredGeneratedMigrations}from"./ignored-migrations";export{auditUniqueIndexes,getDeclaredUniques,getLiveUniqueIndexes}from"./unique-audit";export{__flushAfterCommitNow,__pendingAfterCommitCount,enqueueAfterCommit,isInTransaction,runInTransactionScope}from"./transaction-context";export{createQueryBuilder,setConfig}from"@stacksjs/query-builder";export{createDynamo,dynamo,EntityQueryBuilder,generateKeyPattern,parseKeyPattern,buildKey,marshall,unmarshall}from"./drivers/dynamodb";export*from"./row-lease";export{readCommittedTransactionOptions,sqliteWriteOptions}from"./transaction-options";
|
|
1
|
+
export{Database,createDatabase,createMysqlDatabase,createPostgresDatabase,createSqliteDatabase,createTursoDatabase}from"./database";export{detectDriver,driverDefaults,getConfigFromEnv,getConnectionString,mergeWithDefaults,validateDriverConfig}from"./driver-config";export*from"./utils";export*from"./row-lock";export*from"./types";export*from"./migrations";export*from"./framework-renames";export{setQueryTracker,logQuery}from"./query-logger";export{addColumnSafely,backfillInBatches,renameColumnSafely}from"./safe-migrations";export{matchedRows,mutationCount}from"./affected-rows";export*from"./seeder";export*from"./drivers";export*from"./custom";export*from"./auth-tables";export*from"./utc-defaults";export*from"./uuid-columns";export*from"./managed-columns";export*from"./relation-columns";export{ensureNotificationForeignKeys,migrateNotificationTables}from"./notification-tables";export{migrateRbacTables}from"./rbac-tables";export*from"./trait-tables";export*from"./datetime-columns";export*from"./dialect";export*from"./replicas";export*from"./ddl-constraints";export*from"./erd";export*from"./vschema";export*from"./sql-helpers";export*from"./table-exists";export*from"./defaults";export*from"./migration-dialect";export*from"./migration-path";export*from"./migration-ledger";export*from"./schema-align";export*from"./hand-written-migrations";export*from"./migration-names";export{comparableIndexKey,postgresIndexStatement}from"./index-shape";export*from"./model-sources";export*from"./package-migrations";export*from"./package-models";export*from"./shadowed-models";export*from"./ensure-database";export{auditForeignKeys,classifyDeclaredFKs,findFkOrphans,fkKey,getDeclaredFKs,getLiveFKs,getLiveTables}from"./fk-audit";export{frameworkRouteAdmission}from"./framework-route-admission";export{auditSchemaDrift,formatSchemaDrift}from"./schema-drift";export{describeIgnoreRule,findIgnoredMigrations,formatIgnoredMigrations,trackIgnoredGeneratedMigrations}from"./ignored-migrations";export{auditUniqueIndexes,getDeclaredUniques,getLiveUniqueIndexes}from"./unique-audit";export{__flushAfterCommitNow,__pendingAfterCommitCount,enqueueAfterCommit,isInTransaction,runInTransactionScope}from"./transaction-context";export{createQueryBuilder,setConfig}from"@stacksjs/query-builder";export{createDynamo,dynamo,EntityQueryBuilder,generateKeyPattern,parseKeyPattern,buildKey,marshall,unmarshall}from"./drivers/dynamodb";export*from"./row-lease";export{readCommittedTransactionOptions,sqliteWriteOptions}from"./transaction-options";
|
package/dist/runtime.d.ts
CHANGED
package/dist/runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./affected-rows";export*from"./dialect";export*from"./replicas";export*from"./sql-helpers";export*from"./transaction-context";export*from"./types";export*from"./utils";export*from"./row-lock";export*from"./row-lease";export{readCommittedTransactionOptions,sqliteWriteOptions}from"./transaction-options";
|
|
1
|
+
export*from"./affected-rows";export*from"./dialect";export*from"./replicas";export*from"./sql-helpers";export*from"./table-exists";export*from"./transaction-context";export*from"./types";export*from"./utils";export*from"./row-lock";export*from"./row-lease";export{readCommittedTransactionOptions,sqliteWriteOptions}from"./transaction-options";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { QueryBuilderDialect } from './dialect';
|
|
2
|
+
export declare function tableExistsSql(dialect: QueryBuilderDialect): string;
|
|
3
|
+
/** `runner` and `dialect` default to the configured `db` and its dialect. */
|
|
4
|
+
export declare function tableExists(table: string, runner?: TableCatalogRunner, dialect?: QueryBuilderDialect): Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* Whether a table exists, asked of the database's own catalog.
|
|
7
|
+
*
|
|
8
|
+
* For telling "this table has not been migrated" apart from every other
|
|
9
|
+
* failure. Matching error text cannot do that reliably: "does not exist" is
|
|
10
|
+
* PostgreSQL's wording for a missing column as well as a missing table, and
|
|
11
|
+
* each driver words it differently. The catalog answers the question directly.
|
|
12
|
+
*
|
|
13
|
+
* PostgreSQL resolves the name through `search_path`, as an unqualified query
|
|
14
|
+
* against the table would. The MySQL-wire dialects look in the current
|
|
15
|
+
* database, and SQLite in `sqlite_master`. The name is always a bound value.
|
|
16
|
+
*/
|
|
17
|
+
export declare interface TableCatalogRunner {
|
|
18
|
+
unsafe: (sql: string, values?: unknown[]) => { execute: () => Promise<unknown> }
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sqlHelpers}from"./sql-helpers";import{db,getDatabaseDialect}from"./utils";export function tableExistsSql(dialect){const param=sqlHelpers(dialect).param(1);if(dialect==="postgres")return`SELECT 1 AS present WHERE to_regclass(quote_ident(${param})) IS NOT NULL`;if(dialect==="sqlite")return`SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = ${param}`;return`SELECT 1 AS present FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ${param}`}export async function tableExists(table,runner=db,dialect=getDatabaseDialect()){const rows=await runner.unsafe(tableExistsSql(dialect),[table]).execute();return Array.isArray(rows)&&rows.length>0}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/database",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.490",
|
|
6
6
|
"description": "The Stacks database integration.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -66,26 +66,26 @@
|
|
|
66
66
|
"prepublishOnly": "bun run build"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@stacksjs/config": "0.75.
|
|
70
|
-
"@stacksjs/env": "0.75.
|
|
71
|
-
"@stacksjs/error-handling": "0.75.
|
|
72
|
-
"@stacksjs/faker": "0.75.
|
|
73
|
-
"@stacksjs/features": "0.75.
|
|
74
|
-
"@stacksjs/logging": "0.75.
|
|
75
|
-
"@stacksjs/model-meta": "0.75.
|
|
76
|
-
"@stacksjs/path": "0.75.
|
|
77
|
-
"@stacksjs/query-builder": "0.75.
|
|
78
|
-
"@stacksjs/security": "0.75.
|
|
79
|
-
"@stacksjs/storage": "0.75.
|
|
80
|
-
"@stacksjs/strings": "0.75.
|
|
69
|
+
"@stacksjs/config": "0.75.490",
|
|
70
|
+
"@stacksjs/env": "0.75.490",
|
|
71
|
+
"@stacksjs/error-handling": "0.75.490",
|
|
72
|
+
"@stacksjs/faker": "0.75.490",
|
|
73
|
+
"@stacksjs/features": "0.75.490",
|
|
74
|
+
"@stacksjs/logging": "0.75.490",
|
|
75
|
+
"@stacksjs/model-meta": "0.75.490",
|
|
76
|
+
"@stacksjs/path": "0.75.490",
|
|
77
|
+
"@stacksjs/query-builder": "0.75.490",
|
|
78
|
+
"@stacksjs/security": "0.75.490",
|
|
79
|
+
"@stacksjs/storage": "0.75.490",
|
|
80
|
+
"@stacksjs/strings": "0.75.490",
|
|
81
81
|
"@stacksjs/ts-validation": "^0.5.7",
|
|
82
82
|
"bun-query-builder": "^0.3.38",
|
|
83
83
|
"dynamodb-tooling": "^0.3.6"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@stacksjs/cli": "0.75.
|
|
87
|
-
"@stacksjs/router": "0.75.
|
|
88
|
-
"@stacksjs/utils": "0.75.
|
|
86
|
+
"@stacksjs/cli": "0.75.490",
|
|
87
|
+
"@stacksjs/router": "0.75.490",
|
|
88
|
+
"@stacksjs/utils": "0.75.490",
|
|
89
89
|
"better-dx": "^0.2.24"
|
|
90
90
|
}
|
|
91
91
|
}
|