@geekmidas/testkit 1.0.3 → 1.0.5
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/CHANGELOG.md +12 -0
- package/dist/{Factory-BOX312yd.d.cts → Factory-CUM2767q.d.cts} +2 -2
- package/dist/{Factory-BOX312yd.d.cts.map → Factory-CUM2767q.d.cts.map} +1 -1
- package/dist/{Factory-CVR3GdkW.d.mts → Factory-SFupxRC2.d.mts} +2 -2
- package/dist/{Factory-CVR3GdkW.d.mts.map → Factory-SFupxRC2.d.mts.map} +1 -1
- package/dist/Factory.d.cts +2 -2
- package/dist/Factory.d.mts +2 -2
- package/dist/{KyselyFactory-DRlMv-WT.d.mts → KyselyFactory-OMwcuAX_.d.cts} +3 -3
- package/dist/{KyselyFactory-DRlMv-WT.d.mts.map → KyselyFactory-OMwcuAX_.d.cts.map} +1 -1
- package/dist/{KyselyFactory-Dy5zzV4B.d.cts → KyselyFactory-vAxYodck.d.mts} +3 -3
- package/dist/{KyselyFactory-Dy5zzV4B.d.cts.map → KyselyFactory-vAxYodck.d.mts.map} +1 -1
- package/dist/KyselyFactory.d.cts +3 -3
- package/dist/KyselyFactory.d.mts +3 -3
- package/dist/{ObjectionFactory-CD-WFuMJ.d.cts → ObjectionFactory-BWjB49-i.d.mts} +3 -3
- package/dist/{ObjectionFactory-CD-WFuMJ.d.cts.map → ObjectionFactory-BWjB49-i.d.mts.map} +1 -1
- package/dist/{ObjectionFactory-DkJUf-uM.d.mts → ObjectionFactory-DvmZVHhe.d.cts} +3 -3
- package/dist/{ObjectionFactory-DkJUf-uM.d.mts.map → ObjectionFactory-DvmZVHhe.d.cts.map} +1 -1
- package/dist/ObjectionFactory.d.cts +3 -3
- package/dist/ObjectionFactory.d.mts +3 -3
- package/dist/{PostgresKyselyMigrator-B4pScubb.mjs → PostgresKyselyMigrator-BIKd7G5C.mjs} +16 -3
- package/dist/PostgresKyselyMigrator-BIKd7G5C.mjs.map +1 -0
- package/dist/{PostgresKyselyMigrator-CBltSOq5.d.cts → PostgresKyselyMigrator-CTNftoZK.d.cts} +16 -2
- package/dist/PostgresKyselyMigrator-CTNftoZK.d.cts.map +1 -0
- package/dist/{PostgresKyselyMigrator-C7ljZYvq.cjs → PostgresKyselyMigrator-CqNs3qX8.cjs} +16 -3
- package/dist/PostgresKyselyMigrator-CqNs3qX8.cjs.map +1 -0
- package/dist/{PostgresKyselyMigrator-DrVWncqd.d.mts → PostgresKyselyMigrator-x0uvWs3U.d.mts} +16 -2
- package/dist/PostgresKyselyMigrator-x0uvWs3U.d.mts.map +1 -0
- package/dist/PostgresKyselyMigrator.cjs +2 -2
- package/dist/PostgresKyselyMigrator.d.cts +2 -2
- package/dist/PostgresKyselyMigrator.d.mts +2 -2
- package/dist/PostgresKyselyMigrator.mjs +2 -2
- package/dist/{PostgresMigrator-Bres0U6E.d.cts → PostgresMigrator-C_QQ6q35.d.mts} +15 -2
- package/dist/PostgresMigrator-C_QQ6q35.d.mts.map +1 -0
- package/dist/{PostgresMigrator-S-YYosAC.d.mts → PostgresMigrator-CeYy-eHF.d.cts} +15 -2
- package/dist/PostgresMigrator-CeYy-eHF.d.cts.map +1 -0
- package/dist/{PostgresMigrator-DcP1o-T6.mjs → PostgresMigrator-DVAY04qN.mjs} +16 -2
- package/dist/PostgresMigrator-DVAY04qN.mjs.map +1 -0
- package/dist/{PostgresMigrator-CHiBYEg_.cjs → PostgresMigrator-M9jpzOvN.cjs} +16 -2
- package/dist/PostgresMigrator-M9jpzOvN.cjs.map +1 -0
- package/dist/PostgresMigrator.cjs +1 -1
- package/dist/PostgresMigrator.d.cts +1 -1
- package/dist/PostgresMigrator.d.mts +1 -1
- package/dist/PostgresMigrator.mjs +1 -1
- package/dist/{PostgresObjectionMigrator-CPfBAP7r.d.cts → PostgresObjectionMigrator-1j6YIB1c.d.mts} +2 -2
- package/dist/{PostgresObjectionMigrator-CPfBAP7r.d.cts.map → PostgresObjectionMigrator-1j6YIB1c.d.mts.map} +1 -1
- package/dist/{PostgresObjectionMigrator-DVEqB5tp.d.mts → PostgresObjectionMigrator-DHVC9h_P.d.cts} +2 -2
- package/dist/{PostgresObjectionMigrator-DVEqB5tp.d.mts.map → PostgresObjectionMigrator-DHVC9h_P.d.cts.map} +1 -1
- package/dist/{PostgresObjectionMigrator-BXLAVVwm.cjs → PostgresObjectionMigrator-DSaPhwjY.cjs} +2 -2
- package/dist/{PostgresObjectionMigrator-BXLAVVwm.cjs.map → PostgresObjectionMigrator-DSaPhwjY.cjs.map} +1 -1
- package/dist/{PostgresObjectionMigrator-BJ5X48U8.mjs → PostgresObjectionMigrator-DjPKdUbm.mjs} +2 -2
- package/dist/{PostgresObjectionMigrator-BJ5X48U8.mjs.map → PostgresObjectionMigrator-DjPKdUbm.mjs.map} +1 -1
- package/dist/PostgresObjectionMigrator.cjs +2 -2
- package/dist/PostgresObjectionMigrator.d.cts +2 -2
- package/dist/PostgresObjectionMigrator.d.mts +2 -2
- package/dist/PostgresObjectionMigrator.mjs +2 -2
- package/dist/better-auth.d.cts +2 -2
- package/dist/better-auth.d.mts +2 -2
- package/dist/{directory-DGOcVlKD.d.cts → directory-CYXmolu1.d.mts} +3 -3
- package/dist/{directory-DGOcVlKD.d.cts.map → directory-CYXmolu1.d.mts.map} +1 -1
- package/dist/{directory-YzQUGC5g.d.mts → directory-DAnMWi50.d.cts} +3 -3
- package/dist/{directory-YzQUGC5g.d.mts.map → directory-DAnMWi50.d.cts.map} +1 -1
- package/dist/{faker-DsYCplsG.d.mts → faker-DHh7xs4u.d.mts} +3 -3
- package/dist/{faker-DsYCplsG.d.mts.map → faker-DHh7xs4u.d.mts.map} +1 -1
- package/dist/{faker-Cg76aFNO.d.cts → faker-zVCm31nU.d.cts} +3 -3
- package/dist/{faker-Cg76aFNO.d.cts.map → faker-zVCm31nU.d.cts.map} +1 -1
- package/dist/faker.d.cts +1 -1
- package/dist/faker.d.mts +1 -1
- package/dist/initScript.cjs +1 -0
- package/dist/initScript.cjs.map +1 -1
- package/dist/initScript.d.cts.map +1 -1
- package/dist/initScript.d.mts.map +1 -1
- package/dist/initScript.mjs +1 -0
- package/dist/initScript.mjs.map +1 -1
- package/dist/kysely.cjs +2 -2
- package/dist/kysely.d.cts +5 -5
- package/dist/kysely.d.mts +5 -5
- package/dist/kysely.mjs +2 -2
- package/dist/objection.cjs +2 -2
- package/dist/objection.d.cts +5 -5
- package/dist/objection.d.mts +5 -5
- package/dist/objection.mjs +2 -2
- package/dist/os/directory.d.cts +1 -1
- package/dist/os/directory.d.mts +1 -1
- package/dist/os/index.d.cts +1 -1
- package/dist/os/index.d.mts +1 -1
- package/package.json +3 -3
- package/src/PostgresKyselyMigrator.ts +15 -1
- package/src/PostgresMigrator.ts +19 -2
- package/src/__tests__/PostgresKyselyMigrator.spec.ts +104 -0
- package/src/__tests__/PostgresMigrator.spec.ts +109 -0
- package/src/__tests__/initScript.spec.ts +24 -0
- package/src/initScript.ts +3 -0
- package/dist/PostgresKyselyMigrator-B4pScubb.mjs.map +0 -1
- package/dist/PostgresKyselyMigrator-C7ljZYvq.cjs.map +0 -1
- package/dist/PostgresKyselyMigrator-CBltSOq5.d.cts.map +0 -1
- package/dist/PostgresKyselyMigrator-DrVWncqd.d.mts.map +0 -1
- package/dist/PostgresMigrator-Bres0U6E.d.cts.map +0 -1
- package/dist/PostgresMigrator-CHiBYEg_.cjs.map +0 -1
- package/dist/PostgresMigrator-DcP1o-T6.mjs.map +0 -1
- package/dist/PostgresMigrator-S-YYosAC.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @geekmidas/testkit
|
|
2
2
|
|
|
3
|
+
## 1.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 🐛 [`184c254`](https://github.com/geekmidas/toolbox/commit/184c2547a674d37c48948a9922c947ca98ff1f17) Thanks [@geekmidas](https://github.com/geekmidas)! - Fix script parsing
|
|
8
|
+
|
|
9
|
+
## 1.0.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ✨ [`7815080`](https://github.com/geekmidas/toolbox/commit/781508030df7f67881f5e79349338f62b35ed684) Thanks [@geekmidas](https://github.com/geekmidas)! - Add after create hook for init scripts
|
|
14
|
+
|
|
3
15
|
## 1.0.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
1
|
+
import { FakerFactory } from "./faker-zVCm31nU.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/Factory.d.ts
|
|
4
4
|
|
|
@@ -144,4 +144,4 @@ type ExtractSeedAttrs<T> = T extends ((context: {
|
|
|
144
144
|
//# sourceMappingURL=Factory.d.ts.map
|
|
145
145
|
//#endregion
|
|
146
146
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
|
147
|
-
//# sourceMappingURL=Factory-
|
|
147
|
+
//# sourceMappingURL=Factory-CUM2767q.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory-
|
|
1
|
+
{"version":3,"file":"Factory-CUM2767q.d.cts","names":[],"sources":["../src/Factory.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;;;;;;;;;;AAiD6B,uBAjDP,OAiDO,CAAA,iBAhDX,MAgDW,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cA/Cd,MA+Cc,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;EAavB,OAAA,UAAA,CAAA,aA1CkB,WA0ClB,CAAA,CAAA,MAAA,EA1CuC,IA0CvC,CAAA,EA1C8C,IA0C9C;EA8BF;;;;;;EAK0C,SAAW,MAAA,CAAA,UAAA,MApEhC,QAoEgC,CAAA,CAAA,WAAA,EAnElD,CAmEkD,EAAA,KAAA,CAAA,EAlEvD,UAkEuD,CAlE5C,QAkE4C,CAlEnC,CAkEmC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAjE7D,OAiE6D,CAjErD,OAiEqD,CAjE7C,UAiE6C,CAjElC,QAiEkC,CAjEzB,CAiEyB,CAAA,CAAA,CAAA,CAAA;EAAM;AAAP;AAgChE;;;;;EAKsD,SAAe,UAAA,CAAA,UAAA,MA7FhC,QA6FgC,CAAA,CAAA,KAAA,EAAA,MAAA,EAAA,WAAA,EA3FtD,CA2FsD,EAAA,KAAA,CAAA,EAzFhE,UAyFgE,CAzFrD,QAyFqD,CAzF5C,CAyF4C,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAtFzD,YAsFyD,EAAA,GArF3D,OAqF2D,CArFnD,UAqFmD,CArFxC,QAqFwC,CArF/B,CAqF+B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EApFjE,OAoFiE,CApFzD,OAoFyD,CApFjD,UAoFiD,CApFtC,QAoFsC,CApF7B,CAoF6B,CAAA,CAAA,CAAA,EAAA,CAAA;EAAM;AAAP;AAMpE;;;;AAKI;gCAtF2B,iBACnB,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BT,kFAKA,gBAAgB,aAAa,OAAO,SAAS,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCrD;SAKW;WAAgB;MAAa;MAAS,QAAQ;;;;;KAMzD,sBAAsB;;;;aAK/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
1
|
+
import { FakerFactory } from "./faker-DHh7xs4u.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/Factory.d.ts
|
|
4
4
|
|
|
@@ -144,4 +144,4 @@ type ExtractSeedAttrs<T> = T extends ((context: {
|
|
|
144
144
|
//# sourceMappingURL=Factory.d.ts.map
|
|
145
145
|
//#endregion
|
|
146
146
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
|
147
|
-
//# sourceMappingURL=Factory-
|
|
147
|
+
//# sourceMappingURL=Factory-SFupxRC2.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory-
|
|
1
|
+
{"version":3,"file":"Factory-SFupxRC2.d.mts","names":[],"sources":["../src/Factory.ts"],"sourcesContent":[],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;;;;;;;;;;AAiD6B,uBAjDP,OAiDO,CAAA,iBAhDX,MAgDW,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cA/Cd,MA+Cc,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;EAavB,OAAA,UAAA,CAAA,aA1CkB,WA0ClB,CAAA,CAAA,MAAA,EA1CuC,IA0CvC,CAAA,EA1C8C,IA0C9C;EA8BF;;;;;;EAK0C,SAAW,MAAA,CAAA,UAAA,MApEhC,QAoEgC,CAAA,CAAA,WAAA,EAnElD,CAmEkD,EAAA,KAAA,CAAA,EAlEvD,UAkEuD,CAlE5C,QAkE4C,CAlEnC,CAkEmC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAjE7D,OAiE6D,CAjErD,OAiEqD,CAjE7C,UAiE6C,CAjElC,QAiEkC,CAjEzB,CAiEyB,CAAA,CAAA,CAAA,CAAA;EAAM;AAAP;AAgChE;;;;;EAKsD,SAAe,UAAA,CAAA,UAAA,MA7FhC,QA6FgC,CAAA,CAAA,KAAA,EAAA,MAAA,EAAA,WAAA,EA3FtD,CA2FsD,EAAA,KAAA,CAAA,EAzFhE,UAyFgE,CAzFrD,QAyFqD,CAzF5C,CAyF4C,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAtFzD,YAsFyD,EAAA,GArF3D,OAqF2D,CArFnD,UAqFmD,CArFxC,QAqFwC,CArF/B,CAqF+B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EApFjE,OAoFiE,CApFzD,OAoFyD,CApFjD,UAoFiD,CApFtC,QAoFsC,CApF7B,CAoF6B,CAAA,CAAA,CAAA,EAAA,CAAA;EAAM;AAAP;AAMpE;;;;AAKI;gCAtF2B,iBACnB,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BT,kFAKA,gBAAgB,aAAa,OAAO,SAAS,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCrD;SAKW;WAAgB;MAAa;MAAS,QAAQ;;;;;KAMzD,sBAAsB;;;;aAK/B"}
|
package/dist/Factory.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-
|
|
1
|
+
import "./faker-zVCm31nU.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-CUM2767q.cjs";
|
|
3
3
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
package/dist/Factory.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-
|
|
1
|
+
import "./faker-DHh7xs4u.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder } from "./Factory-SFupxRC2.mjs";
|
|
3
3
|
export { ExtractSeedAttrs, Factory, FactorySeed, MixedFactoryBuilder };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-zVCm31nU.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-CUM2767q.cjs";
|
|
3
3
|
import { ControlledTransaction, Insertable, Kysely, Selectable } from "kysely";
|
|
4
4
|
|
|
5
5
|
//#region src/KyselyFactory.d.ts
|
|
@@ -225,4 +225,4 @@ declare class KyselyFactory<DB, Builders extends Record<string, any>, Seeds exte
|
|
|
225
225
|
//# sourceMappingURL=KyselyFactory.d.ts.map
|
|
226
226
|
//#endregion
|
|
227
227
|
export { KyselyFactory };
|
|
228
|
-
//# sourceMappingURL=KyselyFactory-
|
|
228
|
+
//# sourceMappingURL=KyselyFactory-OMwcuAX_.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KyselyFactory-
|
|
1
|
+
{"version":3,"file":"KyselyFactory-OMwcuAX_.d.cts","names":[],"sources":["../src/KyselyFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GK,cA5GQ,aA4GR,CAAA,EAAA,EAAA,iBA1Ga,MA0Gb,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAzGU,MAyGV,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAxGK,OAwGL,CAxGa,QAwGb,EAxGuB,KAwGvB,CAAA,CAAA;EAAO,QACoB,QAAA;EAAE,QAAC,KAAA;EAAS,QAAvB,EAAA;EAAU;;;;;;;;;;;;;;;;;;;;;EAwJf,OACK,UAAA,CAAA,aA5OoB,WA4OpB,CAAA,CAAA,MAAA,EA5OyC,IA4OzC,CAAA,EA5OgD,IA4OhD;EAAQ;;;;;;;EAClB,WACuB,CAAA,QAAA,EAlOd,QAkOc,EAAA,KAAA,EAjOjB,KAiOiB,EAAA,EAAA,EAhOpB,MAgOoB,CAhOb,EAgOa,CAAA,GAhOP,qBAgOO,CAhOe,EAgOf,EAAA,EAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;;;;;;;;AApQzB;;;;;;;;;;;;;;;;;;;;;;;;mDA0FS,2BACV,QAAQ,WAAW,GAAG,eAAe,QAClD,WAAW,GAAG,sCAGN,WAAW,GAAG,oBAEhB;WAEC;aACE;QACL,OAAO;WACJ;QAEL,QAAQ,WAAW,GAAG,eACtB,QAAQ,QAAQ,WAAW,GAAG,8CAG1B,gBACE,aACL,OAAO,YACJ,iBACH,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAuEgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAqEN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BAGL,iBACH,WAAW,SAAS,SAAS,QAAQ,WAAW,SAAS,UAC5D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAsDlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-DHh7xs4u.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-SFupxRC2.mjs";
|
|
3
3
|
import { ControlledTransaction, Insertable, Kysely, Selectable } from "kysely";
|
|
4
4
|
|
|
5
5
|
//#region src/KyselyFactory.d.ts
|
|
@@ -225,4 +225,4 @@ declare class KyselyFactory<DB, Builders extends Record<string, any>, Seeds exte
|
|
|
225
225
|
//# sourceMappingURL=KyselyFactory.d.ts.map
|
|
226
226
|
//#endregion
|
|
227
227
|
export { KyselyFactory };
|
|
228
|
-
//# sourceMappingURL=KyselyFactory-
|
|
228
|
+
//# sourceMappingURL=KyselyFactory-vAxYodck.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KyselyFactory-
|
|
1
|
+
{"version":3,"file":"KyselyFactory-vAxYodck.d.mts","names":[],"sources":["../src/KyselyFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GK,cA5GQ,aA4GR,CAAA,EAAA,EAAA,iBA1Ga,MA0Gb,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAzGU,MAyGV,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAxGK,OAwGL,CAxGa,QAwGb,EAxGuB,KAwGvB,CAAA,CAAA;EAAO,QACoB,QAAA;EAAE,QAAC,KAAA;EAAS,QAAvB,EAAA;EAAU;;;;;;;;;;;;;;;;;;;;;EAwJf,OACK,UAAA,CAAA,aA5OoB,WA4OpB,CAAA,CAAA,MAAA,EA5OyC,IA4OzC,CAAA,EA5OgD,IA4OhD;EAAQ;;;;;;;EAClB,WACuB,CAAA,QAAA,EAlOd,QAkOc,EAAA,KAAA,EAjOjB,KAiOiB,EAAA,EAAA,EAhOpB,MAgOoB,CAhOb,EAgOa,CAAA,GAhOP,qBAgOO,CAhOe,EAgOf,EAAA,EAAA,CAAA;EAAQ;;;;;;;;;;;;;;;;;;;;;;;AApQzB;;;;;;;;;;;;;;;;;;;;;;;;mDA0FS,2BACV,QAAQ,WAAW,GAAG,eAAe,QAClD,WAAW,GAAG,sCAGN,WAAW,GAAG,oBAEhB;WAEC;aACE;QACL,OAAO;WACJ;QAEL,QAAQ,WAAW,GAAG,eACtB,QAAQ,QAAQ,WAAW,GAAG,8CAG1B,gBACE,aACL,OAAO,YACJ,iBACH,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAuEgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAqEN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BAGL,iBACH,WAAW,SAAS,SAAS,QAAQ,WAAW,SAAS,UAC5D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAsDlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
package/dist/KyselyFactory.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { KyselyFactory } from "./KyselyFactory-
|
|
1
|
+
import "./faker-zVCm31nU.cjs";
|
|
2
|
+
import "./Factory-CUM2767q.cjs";
|
|
3
|
+
import { KyselyFactory } from "./KyselyFactory-OMwcuAX_.cjs";
|
|
4
4
|
export { KyselyFactory };
|
package/dist/KyselyFactory.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { KyselyFactory } from "./KyselyFactory-
|
|
1
|
+
import "./faker-DHh7xs4u.mjs";
|
|
2
|
+
import "./Factory-SFupxRC2.mjs";
|
|
3
|
+
import { KyselyFactory } from "./KyselyFactory-vAxYodck.mjs";
|
|
4
4
|
export { KyselyFactory };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-DHh7xs4u.mjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-SFupxRC2.mjs";
|
|
3
3
|
import { Knex } from "knex";
|
|
4
4
|
import { Model } from "objection";
|
|
5
5
|
|
|
@@ -238,4 +238,4 @@ declare class ObjectionFactory<Builders extends Record<string, any>, Seeds exten
|
|
|
238
238
|
//# sourceMappingURL=ObjectionFactory.d.ts.map
|
|
239
239
|
//#endregion
|
|
240
240
|
export { ObjectionFactory };
|
|
241
|
-
//# sourceMappingURL=ObjectionFactory-
|
|
241
|
+
//# sourceMappingURL=ObjectionFactory-BWjB49-i.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectionFactory-
|
|
1
|
+
{"version":3,"file":"ObjectionFactory-BWjB49-i.d.mts","names":[],"sources":["../src/ObjectionFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Gc,cA1GD,gBA0GC,CAAA,iBAzGI,MAyGJ,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAxGC,MAwGD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAvGJ,OAuGI,CAvGI,QAuGJ,EAvGc,KAuGd,CAAA,CAAA;EAAM,QAAd,QAAA;EAAO,QAqDO,KAAA;EAAQ,QACX,EAAA;EAAK;;;;;;;;;;;;;;;;;;;;;EA2GX,OACuB,UAAA,CAAA,aAnPO,WAmPP,CAAA,CAAA,MAAA,EAnP4B,IAmP5B,CAAA,EAnPmC,IAmPnC;EAAQ;;;;;;;;;;;;;;;;;;;AAzQzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAmFO,qBACR,QAAQ,aAAa,WAAW,QAAQ,aAAa,kCAE1D,aAAa,qBAEV;WAEJ;aACE;QACL;WACG;QAEL,QAAQ,aAAa,WACrB,QAAQ,QAAQ,aAAa,0CAGzB,gBACE,aACL,aACG,iBACH,QAAQ;;;;;;;;wBAqDM,iBACH,WACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAoCgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA+DN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BACe,iBAAiB,WAAW,SAAS,SAC/D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAgFlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FakerFactory } from "./faker-
|
|
2
|
-
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-
|
|
1
|
+
import { FakerFactory } from "./faker-zVCm31nU.cjs";
|
|
2
|
+
import { ExtractSeedAttrs, Factory, FactorySeed } from "./Factory-CUM2767q.cjs";
|
|
3
3
|
import { Knex } from "knex";
|
|
4
4
|
import { Model } from "objection";
|
|
5
5
|
|
|
@@ -238,4 +238,4 @@ declare class ObjectionFactory<Builders extends Record<string, any>, Seeds exten
|
|
|
238
238
|
//# sourceMappingURL=ObjectionFactory.d.ts.map
|
|
239
239
|
//#endregion
|
|
240
240
|
export { ObjectionFactory };
|
|
241
|
-
//# sourceMappingURL=ObjectionFactory-
|
|
241
|
+
//# sourceMappingURL=ObjectionFactory-DvmZVHhe.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectionFactory-
|
|
1
|
+
{"version":3,"file":"ObjectionFactory-DvmZVHhe.d.cts","names":[],"sources":["../src/ObjectionFactory.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0Gc,cA1GD,gBA0GC,CAAA,iBAzGI,MAyGJ,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAxGC,MAwGD,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,SAvGJ,OAuGI,CAvGI,QAuGJ,EAvGc,KAuGd,CAAA,CAAA;EAAM,QAAd,QAAA;EAAO,QAqDO,KAAA;EAAQ,QACX,EAAA;EAAK;;;;;;;;;;;;;;;;;;;;;EA2GX,OACuB,UAAA,CAAA,aAnPO,WAmPP,CAAA,CAAA,MAAA,EAnP4B,IAmP5B,CAAA,EAnPmC,IAmPnC;EAAQ;;;;;;;;;;;;;;;;;;;AAzQzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAmFO,qBACR,QAAQ,aAAa,WAAW,QAAQ,aAAa,kCAE1D,aAAa,qBAEV;WAEJ;aACE;QACL;WACG;QAEL,QAAQ,aAAa,WACrB,QAAQ,QAAQ,aAAa,0CAGzB,gBACE,aACL,aACG,iBACH,QAAQ;;;;;;;;wBAqDM,iBACH,WACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAoCgB,uBACf,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA+DN,sCAEnB,WACL,WAAW,SAAS,SAC1B,QAAQ,QAAQ,WAAW,SAAS;6BACN,sCAEnB,+BACe,iBAAiB,WAAW,SAAS,SAC/D,QAAQ,QAAQ,WAAW,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAgFlB,iBACV,WACF,iBAAiB,MAAM,MAC7B,WAAW,MAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory-
|
|
1
|
+
import "./faker-zVCm31nU.cjs";
|
|
2
|
+
import "./Factory-CUM2767q.cjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory-DvmZVHhe.cjs";
|
|
4
4
|
export { ObjectionFactory };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./faker-
|
|
2
|
-
import "./Factory-
|
|
3
|
-
import { ObjectionFactory } from "./ObjectionFactory-
|
|
1
|
+
import "./faker-DHh7xs4u.mjs";
|
|
2
|
+
import "./Factory-SFupxRC2.mjs";
|
|
3
|
+
import { ObjectionFactory } from "./ObjectionFactory-BWjB49-i.mjs";
|
|
4
4
|
export { ObjectionFactory };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PostgresMigrator } from "./PostgresMigrator-
|
|
1
|
+
import { PostgresMigrator } from "./PostgresMigrator-DVAY04qN.mjs";
|
|
2
2
|
import { Migrator } from "kysely";
|
|
3
3
|
|
|
4
4
|
//#region src/PostgresKyselyMigrator.ts
|
|
@@ -40,6 +40,18 @@ const logger = console;
|
|
|
40
40
|
* const cleanup = await migrator.start();
|
|
41
41
|
* // Run tests...
|
|
42
42
|
* await cleanup();
|
|
43
|
+
*
|
|
44
|
+
* // With afterCreate hook to create per-app users
|
|
45
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
46
|
+
*
|
|
47
|
+
* const migrator = new PostgresKyselyMigrator({
|
|
48
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
49
|
+
* db,
|
|
50
|
+
* provider,
|
|
51
|
+
* afterCreate: async (uri) => {
|
|
52
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
43
55
|
* ```
|
|
44
56
|
*/
|
|
45
57
|
var PostgresKyselyMigrator = class extends PostgresMigrator {
|
|
@@ -50,9 +62,10 @@ var PostgresKyselyMigrator = class extends PostgresMigrator {
|
|
|
50
62
|
* @param options.uri - PostgreSQL connection URI
|
|
51
63
|
* @param options.db - Kysely database instance
|
|
52
64
|
* @param options.provider - Migration provider for locating migration files
|
|
65
|
+
* @param options.afterCreate - Optional hook called after database creation but before migrations
|
|
53
66
|
*/
|
|
54
67
|
constructor(options) {
|
|
55
|
-
super(options.uri);
|
|
68
|
+
super(options.uri, options.afterCreate);
|
|
56
69
|
this.options = options;
|
|
57
70
|
}
|
|
58
71
|
/**
|
|
@@ -79,4 +92,4 @@ var PostgresKyselyMigrator = class extends PostgresMigrator {
|
|
|
79
92
|
|
|
80
93
|
//#endregion
|
|
81
94
|
export { PostgresKyselyMigrator };
|
|
82
|
-
//# sourceMappingURL=PostgresKyselyMigrator-
|
|
95
|
+
//# sourceMappingURL=PostgresKyselyMigrator-BIKd7G5C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresKyselyMigrator-BIKd7G5C.mjs","names":["options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t\tafterCreate?: (uri: string) => Promise<void>;\n\t\t}"],"sources":["../src/PostgresKyselyMigrator.ts"],"sourcesContent":["import { type Kysely, type MigrationProvider, Migrator } from 'kysely';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Kysely ORM.\n * Extends PostgresMigrator to provide Kysely-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import { FileMigrationProvider } from 'kysely';\n * import { PostgresKyselyMigrator } from '@geekmidas/testkit';\n *\n * // Create migration provider\n * const provider = new FileMigrationProvider({\n * fs: require('fs'),\n * path: require('path'),\n * migrationFolder: path.join(__dirname, 'migrations')\n * });\n *\n * // Create Kysely instance\n * const db = new Kysely<Database>({\n * dialect: new PostgresDialect({\n * pool: new Pool({ connectionString: uri })\n * })\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresKyselyMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * db,\n * provider\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n *\n * // With afterCreate hook to create per-app users\n * import { runInitScript } from '@geekmidas/testkit/postgres';\n *\n * const migrator = new PostgresKyselyMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * db,\n * provider,\n * afterCreate: async (uri) => {\n * await runInitScript('docker/postgres/init.sh', uri, env);\n * },\n * });\n * ```\n */\nexport class PostgresKyselyMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresKyselyMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.db - Kysely database instance\n\t * @param options.provider - Migration provider for locating migration files\n\t * @param options.afterCreate - Optional hook called after database creation but before migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t\tafterCreate?: (uri: string) => Promise<void>;\n\t\t},\n\t) {\n\t\tsuper(options.uri, options.afterCreate);\n\t}\n\n\t/**\n\t * Executes Kysely migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\tconst migrator = new Migrator({\n\t\t\tdb: this.options.db,\n\t\t\tprovider: this.options.provider,\n\t\t});\n\t\tconst migrations = await migrator.migrateToLatest();\n\n\t\tif (migrations.error) {\n\t\t\tlogger.error(migrations.error, `Failed to apply migrations`);\n\t\t\tthrow migrations.error;\n\t\t}\n\n\t\tawait this.options.db.destroy();\n\n\t\tlogger.log(`Applied ${migrations.results?.length} migrations successfully`);\n\t}\n}\n"],"mappings":";;;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDf,IAAa,yBAAb,cAA4C,iBAAiB;;;;;;;;;;CAU5D,YACSA,SAMP;AACD,QAAM,QAAQ,KAAK,QAAQ,YAAY;EAP/B;CAQR;;;;;;;;CASD,MAAM,UAAyB;EAC9B,MAAM,WAAW,IAAI,SAAS;GAC7B,IAAI,KAAK,QAAQ;GACjB,UAAU,KAAK,QAAQ;EACvB;EACD,MAAM,aAAa,MAAM,SAAS,iBAAiB;AAEnD,MAAI,WAAW,OAAO;AACrB,UAAO,MAAM,WAAW,QAAQ,4BAA4B;AAC5D,SAAM,WAAW;EACjB;AAED,QAAM,KAAK,QAAQ,GAAG,SAAS;AAE/B,SAAO,KAAK,UAAU,WAAW,SAAS,OAAO,0BAA0B;CAC3E;AACD"}
|
package/dist/{PostgresKyselyMigrator-CBltSOq5.d.cts → PostgresKyselyMigrator-CTNftoZK.d.cts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PostgresMigrator } from "./PostgresMigrator-
|
|
1
|
+
import { PostgresMigrator } from "./PostgresMigrator-CeYy-eHF.cjs";
|
|
2
2
|
import { Kysely, MigrationProvider } from "kysely";
|
|
3
3
|
|
|
4
4
|
//#region src/PostgresKyselyMigrator.d.ts
|
|
@@ -37,6 +37,18 @@ import { Kysely, MigrationProvider } from "kysely";
|
|
|
37
37
|
* const cleanup = await migrator.start();
|
|
38
38
|
* // Run tests...
|
|
39
39
|
* await cleanup();
|
|
40
|
+
*
|
|
41
|
+
* // With afterCreate hook to create per-app users
|
|
42
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
43
|
+
*
|
|
44
|
+
* const migrator = new PostgresKyselyMigrator({
|
|
45
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
46
|
+
* db,
|
|
47
|
+
* provider,
|
|
48
|
+
* afterCreate: async (uri) => {
|
|
49
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
40
52
|
* ```
|
|
41
53
|
*/
|
|
42
54
|
declare class PostgresKyselyMigrator extends PostgresMigrator {
|
|
@@ -48,11 +60,13 @@ declare class PostgresKyselyMigrator extends PostgresMigrator {
|
|
|
48
60
|
* @param options.uri - PostgreSQL connection URI
|
|
49
61
|
* @param options.db - Kysely database instance
|
|
50
62
|
* @param options.provider - Migration provider for locating migration files
|
|
63
|
+
* @param options.afterCreate - Optional hook called after database creation but before migrations
|
|
51
64
|
*/
|
|
52
65
|
constructor(options: {
|
|
53
66
|
uri: string;
|
|
54
67
|
db: Kysely<any>;
|
|
55
68
|
provider: MigrationProvider;
|
|
69
|
+
afterCreate?: (uri: string) => Promise<void>;
|
|
56
70
|
});
|
|
57
71
|
/**
|
|
58
72
|
* Executes Kysely migrations to the latest version.
|
|
@@ -66,4 +80,4 @@ declare class PostgresKyselyMigrator extends PostgresMigrator {
|
|
|
66
80
|
//# sourceMappingURL=PostgresKyselyMigrator.d.ts.map
|
|
67
81
|
//#endregion
|
|
68
82
|
export { PostgresKyselyMigrator };
|
|
69
|
-
//# sourceMappingURL=PostgresKyselyMigrator-
|
|
83
|
+
//# sourceMappingURL=PostgresKyselyMigrator-CTNftoZK.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresKyselyMigrator-CTNftoZK.d.cts","names":[],"sources":["../src/PostgresKyselyMigrator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwDA;;;;;;;AAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA/C,sBAAA,SAA+B,gBAAA;;;;;;;;;;;;;QAarC;cACM;mCACqB;;;;;;;;;aAahB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_PostgresMigrator = require('./PostgresMigrator-
|
|
2
|
+
const require_PostgresMigrator = require('./PostgresMigrator-M9jpzOvN.cjs');
|
|
3
3
|
const kysely = require_chunk.__toESM(require("kysely"));
|
|
4
4
|
|
|
5
5
|
//#region src/PostgresKyselyMigrator.ts
|
|
@@ -41,6 +41,18 @@ const logger = console;
|
|
|
41
41
|
* const cleanup = await migrator.start();
|
|
42
42
|
* // Run tests...
|
|
43
43
|
* await cleanup();
|
|
44
|
+
*
|
|
45
|
+
* // With afterCreate hook to create per-app users
|
|
46
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
47
|
+
*
|
|
48
|
+
* const migrator = new PostgresKyselyMigrator({
|
|
49
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
50
|
+
* db,
|
|
51
|
+
* provider,
|
|
52
|
+
* afterCreate: async (uri) => {
|
|
53
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
54
|
+
* },
|
|
55
|
+
* });
|
|
44
56
|
* ```
|
|
45
57
|
*/
|
|
46
58
|
var PostgresKyselyMigrator = class extends require_PostgresMigrator.PostgresMigrator {
|
|
@@ -51,9 +63,10 @@ var PostgresKyselyMigrator = class extends require_PostgresMigrator.PostgresMigr
|
|
|
51
63
|
* @param options.uri - PostgreSQL connection URI
|
|
52
64
|
* @param options.db - Kysely database instance
|
|
53
65
|
* @param options.provider - Migration provider for locating migration files
|
|
66
|
+
* @param options.afterCreate - Optional hook called after database creation but before migrations
|
|
54
67
|
*/
|
|
55
68
|
constructor(options) {
|
|
56
|
-
super(options.uri);
|
|
69
|
+
super(options.uri, options.afterCreate);
|
|
57
70
|
this.options = options;
|
|
58
71
|
}
|
|
59
72
|
/**
|
|
@@ -85,4 +98,4 @@ Object.defineProperty(exports, 'PostgresKyselyMigrator', {
|
|
|
85
98
|
return PostgresKyselyMigrator;
|
|
86
99
|
}
|
|
87
100
|
});
|
|
88
|
-
//# sourceMappingURL=PostgresKyselyMigrator-
|
|
101
|
+
//# sourceMappingURL=PostgresKyselyMigrator-CqNs3qX8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresKyselyMigrator-CqNs3qX8.cjs","names":["PostgresMigrator","options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t\tafterCreate?: (uri: string) => Promise<void>;\n\t\t}","Migrator"],"sources":["../src/PostgresKyselyMigrator.ts"],"sourcesContent":["import { type Kysely, type MigrationProvider, Migrator } from 'kysely';\nimport { PostgresMigrator } from './PostgresMigrator';\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * PostgreSQL migrator implementation for Kysely ORM.\n * Extends PostgresMigrator to provide Kysely-specific migration functionality.\n * Automatically creates test databases and applies migrations for testing environments.\n *\n * @example\n * ```typescript\n * import { FileMigrationProvider } from 'kysely';\n * import { PostgresKyselyMigrator } from '@geekmidas/testkit';\n *\n * // Create migration provider\n * const provider = new FileMigrationProvider({\n * fs: require('fs'),\n * path: require('path'),\n * migrationFolder: path.join(__dirname, 'migrations')\n * });\n *\n * // Create Kysely instance\n * const db = new Kysely<Database>({\n * dialect: new PostgresDialect({\n * pool: new Pool({ connectionString: uri })\n * })\n * });\n *\n * // Create and use migrator\n * const migrator = new PostgresKyselyMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * db,\n * provider\n * });\n *\n * const cleanup = await migrator.start();\n * // Run tests...\n * await cleanup();\n *\n * // With afterCreate hook to create per-app users\n * import { runInitScript } from '@geekmidas/testkit/postgres';\n *\n * const migrator = new PostgresKyselyMigrator({\n * uri: 'postgresql://localhost:5432/test_db',\n * db,\n * provider,\n * afterCreate: async (uri) => {\n * await runInitScript('docker/postgres/init.sh', uri, env);\n * },\n * });\n * ```\n */\nexport class PostgresKyselyMigrator extends PostgresMigrator {\n\t/**\n\t * Creates a new PostgresKyselyMigrator instance.\n\t *\n\t * @param options - Configuration options\n\t * @param options.uri - PostgreSQL connection URI\n\t * @param options.db - Kysely database instance\n\t * @param options.provider - Migration provider for locating migration files\n\t * @param options.afterCreate - Optional hook called after database creation but before migrations\n\t */\n\tconstructor(\n\t\tprivate options: {\n\t\t\turi: string;\n\t\t\tdb: Kysely<any>;\n\t\t\tprovider: MigrationProvider;\n\t\t\tafterCreate?: (uri: string) => Promise<void>;\n\t\t},\n\t) {\n\t\tsuper(options.uri, options.afterCreate);\n\t}\n\n\t/**\n\t * Executes Kysely migrations to the latest version.\n\t * Implements the abstract migrate() method from PostgresMigrator.\n\t *\n\t * @throws Error if migrations fail to apply\n\t * @returns Promise that resolves when all migrations are applied\n\t */\n\tasync migrate(): Promise<void> {\n\t\tconst migrator = new Migrator({\n\t\t\tdb: this.options.db,\n\t\t\tprovider: this.options.provider,\n\t\t});\n\t\tconst migrations = await migrator.migrateToLatest();\n\n\t\tif (migrations.error) {\n\t\t\tlogger.error(migrations.error, `Failed to apply migrations`);\n\t\t\tthrow migrations.error;\n\t\t}\n\n\t\tawait this.options.db.destroy();\n\n\t\tlogger.log(`Applied ${migrations.results?.length} migrations successfully`);\n\t}\n}\n"],"mappings":";;;;;;;;AAMA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDf,IAAa,yBAAb,cAA4CA,0CAAiB;;;;;;;;;;CAU5D,YACSC,SAMP;AACD,QAAM,QAAQ,KAAK,QAAQ,YAAY;EAP/B;CAQR;;;;;;;;CASD,MAAM,UAAyB;EAC9B,MAAM,WAAW,IAAIC,gBAAS;GAC7B,IAAI,KAAK,QAAQ;GACjB,UAAU,KAAK,QAAQ;EACvB;EACD,MAAM,aAAa,MAAM,SAAS,iBAAiB;AAEnD,MAAI,WAAW,OAAO;AACrB,UAAO,MAAM,WAAW,QAAQ,4BAA4B;AAC5D,SAAM,WAAW;EACjB;AAED,QAAM,KAAK,QAAQ,GAAG,SAAS;AAE/B,SAAO,KAAK,UAAU,WAAW,SAAS,OAAO,0BAA0B;CAC3E;AACD"}
|
package/dist/{PostgresKyselyMigrator-DrVWncqd.d.mts → PostgresKyselyMigrator-x0uvWs3U.d.mts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PostgresMigrator } from "./PostgresMigrator-
|
|
1
|
+
import { PostgresMigrator } from "./PostgresMigrator-C_QQ6q35.mjs";
|
|
2
2
|
import { Kysely, MigrationProvider } from "kysely";
|
|
3
3
|
|
|
4
4
|
//#region src/PostgresKyselyMigrator.d.ts
|
|
@@ -37,6 +37,18 @@ import { Kysely, MigrationProvider } from "kysely";
|
|
|
37
37
|
* const cleanup = await migrator.start();
|
|
38
38
|
* // Run tests...
|
|
39
39
|
* await cleanup();
|
|
40
|
+
*
|
|
41
|
+
* // With afterCreate hook to create per-app users
|
|
42
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
43
|
+
*
|
|
44
|
+
* const migrator = new PostgresKyselyMigrator({
|
|
45
|
+
* uri: 'postgresql://localhost:5432/test_db',
|
|
46
|
+
* db,
|
|
47
|
+
* provider,
|
|
48
|
+
* afterCreate: async (uri) => {
|
|
49
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
40
52
|
* ```
|
|
41
53
|
*/
|
|
42
54
|
declare class PostgresKyselyMigrator extends PostgresMigrator {
|
|
@@ -48,11 +60,13 @@ declare class PostgresKyselyMigrator extends PostgresMigrator {
|
|
|
48
60
|
* @param options.uri - PostgreSQL connection URI
|
|
49
61
|
* @param options.db - Kysely database instance
|
|
50
62
|
* @param options.provider - Migration provider for locating migration files
|
|
63
|
+
* @param options.afterCreate - Optional hook called after database creation but before migrations
|
|
51
64
|
*/
|
|
52
65
|
constructor(options: {
|
|
53
66
|
uri: string;
|
|
54
67
|
db: Kysely<any>;
|
|
55
68
|
provider: MigrationProvider;
|
|
69
|
+
afterCreate?: (uri: string) => Promise<void>;
|
|
56
70
|
});
|
|
57
71
|
/**
|
|
58
72
|
* Executes Kysely migrations to the latest version.
|
|
@@ -66,4 +80,4 @@ declare class PostgresKyselyMigrator extends PostgresMigrator {
|
|
|
66
80
|
//# sourceMappingURL=PostgresKyselyMigrator.d.ts.map
|
|
67
81
|
//#endregion
|
|
68
82
|
export { PostgresKyselyMigrator };
|
|
69
|
-
//# sourceMappingURL=PostgresKyselyMigrator-
|
|
83
|
+
//# sourceMappingURL=PostgresKyselyMigrator-x0uvWs3U.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresKyselyMigrator-x0uvWs3U.d.mts","names":[],"sources":["../src/PostgresKyselyMigrator.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwDA;;;;;;;AAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA/C,sBAAA,SAA+B,gBAAA;;;;;;;;;;;;;QAarC;cACM;mCACqB;;;;;;;;;aAahB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require('./PostgresMigrator-
|
|
2
|
-
const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-
|
|
1
|
+
require('./PostgresMigrator-M9jpzOvN.cjs');
|
|
2
|
+
const require_PostgresKyselyMigrator = require('./PostgresKyselyMigrator-CqNs3qX8.cjs');
|
|
3
3
|
|
|
4
4
|
exports.PostgresKyselyMigrator = require_PostgresKyselyMigrator.PostgresKyselyMigrator;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./PostgresMigrator-
|
|
2
|
-
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-
|
|
1
|
+
import "./PostgresMigrator-CeYy-eHF.cjs";
|
|
2
|
+
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-CTNftoZK.cjs";
|
|
3
3
|
export { PostgresKyselyMigrator };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./PostgresMigrator-
|
|
2
|
-
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-
|
|
1
|
+
import "./PostgresMigrator-C_QQ6q35.mjs";
|
|
2
|
+
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-x0uvWs3U.mjs";
|
|
3
3
|
export { PostgresKyselyMigrator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./PostgresMigrator-
|
|
2
|
-
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-
|
|
1
|
+
import "./PostgresMigrator-DVAY04qN.mjs";
|
|
2
|
+
import { PostgresKyselyMigrator } from "./PostgresKyselyMigrator-BIKd7G5C.mjs";
|
|
3
3
|
|
|
4
4
|
export { PostgresKyselyMigrator };
|
|
@@ -17,6 +17,17 @@
|
|
|
17
17
|
* const migrator = new MyMigrator('postgresql://localhost:5432/test_db');
|
|
18
18
|
* const cleanup = await migrator.start();
|
|
19
19
|
*
|
|
20
|
+
* // With afterCreate hook (e.g. run init script to create per-app users)
|
|
21
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
22
|
+
*
|
|
23
|
+
* const migrator = new MyMigrator(
|
|
24
|
+
* 'postgresql://localhost:5432/test_db',
|
|
25
|
+
* async (uri) => {
|
|
26
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
27
|
+
* },
|
|
28
|
+
* );
|
|
29
|
+
* const cleanup = await migrator.start();
|
|
30
|
+
*
|
|
20
31
|
* // Run tests...
|
|
21
32
|
*
|
|
22
33
|
* // Clean up
|
|
@@ -25,12 +36,14 @@
|
|
|
25
36
|
*/
|
|
26
37
|
declare abstract class PostgresMigrator {
|
|
27
38
|
private uri;
|
|
39
|
+
private afterCreate?;
|
|
28
40
|
/**
|
|
29
41
|
* Creates a new PostgresMigrator instance.
|
|
30
42
|
*
|
|
31
43
|
* @param uri - PostgreSQL connection URI
|
|
44
|
+
* @param afterCreate - Optional hook called after database creation but before migrations
|
|
32
45
|
*/
|
|
33
|
-
constructor(uri: string);
|
|
46
|
+
constructor(uri: string, afterCreate?: ((uri: string) => Promise<void>) | undefined);
|
|
34
47
|
/**
|
|
35
48
|
* Abstract method to be implemented by subclasses.
|
|
36
49
|
* Should contain the migration logic for setting up database schema.
|
|
@@ -83,4 +96,4 @@ declare abstract class PostgresMigrator {
|
|
|
83
96
|
//# sourceMappingURL=PostgresMigrator.d.ts.map
|
|
84
97
|
//#endregion
|
|
85
98
|
export { PostgresMigrator };
|
|
86
|
-
//# sourceMappingURL=PostgresMigrator-
|
|
99
|
+
//# sourceMappingURL=PostgresMigrator-C_QQ6q35.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresMigrator-C_QQ6q35.d.mts","names":[],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":[],"mappings":";;AA4EA;;;;;;AAkGY;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAlGU,gBAAA;;;;;;;;;2DASmB;;;;;;;sBASpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgFT,cAAA"}
|
|
@@ -17,6 +17,17 @@
|
|
|
17
17
|
* const migrator = new MyMigrator('postgresql://localhost:5432/test_db');
|
|
18
18
|
* const cleanup = await migrator.start();
|
|
19
19
|
*
|
|
20
|
+
* // With afterCreate hook (e.g. run init script to create per-app users)
|
|
21
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
22
|
+
*
|
|
23
|
+
* const migrator = new MyMigrator(
|
|
24
|
+
* 'postgresql://localhost:5432/test_db',
|
|
25
|
+
* async (uri) => {
|
|
26
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
27
|
+
* },
|
|
28
|
+
* );
|
|
29
|
+
* const cleanup = await migrator.start();
|
|
30
|
+
*
|
|
20
31
|
* // Run tests...
|
|
21
32
|
*
|
|
22
33
|
* // Clean up
|
|
@@ -25,12 +36,14 @@
|
|
|
25
36
|
*/
|
|
26
37
|
declare abstract class PostgresMigrator {
|
|
27
38
|
private uri;
|
|
39
|
+
private afterCreate?;
|
|
28
40
|
/**
|
|
29
41
|
* Creates a new PostgresMigrator instance.
|
|
30
42
|
*
|
|
31
43
|
* @param uri - PostgreSQL connection URI
|
|
44
|
+
* @param afterCreate - Optional hook called after database creation but before migrations
|
|
32
45
|
*/
|
|
33
|
-
constructor(uri: string);
|
|
46
|
+
constructor(uri: string, afterCreate?: ((uri: string) => Promise<void>) | undefined);
|
|
34
47
|
/**
|
|
35
48
|
* Abstract method to be implemented by subclasses.
|
|
36
49
|
* Should contain the migration logic for setting up database schema.
|
|
@@ -83,4 +96,4 @@ declare abstract class PostgresMigrator {
|
|
|
83
96
|
//# sourceMappingURL=PostgresMigrator.d.ts.map
|
|
84
97
|
//#endregion
|
|
85
98
|
export { PostgresMigrator };
|
|
86
|
-
//# sourceMappingURL=PostgresMigrator-
|
|
99
|
+
//# sourceMappingURL=PostgresMigrator-CeYy-eHF.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresMigrator-CeYy-eHF.d.cts","names":[],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":[],"mappings":";;AA4EA;;;;;;AAkGY;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAlGU,gBAAA;;;;;;;;;2DASmB;;;;;;;sBASpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAgFT,cAAA"}
|
|
@@ -54,6 +54,17 @@ const logger = console;
|
|
|
54
54
|
* const migrator = new MyMigrator('postgresql://localhost:5432/test_db');
|
|
55
55
|
* const cleanup = await migrator.start();
|
|
56
56
|
*
|
|
57
|
+
* // With afterCreate hook (e.g. run init script to create per-app users)
|
|
58
|
+
* import { runInitScript } from '@geekmidas/testkit/postgres';
|
|
59
|
+
*
|
|
60
|
+
* const migrator = new MyMigrator(
|
|
61
|
+
* 'postgresql://localhost:5432/test_db',
|
|
62
|
+
* async (uri) => {
|
|
63
|
+
* await runInitScript('docker/postgres/init.sh', uri, env);
|
|
64
|
+
* },
|
|
65
|
+
* );
|
|
66
|
+
* const cleanup = await migrator.start();
|
|
67
|
+
*
|
|
57
68
|
* // Run tests...
|
|
58
69
|
*
|
|
59
70
|
* // Clean up
|
|
@@ -65,9 +76,11 @@ var PostgresMigrator = class PostgresMigrator {
|
|
|
65
76
|
* Creates a new PostgresMigrator instance.
|
|
66
77
|
*
|
|
67
78
|
* @param uri - PostgreSQL connection URI
|
|
79
|
+
* @param afterCreate - Optional hook called after database creation but before migrations
|
|
68
80
|
*/
|
|
69
|
-
constructor(uri) {
|
|
81
|
+
constructor(uri, afterCreate) {
|
|
70
82
|
this.uri = uri;
|
|
83
|
+
this.afterCreate = afterCreate;
|
|
71
84
|
}
|
|
72
85
|
/**
|
|
73
86
|
* Creates a PostgreSQL database if it doesn't already exist.
|
|
@@ -136,6 +149,7 @@ var PostgresMigrator = class PostgresMigrator {
|
|
|
136
149
|
const { database, db } = await setupClient(this.uri);
|
|
137
150
|
try {
|
|
138
151
|
await PostgresMigrator.create(this.uri);
|
|
152
|
+
if (this.afterCreate) await this.afterCreate(this.uri);
|
|
139
153
|
await this.migrate();
|
|
140
154
|
logger.log(`Migrating database: ${database}`);
|
|
141
155
|
} finally {
|
|
@@ -149,4 +163,4 @@ var PostgresMigrator = class PostgresMigrator {
|
|
|
149
163
|
|
|
150
164
|
//#endregion
|
|
151
165
|
export { PostgresMigrator };
|
|
152
|
-
//# sourceMappingURL=PostgresMigrator-
|
|
166
|
+
//# sourceMappingURL=PostgresMigrator-DVAY04qN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresMigrator-DVAY04qN.mjs","names":["uri: string","afterCreate?: (uri: string) => Promise<void>","error: any"],"sources":["../src/PostgresMigrator.ts"],"sourcesContent":["import pg from 'pg';\n\nconst { Client } = pg;\n\n/**\n * Creates a PostgreSQL client connected to the 'postgres' database.\n * Extracts connection details from the provided URI.\n *\n * @param uri - PostgreSQL connection URI\n * @returns Object containing the target database name and client instance\n *\n * @example\n * ```typescript\n * const { database, db } = await setupClient('postgresql://user:pass@localhost:5432/mydb');\n * // database = 'mydb'\n * // db = Client instance connected to 'postgres' database\n * ```\n */\nasync function setupClient(uri: string) {\n\tconst url = new URL(uri);\n\n\tconst db = new Client({\n\t\tuser: url.username,\n\t\tpassword: url.password,\n\t\thost: url.hostname,\n\t\tport: parseInt(url.port, 10),\n\t\tdatabase: 'postgres',\n\t});\n\n\tlet database = url.pathname.slice(1);\n\tif (database.includes('?')) {\n\t\tdatabase = database.substring(0, database.indexOf('?'));\n\t}\n\treturn { database, db };\n}\n\n/**\n * Default logger instance for migration operations.\n */\nconst logger = console;\n\n/**\n * Abstract base class for PostgreSQL database migration utilities.\n * Provides database creation, migration, and cleanup functionality for testing.\n * Subclasses must implement the migrate() method to define migration logic.\n *\n * @example\n * ```typescript\n * class MyMigrator extends PostgresMigrator {\n * async migrate(): Promise<void> {\n * // Run your migrations here\n * await this.runMigrations();\n * }\n * }\n *\n * // Use in tests\n * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n * const cleanup = await migrator.start();\n *\n * // With afterCreate hook (e.g. run init script to create per-app users)\n * import { runInitScript } from '@geekmidas/testkit/postgres';\n *\n * const migrator = new MyMigrator(\n * 'postgresql://localhost:5432/test_db',\n * async (uri) => {\n * await runInitScript('docker/postgres/init.sh', uri, env);\n * },\n * );\n * const cleanup = await migrator.start();\n *\n * // Run tests...\n *\n * // Clean up\n * await cleanup();\n * ```\n */\nexport abstract class PostgresMigrator {\n\t/**\n\t * Creates a new PostgresMigrator instance.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @param afterCreate - Optional hook called after database creation but before migrations\n\t */\n\tconstructor(\n\t\tprivate uri: string,\n\t\tprivate afterCreate?: (uri: string) => Promise<void>,\n\t) {}\n\n\t/**\n\t * Abstract method to be implemented by subclasses.\n\t * Should contain the migration logic for setting up database schema.\n\t *\n\t * @returns Promise that resolves when migrations are complete\n\t */\n\tabstract migrate(): Promise<void>;\n\n\t/**\n\t * Creates a PostgreSQL database if it doesn't already exist.\n\t * Connects to the 'postgres' database to check and create the target database.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @returns Object indicating whether the database already existed\n\t * @private\n\t */\n\tprivate static async create(\n\t\turi: string,\n\t): Promise<{ alreadyExisted: boolean }> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tconst result = await db.query(\n\t\t\t\t`SELECT * FROM pg_catalog.pg_database WHERE datname = '${database}'`,\n\t\t\t);\n\n\t\t\tif (result.rowCount === 0) {\n\t\t\t\ttry {\n\t\t\t\t\tawait db.query(`CREATE DATABASE \"${database}\"`);\n\t\t\t\t} catch (error: any) {\n\t\t\t\t\t// 42P04 = duplicate_database — another process created it between our check and create\n\t\t\t\t\tif (error?.code === '42P04') {\n\t\t\t\t\t\treturn { alreadyExisted: true };\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\talreadyExisted: result.rowCount ? result.rowCount > 0 : false,\n\t\t\t};\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Drops a PostgreSQL database.\n\t * Used for cleanup after tests are complete.\n\t *\n\t * @param uri - PostgreSQL connection URI\n\t * @throws Error if database cannot be dropped\n\t * @private\n\t */\n\tprivate static async drop(uri: string): Promise<void> {\n\t\tconst { database, db } = await setupClient(uri);\n\t\ttry {\n\t\t\tawait db.connect();\n\t\t\tawait db.query(`DROP DATABASE \"${database}\"`);\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the migration process by creating the database and running migrations.\n\t * Returns a cleanup function that will drop the database when called.\n\t *\n\t * @returns Async cleanup function that drops the created database\n\t *\n\t * @example\n\t * ```typescript\n\t * const migrator = new MyMigrator('postgresql://localhost:5432/test_db');\n\t *\n\t * // Start migrations and get cleanup function\n\t * const cleanup = await migrator.start();\n\t *\n\t * try {\n\t * // Run your tests here\n\t * await runTests();\n\t * } finally {\n\t * // Always clean up\n\t * await cleanup();\n\t * }\n\t * ```\n\t */\n\tasync start() {\n\t\tconst { database, db } = await setupClient(this.uri);\n\t\ttry {\n\t\t\tawait PostgresMigrator.create(this.uri);\n\t\t\tif (this.afterCreate) {\n\t\t\t\tawait this.afterCreate(this.uri);\n\t\t\t}\n\t\t\tawait this.migrate();\n\t\t\tlogger.log(`Migrating database: ${database}`);\n\t\t\t// Example: await db.query('CREATE TABLE example (id SERIAL PRIMARY KEY)');\n\t\t} finally {\n\t\t\tawait db.end();\n\t\t}\n\n\t\treturn async () => {\n\t\t\tawait PostgresMigrator.drop(this.uri);\n\t\t};\n\t}\n}\n"],"mappings":";;;AAEA,MAAM,EAAE,QAAQ,GAAG;;;;;;;;;;;;;;;AAgBnB,eAAe,YAAYA,KAAa;CACvC,MAAM,MAAM,IAAI,IAAI;CAEpB,MAAM,KAAK,IAAI,OAAO;EACrB,MAAM,IAAI;EACV,UAAU,IAAI;EACd,MAAM,IAAI;EACV,MAAM,SAAS,IAAI,MAAM,GAAG;EAC5B,UAAU;CACV;CAED,IAAI,WAAW,IAAI,SAAS,MAAM,EAAE;AACpC,KAAI,SAAS,SAAS,IAAI,CACzB,YAAW,SAAS,UAAU,GAAG,SAAS,QAAQ,IAAI,CAAC;AAExD,QAAO;EAAE;EAAU;CAAI;AACvB;;;;AAKD,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCf,IAAsB,mBAAtB,MAAsB,iBAAiB;;;;;;;CAOtC,YACSA,KACAC,aACP;EAFO;EACA;CACL;;;;;;;;;CAkBJ,aAAqB,OACpBD,KACuC;EACvC,MAAM,EAAE,UAAU,IAAI,GAAG,MAAM,YAAY,IAAI;AAC/C,MAAI;AACH,SAAM,GAAG,SAAS;GAClB,MAAM,SAAS,MAAM,GAAG,OACtB,wDAAwD,SAAS,GAClE;AAED,OAAI,OAAO,aAAa,EACvB,KAAI;AACH,UAAM,GAAG,OAAO,mBAAmB,SAAS,GAAG;GAC/C,SAAQE,OAAY;AAEpB,QAAI,OAAO,SAAS,QACnB,QAAO,EAAE,gBAAgB,KAAM;AAEhC,UAAM;GACN;AAGF,UAAO,EACN,gBAAgB,OAAO,WAAW,OAAO,WAAW,IAAI,MACxD;EACD,UAAS;AACT,SAAM,GAAG,KAAK;EACd;CACD;;;;;;;;;CAUD,aAAqB,KAAKF,KAA4B;EACrD,MAAM,EAAE,UAAU,IAAI,GAAG,MAAM,YAAY,IAAI;AAC/C,MAAI;AACH,SAAM,GAAG,SAAS;AAClB,SAAM,GAAG,OAAO,iBAAiB,SAAS,GAAG;EAC7C,UAAS;AACT,SAAM,GAAG,KAAK;EACd;CACD;;;;;;;;;;;;;;;;;;;;;;;CAwBD,MAAM,QAAQ;EACb,MAAM,EAAE,UAAU,IAAI,GAAG,MAAM,YAAY,KAAK,IAAI;AACpD,MAAI;AACH,SAAM,iBAAiB,OAAO,KAAK,IAAI;AACvC,OAAI,KAAK,YACR,OAAM,KAAK,YAAY,KAAK,IAAI;AAEjC,SAAM,KAAK,SAAS;AACpB,UAAO,KAAK,sBAAsB,SAAS,EAAE;EAE7C,UAAS;AACT,SAAM,GAAG,KAAK;EACd;AAED,SAAO,YAAY;AAClB,SAAM,iBAAiB,KAAK,KAAK,IAAI;EACrC;CACD;AACD"}
|