@stacksjs/database 0.74.56 → 0.74.57
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/ignored-migrations.d.ts +17 -0
- package/dist/ignored-migrations.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +16 -16
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*.sql`. The file
|
|
2
|
+
* exists, `buddy migrate` runs it locally and every test passes, and
|
|
3
|
+
* `git add -A` silently leaves it behind. CI and the deploy then build a
|
|
4
|
+
* database without it, and the first sign is a model whose table does not
|
|
5
|
+
* exist: on one app, every request that touched it answered 500 while the
|
|
6
|
+
* deploy reported success.
|
|
7
|
+
*
|
|
8
|
+
* Nothing about that is visible from inside the project — the ignore rule
|
|
9
|
+
* lives in the developer's global git config — so this asks git directly.
|
|
10
|
+
* Outside a git checkout, or without git installed, it answers "none": the
|
|
11
|
+
* check must never be the thing that breaks a migrate.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findIgnoredMigrations(migrationsDir?: string): string[];
|
|
14
|
+
/** Where the ignore comes from, when git can say: `~/.gitignore_global:26:*.sql`. */
|
|
15
|
+
export declare function describeIgnoreRule(migrationsDir: string, file: string): string | null;
|
|
16
|
+
/** The warning `buddy migrate` and `buddy make:migration` print. */
|
|
17
|
+
export declare function formatIgnoredMigrations(files: string[], migrationsDir?: string): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{spawnSync}from"node:child_process";import fs from"node:fs";import{basename,dirname,join}from"node:path";import{path}from"@stacksjs/path";export function findIgnoredMigrations(migrationsDir=path.userMigrationsPath()){let files;try{files=fs.readdirSync(migrationsDir).filter((file)=>file.endsWith(".sql"))}catch{return[]}if(!files.length)return[];try{const result=spawnSync("git",["check-ignore","--stdin"],{cwd:migrationsDir,input:files.join(`
|
|
2
|
+
`),encoding:"utf8",timeout:5000});if(result.status!==0||typeof result.stdout!=="string")return[];return result.stdout.split(`
|
|
3
|
+
`).map((line)=>basename(line.trim())).filter(Boolean).sort()}catch{return[]}}export function describeIgnoreRule(migrationsDir,file){try{const result=spawnSync("git",["check-ignore","-v",file],{cwd:migrationsDir,encoding:"utf8",timeout:5000});return(result.status===0?result.stdout.trim():"").split("\t")[0]||null}catch{return null}}export function formatIgnoredMigrations(files,migrationsDir=path.userMigrationsPath()){const shown=files.slice(0,5).map((file)=>` - database/migrations/${file}`);if(files.length>5)shown.push(` - \u2026and ${files.length-5} more`);const rule=files[0]?describeIgnoreRule(migrationsDir,files[0]):null,gitignore=join(dirname(dirname(migrationsDir)),".gitignore");return[`${files.length===1?"A migration is":`${files.length} migrations are`} ignored by git and will never be committed:`,...shown,rule?`The rule matching them: ${rule}`:"A gitignore rule (often a global `*.sql`) matches them.","They run here, but CI and the deploy will build a database without them.",`Fix: add \`!database/migrations/*.sql\` to ${gitignore}, then \`git add database/migrations\`.`].join(`
|
|
4
|
+
`)}
|
package/dist/index.d.ts
CHANGED
|
@@ -161,6 +161,7 @@ export { auditForeignKeys, classifyDeclaredFKs, findFkOrphans, fkKey, getDeclare
|
|
|
161
161
|
// declare. `migrate` only tracks which files have run, so a database built from
|
|
162
162
|
// a wrong migration set reports "up to date" forever while its columns differ.
|
|
163
163
|
export { auditSchemaDrift, formatSchemaDrift } from './schema-drift';
|
|
164
|
+
export { describeIgnoreRule, findIgnoredMigrations, formatIgnoredMigrations } from './ignored-migrations';
|
|
164
165
|
// Unique-index drift audit (stacksjs/stacks#1952) — compare declared
|
|
165
166
|
// `unique: true` attributes / indexes against live UNIQUE indexes.
|
|
166
167
|
export { auditUniqueIndexes, getDeclaredUniques, getLiveUniqueIndexes } from './unique-audit';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Database,createDatabase,createMysqlDatabase,createPostgresDatabase,createSqliteDatabase}from"./database";export{detectDriver,driverDefaults,getConfigFromEnv,getConnectionString,mergeWithDefaults,validateDriverConfig}from"./driver-config";export*from"./utils";export{BUN_BROKEN_MYSQL_POOL_MESSAGE,BUN_BROKEN_POSTGRES_POOL_MESSAGE,getBrokenDatabasePools,isBrokenBunPoolError}from"./broken-pool";export*from"./types";export*from"./migrations";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"./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{auditSchemaDrift,formatSchemaDrift}from"./schema-drift";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";
|
|
1
|
+
export{Database,createDatabase,createMysqlDatabase,createPostgresDatabase,createSqliteDatabase}from"./database";export{detectDriver,driverDefaults,getConfigFromEnv,getConnectionString,mergeWithDefaults,validateDriverConfig}from"./driver-config";export*from"./utils";export{BUN_BROKEN_MYSQL_POOL_MESSAGE,BUN_BROKEN_POSTGRES_POOL_MESSAGE,getBrokenDatabasePools,isBrokenBunPoolError}from"./broken-pool";export*from"./types";export*from"./migrations";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"./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{auditSchemaDrift,formatSchemaDrift}from"./schema-drift";export{describeIgnoreRule,findIgnoredMigrations,formatIgnoredMigrations}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";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/database",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.57",
|
|
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.74.
|
|
70
|
-
"@stacksjs/env": "0.74.
|
|
71
|
-
"@stacksjs/error-handling": "0.74.
|
|
72
|
-
"@stacksjs/faker": "^0.74.
|
|
73
|
-
"@stacksjs/features": "0.74.
|
|
74
|
-
"@stacksjs/logging": "0.74.
|
|
75
|
-
"@stacksjs/model-meta": "0.74.
|
|
76
|
-
"@stacksjs/path": "0.74.
|
|
77
|
-
"@stacksjs/query-builder": "^0.74.
|
|
78
|
-
"@stacksjs/security": "0.74.
|
|
79
|
-
"@stacksjs/storage": "0.74.
|
|
80
|
-
"@stacksjs/strings": "0.74.
|
|
69
|
+
"@stacksjs/config": "0.74.57",
|
|
70
|
+
"@stacksjs/env": "0.74.57",
|
|
71
|
+
"@stacksjs/error-handling": "0.74.57",
|
|
72
|
+
"@stacksjs/faker": "^0.74.57",
|
|
73
|
+
"@stacksjs/features": "0.74.57",
|
|
74
|
+
"@stacksjs/logging": "0.74.57",
|
|
75
|
+
"@stacksjs/model-meta": "0.74.57",
|
|
76
|
+
"@stacksjs/path": "0.74.57",
|
|
77
|
+
"@stacksjs/query-builder": "^0.74.57",
|
|
78
|
+
"@stacksjs/security": "0.74.57",
|
|
79
|
+
"@stacksjs/storage": "0.74.57",
|
|
80
|
+
"@stacksjs/strings": "0.74.57",
|
|
81
81
|
"@stacksjs/ts-validation": "^0.5.6",
|
|
82
82
|
"bun-query-builder": "^0.2.70",
|
|
83
83
|
"dynamodb-tooling": "^0.3.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@stacksjs/cli": "0.74.
|
|
87
|
-
"@stacksjs/router": "0.74.
|
|
88
|
-
"@stacksjs/utils": "0.74.
|
|
86
|
+
"@stacksjs/cli": "0.74.57",
|
|
87
|
+
"@stacksjs/router": "0.74.57",
|
|
88
|
+
"@stacksjs/utils": "0.74.57",
|
|
89
89
|
"better-dx": "^0.2.24"
|
|
90
90
|
}
|
|
91
91
|
}
|