@contember/engine-system-api 2.1.0-beta.1 → 2.1.0-beta.2
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/development/src/model/migrations/SchemaProvider.cjs +1 -1
- package/dist/development/src/model/migrations/SchemaProvider.cjs.map +1 -1
- package/dist/development/src/model/migrations/SchemaProvider.js +1 -1
- package/dist/development/src/model/migrations/SchemaProvider.js.map +1 -1
- package/dist/development/src/model/queries/schema/SchemaQuery.cjs +5 -1
- package/dist/development/src/model/queries/schema/SchemaQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/schema/SchemaQuery.js +5 -1
- package/dist/development/src/model/queries/schema/SchemaQuery.js.map +1 -1
- package/dist/production/src/model/migrations/SchemaProvider.cjs +1 -1
- package/dist/production/src/model/migrations/SchemaProvider.cjs.map +1 -1
- package/dist/production/src/model/migrations/SchemaProvider.js +1 -1
- package/dist/production/src/model/migrations/SchemaProvider.js.map +1 -1
- package/dist/production/src/model/queries/schema/SchemaQuery.cjs +5 -1
- package/dist/production/src/model/queries/schema/SchemaQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/schema/SchemaQuery.js +5 -1
- package/dist/production/src/model/queries/schema/SchemaQuery.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/model/queries/schema/SchemaQuery.d.ts +2 -1
- package/dist/types/model/queries/schema/SchemaQuery.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/model/migrations/SchemaProvider.ts +1 -1
- package/src/model/queries/schema/SchemaQuery.ts +4 -0
- package/vitest.config.ts +0 -3
|
@@ -43,7 +43,7 @@ class SchemaProvider {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
async fetch({ db, currentSchema }) {
|
|
46
|
-
const newSchema = await db.queryHandler.fetch(new SchemaQuery.SchemaQuery(currentSchema?.meta.checksum));
|
|
46
|
+
const newSchema = await db.queryHandler.fetch(new SchemaQuery.SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version));
|
|
47
47
|
if (!newSchema) {
|
|
48
48
|
return currentSchema ?? emptyVersionedSchema;
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaProvider.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":["emptySchema","calculateSchemaChecksum","SchemaQuery"],"mappings":";;;;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQA,YAAAA;AAAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAUC,YAAAA,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAIC,YAAAA,YAAY,eAAe,KAAK,
|
|
1
|
+
{"version":3,"file":"SchemaProvider.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":["emptySchema","calculateSchemaChecksum","SchemaQuery"],"mappings":";;;;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQA,YAAAA;AAAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAUC,YAAAA,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAIC,YAAAA,YAAY,eAAe,KAAK,UAAU,eAAe,KAAK,OAAO,CAAC;AACxH,QAAI,CAAC,WAAW;AACf,aAAO,iBAAiB;AAAA,IACzB;AAEA,WAAO;AAAA,EACR;AACD;;;"}
|
|
@@ -41,7 +41,7 @@ class SchemaProvider {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async fetch({ db, currentSchema }) {
|
|
44
|
-
const newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum));
|
|
44
|
+
const newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version));
|
|
45
45
|
if (!newSchema) {
|
|
46
46
|
return currentSchema ?? emptyVersionedSchema;
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaProvider.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQ;AAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAU,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAI,YAAY,eAAe,KAAK,
|
|
1
|
+
{"version":3,"file":"SchemaProvider.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQ;AAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAU,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAI,YAAY,eAAe,KAAK,UAAU,eAAe,KAAK,OAAO,CAAC;AACxH,QAAI,CAAC,WAAW;AACf,aAAO,iBAAiB;AAAA,IACzB;AAEA,WAAO;AAAA,EACR;AACD;"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const Database = require("@contember/database");
|
|
4
4
|
class SchemaQuery extends Database.DatabaseQuery {
|
|
5
|
-
constructor(currentHash) {
|
|
5
|
+
constructor(currentHash, currentVersion) {
|
|
6
6
|
super();
|
|
7
7
|
this.currentHash = currentHash;
|
|
8
|
+
this.currentVersion = currentVersion;
|
|
8
9
|
}
|
|
9
10
|
async fetch(queryable) {
|
|
10
11
|
const query = Database.SelectBuilder.create().from("schema").select(new Database.Literal("*")).where({
|
|
@@ -13,6 +14,9 @@ class SchemaQuery extends Database.DatabaseQuery {
|
|
|
13
14
|
if (!this.currentHash) {
|
|
14
15
|
return it;
|
|
15
16
|
}
|
|
17
|
+
if (this.currentVersion) {
|
|
18
|
+
return it.where((it2) => it2.raw("(checksum != ? OR version != ?)", this.currentHash, this.currentVersion));
|
|
19
|
+
}
|
|
16
20
|
return it.where((it2) => it2.raw("checksum != ?", this.currentHash));
|
|
17
21
|
});
|
|
18
22
|
const row = this.fetchOneOrNull(await query.getResult(queryable.db));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaQuery.cjs","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["DatabaseQuery","SelectBuilder","Literal","it"],"mappings":";;;AAIO,MAAM,oBAAoBA,SAAAA,cAAqC;AAAA,EACrE,YACkB,
|
|
1
|
+
{"version":3,"file":"SchemaQuery.cjs","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t\tprivate readonly currentVersion?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\tif (this.currentVersion) {\n\t\t\t\t\treturn it.where(it => it.raw('(checksum != ? OR version != ?)', this.currentHash, this.currentVersion))\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["DatabaseQuery","SelectBuilder","Literal","it"],"mappings":";;;AAIO,MAAM,oBAAoBA,SAAAA,cAAqC;AAAA,EACrE,YACkB,aACA,gBAChB;AACD,UAAA;AAHiB,SAAA,cAAA;AACA,SAAA,iBAAA;AAAA,EAGlB;AAAA,EAEA,MAAM,MAAM,WAA8D;AACzE,UAAM,QAAQC,SAAAA,cAAc,OAAA,EAO1B,KAAK,QAAQ,EACb,OAAO,IAAIC,SAAAA,QAAQ,GAAG,CAAC,EACvB,MAAM;AAAA,MACN,IAAI;AAAA,IAAA,CACJ,EACA,MAAM,CAAA,OAAM;AACZ,UAAI,CAAC,KAAK,aAAa;AACtB,eAAO;AAAA,MACR;AACA,UAAI,KAAK,gBAAgB;AACxB,eAAO,GAAG,MAAM,CAAAC,QAAMA,IAAG,IAAI,mCAAmC,KAAK,aAAa,KAAK,cAAc,CAAC;AAAA,MACvG;AACA,aAAO,GAAG,MAAM,CAAAA,QAAMA,IAAG,IAAI,iBAAiB,KAAK,WAAW,CAAC;AAAA,IAChE,CAAC;AAEF,UAAM,MAAM,KAAK,eAAe,MAAM,MAAM,UAAU,UAAU,EAAE,CAAC;AACnE,QAAI,CAAC,KAAK;AACT,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,QAAQ,IAAI;AAAA,MACZ,MAAM;AAAA,QACL,UAAU,IAAI;AAAA,QACd,SAAS,IAAI;AAAA,QACb,WAAW,IAAI;AAAA,QACf,IAAI,IAAI;AAAA,MAAA;AAAA,IACT;AAAA,EAEF;AACD;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DatabaseQuery, SelectBuilder, Literal } from "@contember/database";
|
|
2
2
|
class SchemaQuery extends DatabaseQuery {
|
|
3
|
-
constructor(currentHash) {
|
|
3
|
+
constructor(currentHash, currentVersion) {
|
|
4
4
|
super();
|
|
5
5
|
this.currentHash = currentHash;
|
|
6
|
+
this.currentVersion = currentVersion;
|
|
6
7
|
}
|
|
7
8
|
async fetch(queryable) {
|
|
8
9
|
const query = SelectBuilder.create().from("schema").select(new Literal("*")).where({
|
|
@@ -11,6 +12,9 @@ class SchemaQuery extends DatabaseQuery {
|
|
|
11
12
|
if (!this.currentHash) {
|
|
12
13
|
return it;
|
|
13
14
|
}
|
|
15
|
+
if (this.currentVersion) {
|
|
16
|
+
return it.where((it2) => it2.raw("(checksum != ? OR version != ?)", this.currentHash, this.currentVersion));
|
|
17
|
+
}
|
|
14
18
|
return it.where((it2) => it2.raw("checksum != ?", this.currentHash));
|
|
15
19
|
});
|
|
16
20
|
const row = this.fetchOneOrNull(await query.getResult(queryable.db));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaQuery.js","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["it"],"mappings":";AAIO,MAAM,oBAAoB,cAAqC;AAAA,EACrE,YACkB,
|
|
1
|
+
{"version":3,"file":"SchemaQuery.js","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t\tprivate readonly currentVersion?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\tif (this.currentVersion) {\n\t\t\t\t\treturn it.where(it => it.raw('(checksum != ? OR version != ?)', this.currentHash, this.currentVersion))\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["it"],"mappings":";AAIO,MAAM,oBAAoB,cAAqC;AAAA,EACrE,YACkB,aACA,gBAChB;AACD,UAAA;AAHiB,SAAA,cAAA;AACA,SAAA,iBAAA;AAAA,EAGlB;AAAA,EAEA,MAAM,MAAM,WAA8D;AACzE,UAAM,QAAQ,cAAc,OAAA,EAO1B,KAAK,QAAQ,EACb,OAAO,IAAI,QAAQ,GAAG,CAAC,EACvB,MAAM;AAAA,MACN,IAAI;AAAA,IAAA,CACJ,EACA,MAAM,CAAA,OAAM;AACZ,UAAI,CAAC,KAAK,aAAa;AACtB,eAAO;AAAA,MACR;AACA,UAAI,KAAK,gBAAgB;AACxB,eAAO,GAAG,MAAM,CAAAA,QAAMA,IAAG,IAAI,mCAAmC,KAAK,aAAa,KAAK,cAAc,CAAC;AAAA,MACvG;AACA,aAAO,GAAG,MAAM,CAAAA,QAAMA,IAAG,IAAI,iBAAiB,KAAK,WAAW,CAAC;AAAA,IAChE,CAAC;AAEF,UAAM,MAAM,KAAK,eAAe,MAAM,MAAM,UAAU,UAAU,EAAE,CAAC;AACnE,QAAI,CAAC,KAAK;AACT,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,QAAQ,IAAI;AAAA,MACZ,MAAM;AAAA,QACL,UAAU,IAAI;AAAA,QACd,SAAS,IAAI;AAAA,QACb,WAAW,IAAI;AAAA,QACf,IAAI,IAAI;AAAA,MAAA;AAAA,IACT;AAAA,EAEF;AACD;"}
|
|
@@ -43,7 +43,7 @@ class SchemaProvider {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
async fetch({ db, currentSchema }) {
|
|
46
|
-
const newSchema = await db.queryHandler.fetch(new SchemaQuery.SchemaQuery(currentSchema?.meta.checksum));
|
|
46
|
+
const newSchema = await db.queryHandler.fetch(new SchemaQuery.SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version));
|
|
47
47
|
if (!newSchema) {
|
|
48
48
|
return currentSchema ?? emptyVersionedSchema;
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaProvider.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":["emptySchema","calculateSchemaChecksum","SchemaQuery"],"mappings":";;;;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQA,YAAAA;AAAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAUC,YAAAA,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAIC,YAAAA,YAAY,eAAe,KAAK,
|
|
1
|
+
{"version":3,"file":"SchemaProvider.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":["emptySchema","calculateSchemaChecksum","SchemaQuery"],"mappings":";;;;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQA,YAAAA;AAAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAUC,YAAAA,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAIC,YAAAA,YAAY,eAAe,KAAK,UAAU,eAAe,KAAK,OAAO,CAAC;AACxH,QAAI,CAAC,WAAW;AACf,aAAO,iBAAiB;AAAA,IACzB;AAEA,WAAO;AAAA,EACR;AACD;;;"}
|
|
@@ -41,7 +41,7 @@ class SchemaProvider {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async fetch({ db, currentSchema }) {
|
|
44
|
-
const newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum));
|
|
44
|
+
const newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version));
|
|
45
45
|
if (!newSchema) {
|
|
46
46
|
return currentSchema ?? emptyVersionedSchema;
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaProvider.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQ;AAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAU,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAI,YAAY,eAAe,KAAK,
|
|
1
|
+
{"version":3,"file":"SchemaProvider.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/SchemaProvider.ts"],"sourcesContent":["import { SchemaQuery } from '../queries'\nimport { DatabaseContext } from '../database'\nimport { calculateSchemaChecksum, emptySchema, normalizeSchema } from '@contember/schema-utils'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { SchemaMigrator } from '@contember/schema-migrations'\nimport { Schema } from '@contember/schema'\n\nexport type SchemaMeta = {\n\tchecksum: string\n\tversion: string\n\tupdatedAt: Date\n\tid: number\n}\n\nexport const emptyVersionedSchema: SchemaWithMeta = {\n\tschema: emptySchema,\n\tmeta: {},\n}\n\nexport type SchemaWithMeta = {\n\tschema: Schema\n\tmeta: SchemaMeta | { [K in keyof SchemaMeta]?: undefined }\n}\n\nexport class SchemaProvider {\n\tconstructor(\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly schemaMigrator: SchemaMigrator,\n\t) {\n\t}\n\n\tasync buildSchemaFromMigrations(db: DatabaseContext): Promise<SchemaWithMeta> {\n\t\tconst newMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\n\t\tconst partialResult = newMigrations.reduce<SchemaWithMeta>(\n\t\t\t(schema, migration) => {\n\t\t\t\treturn {\n\t\t\t\t\tschema: migration.type !== 'schema'\n\t\t\t\t\t\t? schema.schema\n\t\t\t\t\t\t: this.schemaMigrator.applyModifications(schema.schema, migration.modifications, migration.formatVersion),\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tid: migration.id,\n\t\t\t\t\t\tupdatedAt: migration.executedAt,\n\t\t\t\t\t\tchecksum: '',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t\temptyVersionedSchema,\n\t\t)\n\n\t\tif (!partialResult.meta.version) {\n\t\t\treturn emptyVersionedSchema\n\t\t}\n\n\t\treturn {\n\t\t\tschema: partialResult.schema,\n\t\t\tmeta: {\n\t\t\t\t...partialResult.meta,\n\t\t\t\tchecksum: calculateSchemaChecksum(partialResult.schema),\n\t\t\t},\n\t\t}\n\t}\n\n\tpublic async fetch({ db, currentSchema }: {\n\t\tdb: DatabaseContext\n\t\tcurrentSchema?: SchemaWithMeta | null\n\t}): Promise<SchemaWithMeta> {\n\t\tconst newSchema = await db.queryHandler.fetch(new SchemaQuery(currentSchema?.meta.checksum, currentSchema?.meta.version))\n\t\tif (!newSchema) {\n\t\t\treturn currentSchema ?? emptyVersionedSchema\n\t\t}\n\n\t\treturn newSchema\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,uBAAuC;AAAA,EACnD,QAAQ;AAAA,EACR,MAAM,CAAA;AACP;AAOO,MAAM,eAAe;AAAA,EAC3B,YACkB,4BACA,gBAChB;AAFgB,SAAA,6BAAA;AACA,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,0BAA0B,IAA8C;AAC7E,UAAM,gBAAgB,MAAM,KAAK,2BAA2B,cAAc,EAAE;AAE5E,UAAM,gBAAgB,cAAc;AAAA,MACnC,CAAC,QAAQ,cAAc;AACtB,eAAO;AAAA,UACN,QAAQ,UAAU,SAAS,WACxB,OAAO,SACP,KAAK,eAAe,mBAAmB,OAAO,QAAQ,UAAU,eAAe,UAAU,aAAa;AAAA,UACzG,MAAM;AAAA,YACL,SAAS,UAAU;AAAA,YACnB,IAAI,UAAU;AAAA,YACd,WAAW,UAAU;AAAA,YACrB,UAAU;AAAA,UAAA;AAAA,QACX;AAAA,MAEF;AAAA,MACA;AAAA,IAAA;AAGD,QAAI,CAAC,cAAc,KAAK,SAAS;AAChC,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,MACN,QAAQ,cAAc;AAAA,MACtB,MAAM;AAAA,QACL,GAAG,cAAc;AAAA,QACjB,UAAU,wBAAwB,cAAc,MAAM;AAAA,MAAA;AAAA,IACvD;AAAA,EAEF;AAAA,EAEA,MAAa,MAAM,EAAE,IAAI,iBAGG;AAC3B,UAAM,YAAY,MAAM,GAAG,aAAa,MAAM,IAAI,YAAY,eAAe,KAAK,UAAU,eAAe,KAAK,OAAO,CAAC;AACxH,QAAI,CAAC,WAAW;AACf,aAAO,iBAAiB;AAAA,IACzB;AAEA,WAAO;AAAA,EACR;AACD;"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const Database = require("@contember/database");
|
|
4
4
|
class SchemaQuery extends Database.DatabaseQuery {
|
|
5
|
-
constructor(currentHash) {
|
|
5
|
+
constructor(currentHash, currentVersion) {
|
|
6
6
|
super();
|
|
7
7
|
this.currentHash = currentHash;
|
|
8
|
+
this.currentVersion = currentVersion;
|
|
8
9
|
}
|
|
9
10
|
async fetch(queryable) {
|
|
10
11
|
const query = Database.SelectBuilder.create().from("schema").select(new Database.Literal("*")).where({
|
|
@@ -13,6 +14,9 @@ class SchemaQuery extends Database.DatabaseQuery {
|
|
|
13
14
|
if (!this.currentHash) {
|
|
14
15
|
return it;
|
|
15
16
|
}
|
|
17
|
+
if (this.currentVersion) {
|
|
18
|
+
return it.where((it2) => it2.raw("(checksum != ? OR version != ?)", this.currentHash, this.currentVersion));
|
|
19
|
+
}
|
|
16
20
|
return it.where((it2) => it2.raw("checksum != ?", this.currentHash));
|
|
17
21
|
});
|
|
18
22
|
const row = this.fetchOneOrNull(await query.getResult(queryable.db));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaQuery.cjs","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["DatabaseQuery","SelectBuilder","Literal","it"],"mappings":";;;AAIO,MAAM,oBAAoBA,SAAAA,cAAqC;AAAA,EACrE,YACkB,
|
|
1
|
+
{"version":3,"file":"SchemaQuery.cjs","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t\tprivate readonly currentVersion?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\tif (this.currentVersion) {\n\t\t\t\t\treturn it.where(it => it.raw('(checksum != ? OR version != ?)', this.currentHash, this.currentVersion))\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["DatabaseQuery","SelectBuilder","Literal","it"],"mappings":";;;AAIO,MAAM,oBAAoBA,SAAAA,cAAqC;AAAA,EACrE,YACkB,aACA,gBAChB;AACD,UAAA;AAHiB,SAAA,cAAA;AACA,SAAA,iBAAA;AAAA,EAGlB;AAAA,EAEA,MAAM,MAAM,WAA8D;AACzE,UAAM,QAAQC,SAAAA,cAAc,OAAA,EAO1B,KAAK,QAAQ,EACb,OAAO,IAAIC,SAAAA,QAAQ,GAAG,CAAC,EACvB,MAAM;AAAA,MACN,IAAI;AAAA,IAAA,CACJ,EACA,MAAM,CAAA,OAAM;AACZ,UAAI,CAAC,KAAK,aAAa;AACtB,eAAO;AAAA,MACR;AACA,UAAI,KAAK,gBAAgB;AACxB,eAAO,GAAG,MAAM,CAAAC,QAAMA,IAAG,IAAI,mCAAmC,KAAK,aAAa,KAAK,cAAc,CAAC;AAAA,MACvG;AACA,aAAO,GAAG,MAAM,CAAAA,QAAMA,IAAG,IAAI,iBAAiB,KAAK,WAAW,CAAC;AAAA,IAChE,CAAC;AAEF,UAAM,MAAM,KAAK,eAAe,MAAM,MAAM,UAAU,UAAU,EAAE,CAAC;AACnE,QAAI,CAAC,KAAK;AACT,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,QAAQ,IAAI;AAAA,MACZ,MAAM;AAAA,QACL,UAAU,IAAI;AAAA,QACd,SAAS,IAAI;AAAA,QACb,WAAW,IAAI;AAAA,QACf,IAAI,IAAI;AAAA,MAAA;AAAA,IACT;AAAA,EAEF;AACD;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DatabaseQuery, SelectBuilder, Literal } from "@contember/database";
|
|
2
2
|
class SchemaQuery extends DatabaseQuery {
|
|
3
|
-
constructor(currentHash) {
|
|
3
|
+
constructor(currentHash, currentVersion) {
|
|
4
4
|
super();
|
|
5
5
|
this.currentHash = currentHash;
|
|
6
|
+
this.currentVersion = currentVersion;
|
|
6
7
|
}
|
|
7
8
|
async fetch(queryable) {
|
|
8
9
|
const query = SelectBuilder.create().from("schema").select(new Literal("*")).where({
|
|
@@ -11,6 +12,9 @@ class SchemaQuery extends DatabaseQuery {
|
|
|
11
12
|
if (!this.currentHash) {
|
|
12
13
|
return it;
|
|
13
14
|
}
|
|
15
|
+
if (this.currentVersion) {
|
|
16
|
+
return it.where((it2) => it2.raw("(checksum != ? OR version != ?)", this.currentHash, this.currentVersion));
|
|
17
|
+
}
|
|
14
18
|
return it.where((it2) => it2.raw("checksum != ?", this.currentHash));
|
|
15
19
|
});
|
|
16
20
|
const row = this.fetchOneOrNull(await query.getResult(queryable.db));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaQuery.js","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["it"],"mappings":";AAIO,MAAM,oBAAoB,cAAqC;AAAA,EACrE,YACkB,
|
|
1
|
+
{"version":3,"file":"SchemaQuery.js","sources":["../../../../../../../packages/engine-system-api/src/model/queries/schema/SchemaQuery.ts"],"sourcesContent":["import { DatabaseQuery, DatabaseQueryable, Literal, SelectBuilder } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SchemaWithMeta } from '../../migrations'\n\nexport class SchemaQuery extends DatabaseQuery<SchemaWithMeta | null> {\n\tconstructor(\n\t\tprivate readonly currentHash?: string,\n\t\tprivate readonly currentVersion?: string,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync fetch(queryable: DatabaseQueryable): Promise<SchemaWithMeta | null> {\n\t\tconst query = SelectBuilder.create<{\n\t\t\tschema: Schema\n\t\t\tchecksum: string\n\t\t\tversion: string\n\t\t\tupdated_at: Date\n\t\t\tmigration_id: number\n\t\t}>()\n\t\t\t.from('schema')\n\t\t\t.select(new Literal('*'))\n\t\t\t.where({\n\t\t\t\tid: 'single',\n\t\t\t})\n\t\t\t.match(it => {\n\t\t\t\tif (!this.currentHash) {\n\t\t\t\t\treturn it\n\t\t\t\t}\n\t\t\t\tif (this.currentVersion) {\n\t\t\t\t\treturn it.where(it => it.raw('(checksum != ? OR version != ?)', this.currentHash, this.currentVersion))\n\t\t\t\t}\n\t\t\t\treturn it.where(it => it.raw('checksum != ?', this.currentHash))\n\t\t\t})\n\n\t\tconst row = this.fetchOneOrNull(await query.getResult(queryable.db))\n\t\tif (!row) {\n\t\t\treturn null\n\t\t}\n\t\treturn {\n\t\t\tschema: row.schema,\n\t\t\tmeta: {\n\t\t\t\tchecksum: row.checksum,\n\t\t\t\tversion: row.version,\n\t\t\t\tupdatedAt: row.updated_at,\n\t\t\t\tid: row.migration_id,\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["it"],"mappings":";AAIO,MAAM,oBAAoB,cAAqC;AAAA,EACrE,YACkB,aACA,gBAChB;AACD,UAAA;AAHiB,SAAA,cAAA;AACA,SAAA,iBAAA;AAAA,EAGlB;AAAA,EAEA,MAAM,MAAM,WAA8D;AACzE,UAAM,QAAQ,cAAc,OAAA,EAO1B,KAAK,QAAQ,EACb,OAAO,IAAI,QAAQ,GAAG,CAAC,EACvB,MAAM;AAAA,MACN,IAAI;AAAA,IAAA,CACJ,EACA,MAAM,CAAA,OAAM;AACZ,UAAI,CAAC,KAAK,aAAa;AACtB,eAAO;AAAA,MACR;AACA,UAAI,KAAK,gBAAgB;AACxB,eAAO,GAAG,MAAM,CAAAA,QAAMA,IAAG,IAAI,mCAAmC,KAAK,aAAa,KAAK,cAAc,CAAC;AAAA,MACvG;AACA,aAAO,GAAG,MAAM,CAAAA,QAAMA,IAAG,IAAI,iBAAiB,KAAK,WAAW,CAAC;AAAA,IAChE,CAAC;AAEF,UAAM,MAAM,KAAK,eAAe,MAAM,MAAM,UAAU,UAAU,EAAE,CAAC;AACnE,QAAI,CAAC,KAAK;AACT,aAAO;AAAA,IACR;AACA,WAAO;AAAA,MACN,QAAQ,IAAI;AAAA,MACZ,MAAM;AAAA,QACL,UAAU,IAAI;AAAA,QACd,SAAS,IAAI;AAAA,QACb,WAAW,IAAI;AAAA,QACf,IAAI,IAAI;AAAA,MAAA;AAAA,IACT;AAAA,EAEF;AACD;"}
|