@anarchitects/nx-typeorm 0.2.0 → 0.3.0
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/README.md +32 -0
- package/dist/generators/bootstrap/files/lib/src/infrastructure-persistence/migrations/1700000000000_init_schema.ts__tmpl__ +7 -3
- package/dist/generators/migration-api/generator.d.ts +4 -0
- package/dist/generators/migration-api/generator.d.ts.map +1 -0
- package/dist/generators/migration-api/generator.js +1695 -0
- package/dist/generators/migration-api/schema.json +37 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.json +8 -0
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -100,6 +100,38 @@ nx g @anarchitects/nx-typeorm:migration --project=api --name="add users"
|
|
|
100
100
|
- app: `tools/typeorm/migrations`
|
|
101
101
|
- lib: `src/infrastructure-persistence/migrations`
|
|
102
102
|
|
|
103
|
+
`migration-api` (alias: `migration-api-lib`)
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
nx g @anarchitects/nx-typeorm:migration-api --project=data-access --name="init users"
|
|
107
|
+
nx g @anarchitects/nx-typeorm:migration-api-lib --project=data-access --name="init users"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- library-only generator (fails for applications)
|
|
111
|
+
- generates migration files using TypeORM migration API (`QueryRunner`, `Table`,
|
|
112
|
+
`TableColumn`, etc.) without raw SQL strings
|
|
113
|
+
- maintains migration state in
|
|
114
|
+
`src/infrastructure-persistence/migrations/.nx-typeorm-migration-manifest.json`
|
|
115
|
+
- default behavior:
|
|
116
|
+
- no file when entity snapshot is unchanged
|
|
117
|
+
- new consolidated delta migration when entities changed
|
|
118
|
+
- options:
|
|
119
|
+
- required: `--project`
|
|
120
|
+
- required in `fileMode=new` (default): `--name`
|
|
121
|
+
- optional: `--fileMode=new|patch-init` (default `new`)
|
|
122
|
+
- optional: `--entityGlob=<glob-relative-to-project-root>`
|
|
123
|
+
(default `src/infrastructure-persistence/entities/**/*.ts`)
|
|
124
|
+
- optional: `--allowMixedMigrations` to opt into mixed manual/tool migration
|
|
125
|
+
directories
|
|
126
|
+
- optional: `--timestamp=<number>`
|
|
127
|
+
- safety behavior:
|
|
128
|
+
- fails on unsupported/unresolvable decorators/options
|
|
129
|
+
- fails when implicit naming cannot be resolved safely
|
|
130
|
+
- fails on rename-like table/column diffs (manual migration required)
|
|
131
|
+
- `patch-init` only patches bootstrap init migration
|
|
132
|
+
`1700000000000_init_schema.ts` and is only allowed before any generated
|
|
133
|
+
delta migration exists
|
|
134
|
+
|
|
103
135
|
`entity-create` (alias: `entity`)
|
|
104
136
|
|
|
105
137
|
```bash
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
1
|
+
import { MigrationInterface, QueryRunner, Table, TableCheck, TableColumn, TableExclusion, TableForeignKey, TableIndex, TableUnique } from 'typeorm';
|
|
2
2
|
import { <%= className %>_SCHEMA as SCHEMA } from '../schema';
|
|
3
3
|
|
|
4
4
|
export class Init<%= className %>Schema1700000000000 implements MigrationInterface {
|
|
5
|
-
async up(
|
|
6
|
-
await
|
|
5
|
+
async up(queryRunner: QueryRunner): Promise<void> {
|
|
6
|
+
await queryRunner.createSchema(SCHEMA, true);
|
|
7
|
+
// nx-typeorm:migration-api:up:start
|
|
8
|
+
// nx-typeorm:migration-api:up:end
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
async down(): Promise<void> {
|
|
12
|
+
// nx-typeorm:migration-api:down:start
|
|
13
|
+
// nx-typeorm:migration-api:down:end
|
|
10
14
|
// Schema intentionally kept
|
|
11
15
|
}
|
|
12
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/migration-api/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAkBpB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAwM/D,wBAA8B,qBAAqB,CACjD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,2BAA2B,iBA2IrC"}
|