@contember/engine-system-api 2.1.0-beta.2 → 2.2.0-alpha.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/CLAUDE.md +16 -2
- package/dist/development/src/SystemContainer.cjs.map +1 -1
- package/dist/development/src/SystemContainer.js.map +1 -1
- package/dist/development/src/migrations/2020-03-27-130000-project-migrations.cjs.map +1 -1
- package/dist/development/src/migrations/2020-03-27-130000-project-migrations.js.map +1 -1
- package/dist/development/src/migrations/2020-05-06-150000-composed-primary.cjs.map +1 -1
- package/dist/development/src/migrations/2020-05-06-150000-composed-primary.js.map +1 -1
- package/dist/development/src/migrations/2020-06-01-103000-event-trigger-perf.cjs.map +1 -1
- package/dist/development/src/migrations/2020-06-01-103000-event-trigger-perf.js.map +1 -1
- package/dist/development/src/migrations/2021-05-07-155800-event-log-rework.cjs.map +1 -1
- package/dist/development/src/migrations/2021-05-07-155800-event-log-rework.js.map +1 -1
- package/dist/development/src/migrations/2021-05-19-1232000-event-log-fix-constraint.cjs.map +1 -1
- package/dist/development/src/migrations/2021-05-19-1232000-event-log-fix-constraint.js.map +1 -1
- package/dist/development/src/migrations/2022-10-03-110000-table-on-delete.cjs.map +1 -1
- package/dist/development/src/migrations/2022-10-03-110000-table-on-delete.js.map +1 -1
- package/dist/development/src/migrations/2023-09-11-174000-fix-on-delete.cjs.map +1 -1
- package/dist/development/src/migrations/2023-09-11-174000-fix-on-delete.js.map +1 -1
- package/dist/development/src/migrations/2023-10-19-173000-fix-unique.cjs.map +1 -1
- package/dist/development/src/migrations/2023-10-19-173000-fix-unique.js.map +1 -1
- package/dist/development/src/migrations/2024-06-28-153001-schema-init.cjs.map +1 -1
- package/dist/development/src/migrations/2024-06-28-153001-schema-init.js.map +1 -1
- package/dist/development/src/migrations/2025-03-14-110000-fix-missing-index.cjs.map +1 -1
- package/dist/development/src/migrations/2025-03-14-110000-fix-missing-index.js.map +1 -1
- package/dist/development/src/migrations/2026-06-01-120000-event-truncate.cjs +13 -0
- package/dist/development/src/migrations/2026-06-01-120000-event-truncate.cjs.map +1 -0
- package/dist/development/src/migrations/2026-06-01-120000-event-truncate.js +14 -0
- package/dist/development/src/migrations/2026-06-01-120000-event-truncate.js.map +1 -0
- package/dist/development/src/migrations/runner.cjs +3 -1
- package/dist/development/src/migrations/runner.cjs.map +1 -1
- package/dist/development/src/migrations/runner.js +3 -1
- package/dist/development/src/migrations/runner.js.map +1 -1
- package/dist/development/src/migrations/snapshot-factory.cjs.map +1 -1
- package/dist/development/src/migrations/snapshot-factory.js.map +1 -1
- package/dist/development/src/migrations/snapshot.cjs +5 -4
- package/dist/development/src/migrations/snapshot.cjs.map +1 -1
- package/dist/development/src/migrations/snapshot.js +5 -4
- package/dist/development/src/migrations/snapshot.js.map +1 -1
- package/dist/development/src/model/ProjectInitializer.cjs.map +1 -1
- package/dist/development/src/model/ProjectInitializer.js.map +1 -1
- package/dist/development/src/model/ProjectTruncateExecutor.cjs +3 -3
- package/dist/development/src/model/ProjectTruncateExecutor.cjs.map +1 -1
- package/dist/development/src/model/ProjectTruncateExecutor.js +3 -3
- package/dist/development/src/model/ProjectTruncateExecutor.js.map +1 -1
- package/dist/development/src/model/authorization/PermissionsFactory.cjs.map +1 -1
- package/dist/development/src/model/authorization/PermissionsFactory.js.map +1 -1
- package/dist/development/src/model/authorization/StagePermissionsFactory.cjs.map +1 -1
- package/dist/development/src/model/authorization/StagePermissionsFactory.js.map +1 -1
- package/dist/development/src/model/authorization/StageScope.cjs.map +1 -1
- package/dist/development/src/model/authorization/StageScope.js.map +1 -1
- package/dist/development/src/model/commands/CommandBus.cjs.map +1 -1
- package/dist/development/src/model/commands/CommandBus.js.map +1 -1
- package/dist/development/src/model/commands/events/TruncateEventsCommand.cjs +25 -2
- package/dist/development/src/model/commands/events/TruncateEventsCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/events/TruncateEventsCommand.js +26 -3
- package/dist/development/src/model/commands/events/TruncateEventsCommand.js.map +1 -1
- package/dist/development/src/model/commands/migrations/DeleteMigrationCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/migrations/DeleteMigrationCommand.js.map +1 -1
- package/dist/development/src/model/commands/migrations/ModifyMigrationCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/migrations/ModifyMigrationCommand.js.map +1 -1
- package/dist/development/src/model/commands/migrations/SaveMigrationCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/migrations/SaveMigrationCommand.js.map +1 -1
- package/dist/development/src/model/commands/schema/SaveSchemaCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/schema/SaveSchemaCommand.js.map +1 -1
- package/dist/development/src/model/commands/stages/CreateStageCommand.cjs.map +1 -1
- package/dist/development/src/model/commands/stages/CreateStageCommand.js.map +1 -1
- package/dist/development/src/model/database/DatabaseContext.cjs.map +1 -1
- package/dist/development/src/model/database/DatabaseContext.js.map +1 -1
- package/dist/development/src/model/events/EventResponseBuilder.cjs +6 -1
- package/dist/development/src/model/events/EventResponseBuilder.cjs.map +1 -1
- package/dist/development/src/model/events/EventResponseBuilder.js +6 -1
- package/dist/development/src/model/events/EventResponseBuilder.js.map +1 -1
- package/dist/development/src/model/events/EventResponseHelper.cjs.map +1 -1
- package/dist/development/src/model/events/EventResponseHelper.js.map +1 -1
- package/dist/development/src/model/events/identityUtils.cjs.map +1 -1
- package/dist/development/src/model/events/identityUtils.js.map +1 -1
- package/dist/development/src/model/events/types.cjs +17 -0
- package/dist/development/src/model/events/types.cjs.map +1 -1
- package/dist/development/src/model/events/types.js +17 -0
- package/dist/development/src/model/events/types.js.map +1 -1
- package/dist/development/src/model/helpers/stageHelpers.cjs.map +1 -1
- package/dist/development/src/model/helpers/stageHelpers.js.map +1 -1
- package/dist/development/src/model/metadata/SchemaDatabaseMetadataResolverStore.cjs.map +1 -1
- package/dist/development/src/model/metadata/SchemaDatabaseMetadataResolverStore.js.map +1 -1
- package/dist/development/src/model/migrations/ExecutedMigrationsResolver.cjs.map +1 -1
- package/dist/development/src/model/migrations/ExecutedMigrationsResolver.js.map +1 -1
- package/dist/development/src/model/migrations/MigrationAlterer.cjs.map +1 -1
- package/dist/development/src/model/migrations/MigrationAlterer.js.map +1 -1
- package/dist/development/src/model/migrations/ProjectMigrator.cjs +94 -5
- package/dist/development/src/model/migrations/ProjectMigrator.cjs.map +1 -1
- package/dist/development/src/model/migrations/ProjectMigrator.js +96 -7
- package/dist/development/src/model/migrations/ProjectMigrator.js.map +1 -1
- package/dist/development/src/model/migrations/SchemaProvider.cjs.map +1 -1
- package/dist/development/src/model/migrations/SchemaProvider.js.map +1 -1
- package/dist/development/src/model/queries/events/EventQueryHelpers.cjs +16 -8
- package/dist/development/src/model/queries/events/EventQueryHelpers.cjs.map +1 -1
- package/dist/development/src/model/queries/events/EventQueryHelpers.js +17 -9
- package/dist/development/src/model/queries/events/EventQueryHelpers.js.map +1 -1
- package/dist/development/src/model/queries/events/EventsQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/events/EventsQuery.js.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationByVersionQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationByVersionQuery.js.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationsQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationsQuery.js.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationsQueryHelper.cjs.map +1 -1
- package/dist/development/src/model/queries/migrations/ExecutedMigrationsQueryHelper.js.map +1 -1
- package/dist/development/src/model/queries/schema/SchemaQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/schema/SchemaQuery.js.map +1 -1
- package/dist/development/src/model/queries/stages/StageBySlugQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/stages/StageBySlugQuery.js.map +1 -1
- package/dist/development/src/model/queries/stages/StageQueryFactory.cjs.map +1 -1
- package/dist/development/src/model/queries/stages/StageQueryFactory.js.map +1 -1
- package/dist/development/src/model/queries/stages/StagesQuery.cjs.map +1 -1
- package/dist/development/src/model/queries/stages/StagesQuery.js.map +1 -1
- package/dist/development/src/model/stages/StageCreator.cjs.map +1 -1
- package/dist/development/src/model/stages/StageCreator.js.map +1 -1
- package/dist/development/src/resolvers/ResolverFactory.cjs +4 -1
- package/dist/development/src/resolvers/ResolverFactory.cjs.map +1 -1
- package/dist/development/src/resolvers/ResolverFactory.js +4 -1
- package/dist/development/src/resolvers/ResolverFactory.js.map +1 -1
- package/dist/development/src/resolvers/SystemResolverContext.cjs.map +1 -1
- package/dist/development/src/resolvers/SystemResolverContext.js.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.cjs +49 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.js +49 -1
- package/dist/development/src/resolvers/mutation/MigrateMutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrationAlterMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/MigrationAlterMutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.cjs +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.js +1 -1
- package/dist/development/src/resolvers/mutation/TruncateMutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/query/EventsQueryResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/query/EventsQueryResolver.js.map +1 -1
- package/dist/development/src/resolvers/query/ExecutedMigrationsQueryResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/query/ExecutedMigrationsQueryResolver.js.map +1 -1
- package/dist/development/src/resolvers/query/SchemaQueryResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/query/SchemaQueryResolver.js.map +1 -1
- package/dist/development/src/resolvers/query/StagesQueryResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/query/StagesQueryResolver.js.map +1 -1
- package/dist/development/src/resolvers/types/EventOldValuesResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/types/EventOldValuesResolver.js.map +1 -1
- package/dist/development/src/resolvers/types/OldValuesHelpers.cjs.map +1 -1
- package/dist/development/src/resolvers/types/OldValuesHelpers.js.map +1 -1
- package/dist/development/src/schema/dev.graphql.cjs +1 -1
- package/dist/development/src/schema/dev.graphql.cjs.map +1 -1
- package/dist/development/src/schema/dev.graphql.js +1 -1
- package/dist/development/src/schema/dev.graphql.js.map +1 -1
- package/dist/development/src/schema/system.graphql.cjs +39 -3
- package/dist/development/src/schema/system.graphql.cjs.map +1 -1
- package/dist/development/src/schema/system.graphql.js +39 -3
- package/dist/development/src/schema/system.graphql.js.map +1 -1
- package/dist/development/src/schema/types.cjs +2 -0
- package/dist/development/src/schema/types.cjs.map +1 -1
- package/dist/development/src/schema/types.js +2 -0
- package/dist/development/src/schema/types.js.map +1 -1
- package/dist/development/src/utils/batchQuery.cjs.map +1 -1
- package/dist/development/src/utils/batchQuery.js.map +1 -1
- package/dist/production/src/SystemContainer.cjs.map +1 -1
- package/dist/production/src/SystemContainer.js.map +1 -1
- package/dist/production/src/migrations/2020-03-27-130000-project-migrations.cjs.map +1 -1
- package/dist/production/src/migrations/2020-03-27-130000-project-migrations.js.map +1 -1
- package/dist/production/src/migrations/2020-05-06-150000-composed-primary.cjs.map +1 -1
- package/dist/production/src/migrations/2020-05-06-150000-composed-primary.js.map +1 -1
- package/dist/production/src/migrations/2020-06-01-103000-event-trigger-perf.cjs.map +1 -1
- package/dist/production/src/migrations/2020-06-01-103000-event-trigger-perf.js.map +1 -1
- package/dist/production/src/migrations/2021-05-07-155800-event-log-rework.cjs.map +1 -1
- package/dist/production/src/migrations/2021-05-07-155800-event-log-rework.js.map +1 -1
- package/dist/production/src/migrations/2021-05-19-1232000-event-log-fix-constraint.cjs.map +1 -1
- package/dist/production/src/migrations/2021-05-19-1232000-event-log-fix-constraint.js.map +1 -1
- package/dist/production/src/migrations/2022-10-03-110000-table-on-delete.cjs.map +1 -1
- package/dist/production/src/migrations/2022-10-03-110000-table-on-delete.js.map +1 -1
- package/dist/production/src/migrations/2023-09-11-174000-fix-on-delete.cjs.map +1 -1
- package/dist/production/src/migrations/2023-09-11-174000-fix-on-delete.js.map +1 -1
- package/dist/production/src/migrations/2023-10-19-173000-fix-unique.cjs.map +1 -1
- package/dist/production/src/migrations/2023-10-19-173000-fix-unique.js.map +1 -1
- package/dist/production/src/migrations/2024-06-28-153001-schema-init.cjs.map +1 -1
- package/dist/production/src/migrations/2024-06-28-153001-schema-init.js.map +1 -1
- package/dist/production/src/migrations/2025-03-14-110000-fix-missing-index.cjs.map +1 -1
- package/dist/production/src/migrations/2025-03-14-110000-fix-missing-index.js.map +1 -1
- package/dist/production/src/migrations/2026-06-01-120000-event-truncate.cjs +13 -0
- package/dist/production/src/migrations/2026-06-01-120000-event-truncate.cjs.map +1 -0
- package/dist/production/src/migrations/2026-06-01-120000-event-truncate.js +14 -0
- package/dist/production/src/migrations/2026-06-01-120000-event-truncate.js.map +1 -0
- package/dist/production/src/migrations/runner.cjs +3 -1
- package/dist/production/src/migrations/runner.cjs.map +1 -1
- package/dist/production/src/migrations/runner.js +3 -1
- package/dist/production/src/migrations/runner.js.map +1 -1
- package/dist/production/src/migrations/snapshot-factory.cjs.map +1 -1
- package/dist/production/src/migrations/snapshot-factory.js.map +1 -1
- package/dist/production/src/migrations/snapshot.cjs +5 -4
- package/dist/production/src/migrations/snapshot.cjs.map +1 -1
- package/dist/production/src/migrations/snapshot.js +5 -4
- package/dist/production/src/migrations/snapshot.js.map +1 -1
- package/dist/production/src/model/ProjectInitializer.cjs.map +1 -1
- package/dist/production/src/model/ProjectInitializer.js.map +1 -1
- package/dist/production/src/model/ProjectTruncateExecutor.cjs +3 -3
- package/dist/production/src/model/ProjectTruncateExecutor.cjs.map +1 -1
- package/dist/production/src/model/ProjectTruncateExecutor.js +3 -3
- package/dist/production/src/model/ProjectTruncateExecutor.js.map +1 -1
- package/dist/production/src/model/authorization/PermissionsFactory.cjs.map +1 -1
- package/dist/production/src/model/authorization/PermissionsFactory.js.map +1 -1
- package/dist/production/src/model/authorization/StagePermissionsFactory.cjs.map +1 -1
- package/dist/production/src/model/authorization/StagePermissionsFactory.js.map +1 -1
- package/dist/production/src/model/authorization/StageScope.cjs.map +1 -1
- package/dist/production/src/model/authorization/StageScope.js.map +1 -1
- package/dist/production/src/model/commands/CommandBus.cjs.map +1 -1
- package/dist/production/src/model/commands/CommandBus.js.map +1 -1
- package/dist/production/src/model/commands/events/TruncateEventsCommand.cjs +25 -2
- package/dist/production/src/model/commands/events/TruncateEventsCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/events/TruncateEventsCommand.js +26 -3
- package/dist/production/src/model/commands/events/TruncateEventsCommand.js.map +1 -1
- package/dist/production/src/model/commands/migrations/DeleteMigrationCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/migrations/DeleteMigrationCommand.js.map +1 -1
- package/dist/production/src/model/commands/migrations/ModifyMigrationCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/migrations/ModifyMigrationCommand.js.map +1 -1
- package/dist/production/src/model/commands/migrations/SaveMigrationCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/migrations/SaveMigrationCommand.js.map +1 -1
- package/dist/production/src/model/commands/schema/SaveSchemaCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/schema/SaveSchemaCommand.js.map +1 -1
- package/dist/production/src/model/commands/stages/CreateStageCommand.cjs.map +1 -1
- package/dist/production/src/model/commands/stages/CreateStageCommand.js.map +1 -1
- package/dist/production/src/model/database/DatabaseContext.cjs.map +1 -1
- package/dist/production/src/model/database/DatabaseContext.js.map +1 -1
- package/dist/production/src/model/events/EventResponseBuilder.cjs +6 -1
- package/dist/production/src/model/events/EventResponseBuilder.cjs.map +1 -1
- package/dist/production/src/model/events/EventResponseBuilder.js +6 -1
- package/dist/production/src/model/events/EventResponseBuilder.js.map +1 -1
- package/dist/production/src/model/events/EventResponseHelper.cjs.map +1 -1
- package/dist/production/src/model/events/EventResponseHelper.js.map +1 -1
- package/dist/production/src/model/events/identityUtils.cjs.map +1 -1
- package/dist/production/src/model/events/identityUtils.js.map +1 -1
- package/dist/production/src/model/events/types.cjs +17 -0
- package/dist/production/src/model/events/types.cjs.map +1 -1
- package/dist/production/src/model/events/types.js +17 -0
- package/dist/production/src/model/events/types.js.map +1 -1
- package/dist/production/src/model/helpers/stageHelpers.cjs.map +1 -1
- package/dist/production/src/model/helpers/stageHelpers.js.map +1 -1
- package/dist/production/src/model/metadata/SchemaDatabaseMetadataResolverStore.cjs.map +1 -1
- package/dist/production/src/model/metadata/SchemaDatabaseMetadataResolverStore.js.map +1 -1
- package/dist/production/src/model/migrations/ExecutedMigrationsResolver.cjs.map +1 -1
- package/dist/production/src/model/migrations/ExecutedMigrationsResolver.js.map +1 -1
- package/dist/production/src/model/migrations/MigrationAlterer.cjs.map +1 -1
- package/dist/production/src/model/migrations/MigrationAlterer.js.map +1 -1
- package/dist/production/src/model/migrations/ProjectMigrator.cjs +94 -5
- package/dist/production/src/model/migrations/ProjectMigrator.cjs.map +1 -1
- package/dist/production/src/model/migrations/ProjectMigrator.js +96 -7
- package/dist/production/src/model/migrations/ProjectMigrator.js.map +1 -1
- package/dist/production/src/model/migrations/SchemaProvider.cjs.map +1 -1
- package/dist/production/src/model/migrations/SchemaProvider.js.map +1 -1
- package/dist/production/src/model/queries/events/EventQueryHelpers.cjs +16 -8
- package/dist/production/src/model/queries/events/EventQueryHelpers.cjs.map +1 -1
- package/dist/production/src/model/queries/events/EventQueryHelpers.js +17 -9
- package/dist/production/src/model/queries/events/EventQueryHelpers.js.map +1 -1
- package/dist/production/src/model/queries/events/EventsQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/events/EventsQuery.js.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationByVersionQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationByVersionQuery.js.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationsQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationsQuery.js.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationsQueryHelper.cjs.map +1 -1
- package/dist/production/src/model/queries/migrations/ExecutedMigrationsQueryHelper.js.map +1 -1
- package/dist/production/src/model/queries/schema/SchemaQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/schema/SchemaQuery.js.map +1 -1
- package/dist/production/src/model/queries/stages/StageBySlugQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/stages/StageBySlugQuery.js.map +1 -1
- package/dist/production/src/model/queries/stages/StageQueryFactory.cjs.map +1 -1
- package/dist/production/src/model/queries/stages/StageQueryFactory.js.map +1 -1
- package/dist/production/src/model/queries/stages/StagesQuery.cjs.map +1 -1
- package/dist/production/src/model/queries/stages/StagesQuery.js.map +1 -1
- package/dist/production/src/model/stages/StageCreator.cjs.map +1 -1
- package/dist/production/src/model/stages/StageCreator.js.map +1 -1
- package/dist/production/src/resolvers/ResolverFactory.cjs +4 -1
- package/dist/production/src/resolvers/ResolverFactory.cjs.map +1 -1
- package/dist/production/src/resolvers/ResolverFactory.js +4 -1
- package/dist/production/src/resolvers/ResolverFactory.js.map +1 -1
- package/dist/production/src/resolvers/SystemResolverContext.cjs.map +1 -1
- package/dist/production/src/resolvers/SystemResolverContext.js.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.cjs +49 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.js +49 -1
- package/dist/production/src/resolvers/mutation/MigrateMutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrationAlterMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/MigrationAlterMutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.cjs +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.js +1 -1
- package/dist/production/src/resolvers/mutation/TruncateMutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/query/EventsQueryResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/query/EventsQueryResolver.js.map +1 -1
- package/dist/production/src/resolvers/query/ExecutedMigrationsQueryResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/query/ExecutedMigrationsQueryResolver.js.map +1 -1
- package/dist/production/src/resolvers/query/SchemaQueryResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/query/SchemaQueryResolver.js.map +1 -1
- package/dist/production/src/resolvers/query/StagesQueryResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/query/StagesQueryResolver.js.map +1 -1
- package/dist/production/src/resolvers/types/EventOldValuesResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/types/EventOldValuesResolver.js.map +1 -1
- package/dist/production/src/resolvers/types/OldValuesHelpers.cjs.map +1 -1
- package/dist/production/src/resolvers/types/OldValuesHelpers.js.map +1 -1
- package/dist/production/src/schema/dev.graphql.cjs +1 -1
- package/dist/production/src/schema/dev.graphql.cjs.map +1 -1
- package/dist/production/src/schema/dev.graphql.js +1 -1
- package/dist/production/src/schema/dev.graphql.js.map +1 -1
- package/dist/production/src/schema/system.graphql.cjs +39 -3
- package/dist/production/src/schema/system.graphql.cjs.map +1 -1
- package/dist/production/src/schema/system.graphql.js +39 -3
- package/dist/production/src/schema/system.graphql.js.map +1 -1
- package/dist/production/src/schema/types.cjs +2 -0
- package/dist/production/src/schema/types.cjs.map +1 -1
- package/dist/production/src/schema/types.js +2 -0
- package/dist/production/src/schema/types.js.map +1 -1
- package/dist/production/src/utils/batchQuery.cjs.map +1 -1
- package/dist/production/src/utils/batchQuery.js.map +1 -1
- package/dist/tests/cases/unit/projectMigratorSchemaState.test.d.ts +2 -0
- package/dist/tests/cases/unit/projectMigratorSchemaState.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/truncateEventsCommand.test.d.ts +2 -0
- package/dist/tests/cases/unit/truncateEventsCommand.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/SystemContainer.d.ts +6 -6
- package/dist/types/SystemContainer.d.ts.map +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migrations/2020-03-27-130000-project-migrations.d.ts +1 -1
- package/dist/types/migrations/2020-03-27-130000-project-migrations.d.ts.map +1 -1
- package/dist/types/migrations/2020-05-06-150000-composed-primary.d.ts +1 -1
- package/dist/types/migrations/2020-05-06-150000-composed-primary.d.ts.map +1 -1
- package/dist/types/migrations/2020-06-01-103000-event-trigger-perf.d.ts +1 -1
- package/dist/types/migrations/2020-06-01-103000-event-trigger-perf.d.ts.map +1 -1
- package/dist/types/migrations/2021-05-07-155800-event-log-rework.d.ts +1 -1
- package/dist/types/migrations/2021-05-07-155800-event-log-rework.d.ts.map +1 -1
- package/dist/types/migrations/2021-05-19-1232000-event-log-fix-constraint.d.ts +1 -1
- package/dist/types/migrations/2021-05-19-1232000-event-log-fix-constraint.d.ts.map +1 -1
- package/dist/types/migrations/2022-10-03-110000-table-on-delete.d.ts +1 -1
- package/dist/types/migrations/2022-10-03-110000-table-on-delete.d.ts.map +1 -1
- package/dist/types/migrations/2023-09-11-174000-fix-on-delete.d.ts +1 -1
- package/dist/types/migrations/2023-09-11-174000-fix-on-delete.d.ts.map +1 -1
- package/dist/types/migrations/2023-10-19-173000-fix-unique.d.ts +1 -1
- package/dist/types/migrations/2023-10-19-173000-fix-unique.d.ts.map +1 -1
- package/dist/types/migrations/2024-06-28-153001-schema-init.d.ts +1 -1
- package/dist/types/migrations/2024-06-28-153001-schema-init.d.ts.map +1 -1
- package/dist/types/migrations/2025-03-14-110000-fix-missing-index.d.ts +1 -1
- package/dist/types/migrations/2025-03-14-110000-fix-missing-index.d.ts.map +1 -1
- package/dist/types/migrations/2026-06-01-120000-event-truncate.d.ts +3 -0
- package/dist/types/migrations/2026-06-01-120000-event-truncate.d.ts.map +1 -0
- package/dist/types/migrations/index.d.ts +2 -2
- package/dist/types/migrations/index.d.ts.map +1 -1
- package/dist/types/migrations/runner.d.ts +2 -2
- package/dist/types/migrations/runner.d.ts.map +1 -1
- package/dist/types/migrations/snapshot-factory.d.ts +1 -1
- package/dist/types/migrations/snapshot-factory.d.ts.map +1 -1
- package/dist/types/migrations/snapshot.d.ts +1 -1
- package/dist/types/migrations/snapshot.d.ts.map +1 -1
- package/dist/types/migrations/types.d.ts +2 -2
- package/dist/types/migrations/types.d.ts.map +1 -1
- package/dist/types/model/ProjectInitializer.d.ts +4 -4
- package/dist/types/model/ProjectInitializer.d.ts.map +1 -1
- package/dist/types/model/ProjectTruncateExecutor.d.ts +3 -3
- package/dist/types/model/ProjectTruncateExecutor.d.ts.map +1 -1
- package/dist/types/model/authorization/StagePermissionsFactory.d.ts +1 -1
- package/dist/types/model/authorization/StagePermissionsFactory.d.ts.map +1 -1
- package/dist/types/model/authorization/StageScope.d.ts +2 -2
- package/dist/types/model/authorization/StageScope.d.ts.map +1 -1
- package/dist/types/model/authorization/index.d.ts +3 -3
- package/dist/types/model/authorization/index.d.ts.map +1 -1
- package/dist/types/model/commands/Command.d.ts +2 -2
- package/dist/types/model/commands/Command.d.ts.map +1 -1
- package/dist/types/model/commands/CommandBus.d.ts +2 -2
- package/dist/types/model/commands/CommandBus.d.ts.map +1 -1
- package/dist/types/model/commands/events/TruncateEventsCommand.d.ts +12 -3
- package/dist/types/model/commands/events/TruncateEventsCommand.d.ts.map +1 -1
- package/dist/types/model/commands/events/index.d.ts +1 -1
- package/dist/types/model/commands/events/index.d.ts.map +1 -1
- package/dist/types/model/commands/index.d.ts +5 -5
- package/dist/types/model/commands/index.d.ts.map +1 -1
- package/dist/types/model/commands/migrations/DeleteMigrationCommand.d.ts +1 -1
- package/dist/types/model/commands/migrations/DeleteMigrationCommand.d.ts.map +1 -1
- package/dist/types/model/commands/migrations/ModifyMigrationCommand.d.ts +1 -1
- package/dist/types/model/commands/migrations/ModifyMigrationCommand.d.ts.map +1 -1
- package/dist/types/model/commands/migrations/SaveMigrationCommand.d.ts +2 -2
- package/dist/types/model/commands/migrations/SaveMigrationCommand.d.ts.map +1 -1
- package/dist/types/model/commands/migrations/index.d.ts +2 -2
- package/dist/types/model/commands/migrations/index.d.ts.map +1 -1
- package/dist/types/model/commands/schema/SaveSchemaCommand.d.ts +2 -2
- package/dist/types/model/commands/schema/SaveSchemaCommand.d.ts.map +1 -1
- package/dist/types/model/commands/stages/CreateStageCommand.d.ts +2 -2
- package/dist/types/model/commands/stages/CreateStageCommand.d.ts.map +1 -1
- package/dist/types/model/commands/stages/TruncateStagesCommand.d.ts +1 -1
- package/dist/types/model/commands/stages/TruncateStagesCommand.d.ts.map +1 -1
- package/dist/types/model/commands/stages/index.d.ts +2 -2
- package/dist/types/model/commands/stages/index.d.ts.map +1 -1
- package/dist/types/model/database/DatabaseContext.d.ts +2 -2
- package/dist/types/model/database/DatabaseContext.d.ts.map +1 -1
- package/dist/types/model/database/index.d.ts +1 -1
- package/dist/types/model/database/index.d.ts.map +1 -1
- package/dist/types/model/dependencies/content/ContentQueryExecutor.d.ts +2 -2
- package/dist/types/model/dependencies/content/ContentQueryExecutor.d.ts.map +1 -1
- package/dist/types/model/dependencies/index.d.ts +2 -2
- package/dist/types/model/dependencies/index.d.ts.map +1 -1
- package/dist/types/model/dependencies/tenant/index.d.ts +1 -1
- package/dist/types/model/dependencies/tenant/index.d.ts.map +1 -1
- package/dist/types/model/dtos/index.d.ts +2 -2
- package/dist/types/model/dtos/index.d.ts.map +1 -1
- package/dist/types/model/events/EventResponseBuilder.d.ts +4 -4
- package/dist/types/model/events/EventResponseBuilder.d.ts.map +1 -1
- package/dist/types/model/events/EventResponseHelper.d.ts +1 -1
- package/dist/types/model/events/EventResponseHelper.d.ts.map +1 -1
- package/dist/types/model/events/identityUtils.d.ts +1 -1
- package/dist/types/model/events/identityUtils.d.ts.map +1 -1
- package/dist/types/model/events/index.d.ts +2 -2
- package/dist/types/model/events/index.d.ts.map +1 -1
- package/dist/types/model/events/types.d.ts +12 -2
- package/dist/types/model/events/types.d.ts.map +1 -1
- package/dist/types/model/helpers/index.d.ts +2 -2
- package/dist/types/model/helpers/index.d.ts.map +1 -1
- package/dist/types/model/helpers/stageHelpers.d.ts +1 -1
- package/dist/types/model/helpers/stageHelpers.d.ts.map +1 -1
- package/dist/types/model/index.d.ts +13 -13
- package/dist/types/model/index.d.ts.map +1 -1
- package/dist/types/model/metadata/SchemaDatabaseMetadataResolverStore.d.ts +1 -1
- package/dist/types/model/metadata/SchemaDatabaseMetadataResolverStore.d.ts.map +1 -1
- package/dist/types/model/metadata/index.d.ts +1 -1
- package/dist/types/model/metadata/index.d.ts.map +1 -1
- package/dist/types/model/migrations/ExecutedMigrationsResolver.d.ts +2 -2
- package/dist/types/model/migrations/ExecutedMigrationsResolver.d.ts.map +1 -1
- package/dist/types/model/migrations/MigrationAlterer.d.ts +3 -3
- package/dist/types/model/migrations/MigrationAlterer.d.ts.map +1 -1
- package/dist/types/model/migrations/MigrationInput.d.ts +6 -0
- package/dist/types/model/migrations/MigrationInput.d.ts.map +1 -1
- package/dist/types/model/migrations/ProjectMigrator.d.ts +28 -10
- package/dist/types/model/migrations/ProjectMigrator.d.ts.map +1 -1
- package/dist/types/model/migrations/SchemaProvider.d.ts +2 -2
- package/dist/types/model/migrations/SchemaProvider.d.ts.map +1 -1
- package/dist/types/model/migrations/index.d.ts +4 -4
- package/dist/types/model/migrations/index.d.ts.map +1 -1
- package/dist/types/model/queries/events/EventQueryHelpers.d.ts +4 -4
- package/dist/types/model/queries/events/EventQueryHelpers.d.ts.map +1 -1
- package/dist/types/model/queries/events/EventsQuery.d.ts +2 -2
- package/dist/types/model/queries/events/EventsQuery.d.ts.map +1 -1
- package/dist/types/model/queries/events/index.d.ts +3 -3
- package/dist/types/model/queries/events/index.d.ts.map +1 -1
- package/dist/types/model/queries/index.d.ts +4 -4
- package/dist/types/model/queries/index.d.ts.map +1 -1
- package/dist/types/model/queries/migrations/ExecutedMigrationByVersionQuery.d.ts +1 -1
- package/dist/types/model/queries/migrations/ExecutedMigrationByVersionQuery.d.ts.map +1 -1
- package/dist/types/model/queries/migrations/ExecutedMigrationsQuery.d.ts +1 -1
- package/dist/types/model/queries/migrations/ExecutedMigrationsQuery.d.ts.map +1 -1
- package/dist/types/model/queries/migrations/ExecutedMigrationsQueryHelper.d.ts +1 -1
- package/dist/types/model/queries/migrations/ExecutedMigrationsQueryHelper.d.ts.map +1 -1
- package/dist/types/model/queries/migrations/index.d.ts +3 -3
- package/dist/types/model/queries/migrations/index.d.ts.map +1 -1
- package/dist/types/model/queries/schema/SchemaQuery.d.ts +1 -1
- package/dist/types/model/queries/schema/SchemaQuery.d.ts.map +1 -1
- package/dist/types/model/queries/schema/index.d.ts +1 -1
- package/dist/types/model/queries/schema/index.d.ts.map +1 -1
- package/dist/types/model/queries/stages/StageBySlugQuery.d.ts +1 -1
- package/dist/types/model/queries/stages/StageBySlugQuery.d.ts.map +1 -1
- package/dist/types/model/queries/stages/StageQueryFactory.d.ts +1 -1
- package/dist/types/model/queries/stages/StageQueryFactory.d.ts.map +1 -1
- package/dist/types/model/queries/stages/StagesQuery.d.ts +1 -1
- package/dist/types/model/queries/stages/StagesQuery.d.ts.map +1 -1
- package/dist/types/model/queries/stages/index.d.ts +3 -3
- package/dist/types/model/queries/stages/index.d.ts.map +1 -1
- package/dist/types/model/stages/StageCreator.d.ts +2 -2
- package/dist/types/model/stages/StageCreator.d.ts.map +1 -1
- package/dist/types/model/stages/index.d.ts +1 -1
- package/dist/types/model/stages/index.d.ts.map +1 -1
- package/dist/types/resolvers/Resolver.d.ts +1 -1
- package/dist/types/resolvers/Resolver.d.ts.map +1 -1
- package/dist/types/resolvers/ResolverFactory.d.ts +5 -5
- package/dist/types/resolvers/ResolverFactory.d.ts.map +1 -1
- package/dist/types/resolvers/SystemResolverContext.d.ts +4 -4
- package/dist/types/resolvers/SystemResolverContext.d.ts.map +1 -1
- package/dist/types/resolvers/index.d.ts +5 -5
- package/dist/types/resolvers/index.d.ts.map +1 -1
- package/dist/types/resolvers/mutation/MigrateMutationResolver.d.ts +6 -4
- package/dist/types/resolvers/mutation/MigrateMutationResolver.d.ts.map +1 -1
- package/dist/types/resolvers/mutation/MigrationAlterMutationResolver.d.ts +4 -4
- package/dist/types/resolvers/mutation/MigrationAlterMutationResolver.d.ts.map +1 -1
- package/dist/types/resolvers/mutation/TruncateMutationResolver.d.ts +4 -4
- package/dist/types/resolvers/mutation/TruncateMutationResolver.d.ts.map +1 -1
- package/dist/types/resolvers/mutation/index.d.ts +3 -3
- package/dist/types/resolvers/mutation/index.d.ts.map +1 -1
- package/dist/types/resolvers/query/EventsQueryResolver.d.ts +4 -4
- package/dist/types/resolvers/query/EventsQueryResolver.d.ts.map +1 -1
- package/dist/types/resolvers/query/ExecutedMigrationsQueryResolver.d.ts +3 -3
- package/dist/types/resolvers/query/ExecutedMigrationsQueryResolver.d.ts.map +1 -1
- package/dist/types/resolvers/query/SchemaQueryResolver.d.ts +2 -2
- package/dist/types/resolvers/query/SchemaQueryResolver.d.ts.map +1 -1
- package/dist/types/resolvers/query/StagesQueryResolver.d.ts +3 -3
- package/dist/types/resolvers/query/StagesQueryResolver.d.ts.map +1 -1
- package/dist/types/resolvers/query/index.d.ts +3 -3
- package/dist/types/resolvers/query/index.d.ts.map +1 -1
- package/dist/types/resolvers/types/EventOldValuesResolver.d.ts +2 -2
- package/dist/types/resolvers/types/EventOldValuesResolver.d.ts.map +1 -1
- package/dist/types/resolvers/types/OldValuesHelpers.d.ts +2 -2
- package/dist/types/resolvers/types/OldValuesHelpers.d.ts.map +1 -1
- package/dist/types/resolvers/types/index.d.ts +1 -1
- package/dist/types/resolvers/types/index.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +2 -2
- package/dist/types/schema/index.d.ts.map +1 -1
- package/dist/types/schema/system.graphql.d.ts.map +1 -1
- package/dist/types/schema/types.d.ts +80 -54
- package/dist/types/schema/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/index.d.ts +7 -7
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/providers.d.ts +1 -1
- package/dist/types/utils/providers.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/SystemContainer.ts +6 -6
- package/src/bin/runMigrations.ts +2 -2
- package/src/index.ts +7 -7
- package/src/migrations/2020-03-27-130000-project-migrations.ts +1 -1
- package/src/migrations/2020-05-06-150000-composed-primary.ts +2 -2
- package/src/migrations/2020-06-01-103000-event-trigger-perf.ts +2 -2
- package/src/migrations/2021-05-07-155800-event-log-rework.ts +2 -2
- package/src/migrations/2021-05-19-1232000-event-log-fix-constraint.ts +2 -2
- package/src/migrations/2022-10-03-110000-table-on-delete.ts +1 -1
- package/src/migrations/2023-09-11-174000-fix-on-delete.ts +1 -1
- package/src/migrations/2023-10-19-173000-fix-unique.ts +1 -1
- package/src/migrations/2024-06-28-153001-schema-init.ts +1 -1
- package/src/migrations/2025-03-14-110000-fix-missing-index.ts +1 -1
- package/src/migrations/2026-06-01-120000-event-truncate.ts +18 -0
- package/src/migrations/index.ts +2 -2
- package/src/migrations/runner.ts +31 -29
- package/src/migrations/snapshot-factory.ts +1 -1
- package/src/migrations/snapshot-template-start.txt +1 -1
- package/src/migrations/snapshot.ts +6 -5
- package/src/migrations/types.ts +2 -2
- package/src/model/ProjectInitializer.ts +4 -4
- package/src/model/ProjectTruncateExecutor.ts +8 -8
- package/src/model/authorization/PermissionsFactory.ts +1 -1
- package/src/model/authorization/StagePermissionsFactory.ts +2 -2
- package/src/model/authorization/StageScope.ts +3 -3
- package/src/model/authorization/index.ts +3 -3
- package/src/model/commands/Command.ts +2 -2
- package/src/model/commands/CommandBus.ts +2 -2
- package/src/model/commands/events/TruncateEventsCommand.ts +45 -5
- package/src/model/commands/events/index.ts +1 -1
- package/src/model/commands/index.ts +5 -5
- package/src/model/commands/migrations/DeleteMigrationCommand.ts +1 -1
- package/src/model/commands/migrations/ModifyMigrationCommand.ts +2 -2
- package/src/model/commands/migrations/SaveMigrationCommand.ts +2 -2
- package/src/model/commands/migrations/index.ts +2 -2
- package/src/model/commands/schema/SaveSchemaCommand.ts +2 -2
- package/src/model/commands/stages/CreateStageCommand.ts +3 -3
- package/src/model/commands/stages/TruncateStagesCommand.ts +1 -1
- package/src/model/commands/stages/index.ts +2 -2
- package/src/model/database/DatabaseContext.ts +2 -2
- package/src/model/database/index.ts +1 -1
- package/src/model/dependencies/content/ContentQueryExecutor.ts +2 -2
- package/src/model/dependencies/index.ts +2 -2
- package/src/model/dependencies/tenant/index.ts +1 -1
- package/src/model/dtos/index.ts +2 -2
- package/src/model/events/EventResponseBuilder.ts +12 -7
- package/src/model/events/EventResponseHelper.ts +1 -1
- package/src/model/events/identityUtils.ts +2 -2
- package/src/model/events/index.ts +2 -2
- package/src/model/events/types.ts +15 -1
- package/src/model/helpers/index.ts +2 -2
- package/src/model/helpers/stageHelpers.ts +1 -1
- package/src/model/index.ts +13 -13
- package/src/model/metadata/SchemaDatabaseMetadataResolverStore.ts +1 -1
- package/src/model/metadata/index.ts +1 -1
- package/src/model/migrations/ExecutedMigrationsResolver.ts +3 -3
- package/src/model/migrations/MigrationAlterer.ts +6 -6
- package/src/model/migrations/MigrationInput.ts +7 -0
- package/src/model/migrations/ProjectMigrator.ts +133 -17
- package/src/model/migrations/SchemaProvider.ts +3 -3
- package/src/model/migrations/index.ts +4 -4
- package/src/model/queries/events/EventQueryHelpers.ts +21 -13
- package/src/model/queries/events/EventsQuery.ts +3 -3
- package/src/model/queries/events/index.ts +3 -3
- package/src/model/queries/index.ts +4 -4
- package/src/model/queries/migrations/ExecutedMigrationByVersionQuery.ts +2 -2
- package/src/model/queries/migrations/ExecutedMigrationsQuery.ts +2 -2
- package/src/model/queries/migrations/ExecutedMigrationsQueryHelper.ts +1 -1
- package/src/model/queries/migrations/index.ts +3 -3
- package/src/model/queries/schema/SchemaQuery.ts +1 -1
- package/src/model/queries/schema/index.ts +1 -1
- package/src/model/queries/stages/StageBySlugQuery.ts +2 -2
- package/src/model/queries/stages/StageQueryFactory.ts +1 -1
- package/src/model/queries/stages/StagesQuery.ts +2 -2
- package/src/model/queries/stages/index.ts +3 -3
- package/src/model/stages/StageCreator.ts +4 -4
- package/src/model/stages/index.ts +1 -1
- package/src/resolvers/Resolver.ts +1 -1
- package/src/resolvers/ResolverFactory.ts +9 -6
- package/src/resolvers/SystemResolverContext.ts +6 -6
- package/src/resolvers/index.ts +5 -5
- package/src/resolvers/mutation/MigrateMutationResolver.ts +64 -7
- package/src/resolvers/mutation/MigrationAlterMutationResolver.ts +4 -4
- package/src/resolvers/mutation/TruncateMutationResolver.ts +5 -5
- package/src/resolvers/mutation/index.ts +3 -3
- package/src/resolvers/query/EventsQueryResolver.ts +4 -4
- package/src/resolvers/query/ExecutedMigrationsQueryResolver.ts +4 -4
- package/src/resolvers/query/SchemaQueryResolver.ts +3 -3
- package/src/resolvers/query/StagesQueryResolver.ts +4 -4
- package/src/resolvers/query/index.ts +3 -3
- package/src/resolvers/types/EventOldValuesResolver.ts +3 -3
- package/src/resolvers/types/OldValuesHelpers.ts +3 -3
- package/src/resolvers/types/index.ts +1 -1
- package/src/schema/dev.graphql.ts +1 -1
- package/src/schema/index.ts +4 -2
- package/src/schema/system.graphql.ts +39 -3
- package/src/schema/types.ts +108 -38
- package/src/utils/batchQuery.ts +1 -1
- package/src/utils/index.ts +7 -7
- package/src/utils/providers.ts +1 -1
- package/tests/cases/migrations/2020-05-06-150000-composed-primary.test.ts +1 -1
- package/tests/cases/migrations/2020-06-01-103000-event-trigger-perf.test.ts +1 -1
- package/tests/cases/migrations/2022-10-03-110000-table-on-delete.test.ts +1 -1
- package/tests/cases/migrations/2023-09-11-174000-fix-on-delete.test.ts +1 -1
- package/tests/cases/migrations/2023-10-19-173000-fix-unique.test.ts +1 -1
- package/tests/cases/migrations/2025-03-14-110000-fix-missing-index.test.ts +1 -1
- package/tests/cases/unit/eventsQuery.test.ts +3 -3
- package/tests/cases/unit/projectMigratorSchemaState.test.ts +48 -0
- package/tests/cases/unit/truncateEventsCommand.test.ts +54 -0
|
@@ -5,6 +5,7 @@ var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
|
5
5
|
EventType2["delete"] = "delete";
|
|
6
6
|
EventType2["update"] = "update";
|
|
7
7
|
EventType2["create"] = "create";
|
|
8
|
+
EventType2["truncate"] = "truncate";
|
|
8
9
|
return EventType2;
|
|
9
10
|
})(EventType || {});
|
|
10
11
|
class UpdateEvent {
|
|
@@ -60,10 +61,26 @@ class DeleteEvent {
|
|
|
60
61
|
);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
class TruncateEvent {
|
|
65
|
+
constructor(id, createdAt, appliedAt, identityId, transactionId) {
|
|
66
|
+
this.id = id;
|
|
67
|
+
this.createdAt = createdAt;
|
|
68
|
+
this.appliedAt = appliedAt;
|
|
69
|
+
this.identityId = identityId;
|
|
70
|
+
this.transactionId = transactionId;
|
|
71
|
+
__publicField(
|
|
72
|
+
this,
|
|
73
|
+
"type",
|
|
74
|
+
"truncate"
|
|
75
|
+
/* truncate */
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
63
79
|
export {
|
|
64
80
|
CreateEvent,
|
|
65
81
|
DeleteEvent,
|
|
66
82
|
EventType,
|
|
83
|
+
TruncateEvent,
|
|
67
84
|
UpdateEvent
|
|
68
85
|
};
|
|
69
86
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../packages/engine-system-api/src/model/events/types.ts"],"sourcesContent":["export enum EventType {\n\tdelete = 'delete',\n\tupdate = 'update',\n\tcreate = 'create',\n}\n\nexport type ContentEvent = UpdateEvent | CreateEvent | DeleteEvent\n\nexport interface Event {\n\treadonly type: EventType\n\treadonly id: string\n\treadonly createdAt: Date\n\treadonly transactionId: string\n\t// readonly errors?: string[]\n}\n\nexport class UpdateEvent implements Event {\n\tpublic readonly type = EventType.update\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly createdAt: Date,\n\t\tpublic readonly appliedAt: Date,\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly transactionId: string,\n\t\tpublic readonly rowId: string[],\n\t\tpublic readonly tableName: string,\n\t\tpublic readonly values: { [column: string]: any },\n\t) {\n\t}\n}\n\nexport class CreateEvent implements Event {\n\tpublic readonly type = EventType.create\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly createdAt: Date,\n\t\tpublic readonly appliedAt: Date,\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly transactionId: string,\n\t\tpublic readonly rowId: string[],\n\t\tpublic readonly tableName: string,\n\t\tpublic readonly values: { [column: string]: any },\n\t) {\n\t}\n}\n\nexport class DeleteEvent implements Event {\n\tpublic readonly type = EventType.delete\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly createdAt: Date,\n\t\tpublic readonly appliedAt: Date,\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly transactionId: string,\n\t\tpublic readonly rowId: string[],\n\t\tpublic readonly tableName: string,\n\t) {\n\t}\n}\n"],"names":["EventType"],"mappings":";;;AAAO,IAAK,8BAAAA,eAAL;AACNA,aAAA,QAAA,IAAS;AACTA,aAAA,QAAA,IAAS;AACTA,aAAA,QAAA,IAAS;
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../packages/engine-system-api/src/model/events/types.ts"],"sourcesContent":["export enum EventType {\n\tdelete = 'delete',\n\tupdate = 'update',\n\tcreate = 'create',\n\ttruncate = 'truncate',\n}\n\nexport type ContentEvent = UpdateEvent | CreateEvent | DeleteEvent | TruncateEvent\n\nexport interface Event {\n\treadonly type: EventType\n\treadonly id: string\n\treadonly createdAt: Date\n\treadonly transactionId: string\n\t// readonly errors?: string[]\n}\n\nexport class UpdateEvent implements Event {\n\tpublic readonly type = EventType.update\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly createdAt: Date,\n\t\tpublic readonly appliedAt: Date,\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly transactionId: string,\n\t\tpublic readonly rowId: string[],\n\t\tpublic readonly tableName: string,\n\t\tpublic readonly values: { [column: string]: any },\n\t) {\n\t}\n}\n\nexport class CreateEvent implements Event {\n\tpublic readonly type = EventType.create\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly createdAt: Date,\n\t\tpublic readonly appliedAt: Date,\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly transactionId: string,\n\t\tpublic readonly rowId: string[],\n\t\tpublic readonly tableName: string,\n\t\tpublic readonly values: { [column: string]: any },\n\t) {\n\t}\n}\n\nexport class DeleteEvent implements Event {\n\tpublic readonly type = EventType.delete\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly createdAt: Date,\n\t\tpublic readonly appliedAt: Date,\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly transactionId: string,\n\t\tpublic readonly rowId: string[],\n\t\tpublic readonly tableName: string,\n\t) {\n\t}\n}\n\nexport class TruncateEvent implements Event {\n\tpublic readonly type = EventType.truncate\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly createdAt: Date,\n\t\tpublic readonly appliedAt: Date,\n\t\tpublic readonly identityId: string,\n\t\tpublic readonly transactionId: string,\n\t) {\n\t}\n}\n"],"names":["EventType"],"mappings":";;;AAAO,IAAK,8BAAAA,eAAL;AACNA,aAAA,QAAA,IAAS;AACTA,aAAA,QAAA,IAAS;AACTA,aAAA,QAAA,IAAS;AACTA,aAAA,UAAA,IAAW;AAJA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAiBL,MAAM,YAA6B;AAAA,EAGzC,YACiB,IACA,WACA,WACA,YACA,eACA,OACA,WACA,QACf;AARe,SAAA,KAAA;AACA,SAAA,YAAA;AACA,SAAA,YAAA;AACA,SAAA,aAAA;AACA,SAAA,gBAAA;AACA,SAAA,QAAA;AACA,SAAA,YAAA;AACA,SAAA,SAAA;AAVjB;AAAA,MAAA;AAAA,MAAgB;AAAA,MAAO;AAAA;AAAA,IAAA;AAAA,EAYvB;AACD;AAEO,MAAM,YAA6B;AAAA,EAGzC,YACiB,IACA,WACA,WACA,YACA,eACA,OACA,WACA,QACf;AARe,SAAA,KAAA;AACA,SAAA,YAAA;AACA,SAAA,YAAA;AACA,SAAA,aAAA;AACA,SAAA,gBAAA;AACA,SAAA,QAAA;AACA,SAAA,YAAA;AACA,SAAA,SAAA;AAVjB;AAAA,MAAA;AAAA,MAAgB;AAAA,MAAO;AAAA;AAAA,IAAA;AAAA,EAYvB;AACD;AAEO,MAAM,YAA6B;AAAA,EAGzC,YACiB,IACA,WACA,WACA,YACA,eACA,OACA,WACf;AAPe,SAAA,KAAA;AACA,SAAA,YAAA;AACA,SAAA,YAAA;AACA,SAAA,aAAA;AACA,SAAA,gBAAA;AACA,SAAA,QAAA;AACA,SAAA,YAAA;AATjB;AAAA,MAAA;AAAA,MAAgB;AAAA,MAAO;AAAA;AAAA,IAAA;AAAA,EAWvB;AACD;AAEO,MAAM,cAA+B;AAAA,EAG3C,YACiB,IACA,WACA,WACA,YACA,eACf;AALe,SAAA,KAAA;AACA,SAAA,YAAA;AACA,SAAA,YAAA;AACA,SAAA,aAAA;AACA,SAAA,gBAAA;AAPjB;AAAA,MAAA;AAAA,MAAgB;AAAA,MAAO;AAAA;AAAA,IAAA;AAAA,EASvB;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stageHelpers.cjs","sources":["../../../../../../packages/engine-system-api/src/model/helpers/stageHelpers.ts"],"sourcesContent":["import { Stage } from '../dtos'\n\nexport function formatSchemaName(stage: Pick<Stage, 'slug'>): string {\n\treturn 'stage_' + stage.slug\n}\n"],"names":[],"mappings":";;AAEO,SAAS,iBAAiB,OAAoC;AACpE,SAAO,WAAW,MAAM;AACzB;;"}
|
|
1
|
+
{"version":3,"file":"stageHelpers.cjs","sources":["../../../../../../packages/engine-system-api/src/model/helpers/stageHelpers.ts"],"sourcesContent":["import { Stage } from '../dtos/index.js'\n\nexport function formatSchemaName(stage: Pick<Stage, 'slug'>): string {\n\treturn 'stage_' + stage.slug\n}\n"],"names":[],"mappings":";;AAEO,SAAS,iBAAiB,OAAoC;AACpE,SAAO,WAAW,MAAM;AACzB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stageHelpers.js","sources":["../../../../../../packages/engine-system-api/src/model/helpers/stageHelpers.ts"],"sourcesContent":["import { Stage } from '../dtos'\n\nexport function formatSchemaName(stage: Pick<Stage, 'slug'>): string {\n\treturn 'stage_' + stage.slug\n}\n"],"names":[],"mappings":"AAEO,SAAS,iBAAiB,OAAoC;AACpE,SAAO,WAAW,MAAM;AACzB;"}
|
|
1
|
+
{"version":3,"file":"stageHelpers.js","sources":["../../../../../../packages/engine-system-api/src/model/helpers/stageHelpers.ts"],"sourcesContent":["import { Stage } from '../dtos/index.js'\n\nexport function formatSchemaName(stage: Pick<Stage, 'slug'>): string {\n\treturn 'stage_' + stage.slug\n}\n"],"names":[],"mappings":"AAEO,SAAS,iBAAiB,OAAoC;AACpE,SAAO,WAAW,MAAM;AACzB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDatabaseMetadataResolverStore.cjs","sources":["../../../../../../packages/engine-system-api/src/model/metadata/SchemaDatabaseMetadataResolverStore.ts"],"sourcesContent":["import { DatabaseContext } from '../database'\nimport { DatabaseMetadata, DatabaseMetadataResolver } from '@contember/database'\n\nexport class SchemaDatabaseMetadataResolverStore {\n\tprivate cache: Map<string, DatabaseMetadata> = new Map()\n\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t\tprivate db: DatabaseContext,\n\t) {\n\t}\n\n\tpublic async getMetadata(schema: string): Promise<DatabaseMetadata> {\n\t\tconst cached = this.cache.get(schema)\n\t\tif (cached) {\n\t\t\treturn cached\n\t\t}\n\n\t\tconst newValue = await this.resolver.resolveMetadata(this.db.client, schema)\n\t\tthis.cache.set(schema, newValue)\n\t\treturn newValue\n\t}\n\n\tpublic invalidate(schema: string): void {\n\t\tthis.cache.delete(schema)\n\t}\n}\n\nexport class MigrationsDatabaseMetadataResolverStoreFactory {\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tpublic create(db: DatabaseContext) {\n\t\treturn new SchemaDatabaseMetadataResolverStore(this.resolver, db)\n\t}\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,oCAAoC;AAAA,EAGhD,YACS,UACA,IACP;AAFO,SAAA,WAAA;AACA,SAAA,KAAA;AAJT,kBAAA,MAAQ,6BAA2C,IAAA,CAAI;AAAA,EAMvD;AAAA,EAEA,MAAa,YAAY,QAA2C;AACnE,UAAM,SAAS,KAAK,MAAM,IAAI,MAAM;AACpC,QAAI,QAAQ;AACX,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,MAAM,KAAK,SAAS,gBAAgB,KAAK,GAAG,QAAQ,MAAM;AAC3E,SAAK,MAAM,IAAI,QAAQ,QAAQ;AAC/B,WAAO;AAAA,EACR;AAAA,EAEO,WAAW,QAAsB;AACvC,SAAK,MAAM,OAAO,MAAM;AAAA,EACzB;AACD;AAEO,MAAM,+CAA+C;AAAA,EAC3D,YACS,UACP;AADO,SAAA,WAAA;AAAA,EAET;AAAA,EAEO,OAAO,IAAqB;AAClC,WAAO,IAAI,oCAAoC,KAAK,UAAU,EAAE;AAAA,EACjE;AACD;;;"}
|
|
1
|
+
{"version":3,"file":"SchemaDatabaseMetadataResolverStore.cjs","sources":["../../../../../../packages/engine-system-api/src/model/metadata/SchemaDatabaseMetadataResolverStore.ts"],"sourcesContent":["import { DatabaseContext } from '../database/index.js'\nimport { DatabaseMetadata, DatabaseMetadataResolver } from '@contember/database'\n\nexport class SchemaDatabaseMetadataResolverStore {\n\tprivate cache: Map<string, DatabaseMetadata> = new Map()\n\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t\tprivate db: DatabaseContext,\n\t) {\n\t}\n\n\tpublic async getMetadata(schema: string): Promise<DatabaseMetadata> {\n\t\tconst cached = this.cache.get(schema)\n\t\tif (cached) {\n\t\t\treturn cached\n\t\t}\n\n\t\tconst newValue = await this.resolver.resolveMetadata(this.db.client, schema)\n\t\tthis.cache.set(schema, newValue)\n\t\treturn newValue\n\t}\n\n\tpublic invalidate(schema: string): void {\n\t\tthis.cache.delete(schema)\n\t}\n}\n\nexport class MigrationsDatabaseMetadataResolverStoreFactory {\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tpublic create(db: DatabaseContext) {\n\t\treturn new SchemaDatabaseMetadataResolverStore(this.resolver, db)\n\t}\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,oCAAoC;AAAA,EAGhD,YACS,UACA,IACP;AAFO,SAAA,WAAA;AACA,SAAA,KAAA;AAJT,kBAAA,MAAQ,6BAA2C,IAAA,CAAI;AAAA,EAMvD;AAAA,EAEA,MAAa,YAAY,QAA2C;AACnE,UAAM,SAAS,KAAK,MAAM,IAAI,MAAM;AACpC,QAAI,QAAQ;AACX,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,MAAM,KAAK,SAAS,gBAAgB,KAAK,GAAG,QAAQ,MAAM;AAC3E,SAAK,MAAM,IAAI,QAAQ,QAAQ;AAC/B,WAAO;AAAA,EACR;AAAA,EAEO,WAAW,QAAsB;AACvC,SAAK,MAAM,OAAO,MAAM;AAAA,EACzB;AACD;AAEO,MAAM,+CAA+C;AAAA,EAC3D,YACS,UACP;AADO,SAAA,WAAA;AAAA,EAET;AAAA,EAEO,OAAO,IAAqB;AAClC,WAAO,IAAI,oCAAoC,KAAK,UAAU,EAAE;AAAA,EACjE;AACD;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDatabaseMetadataResolverStore.js","sources":["../../../../../../packages/engine-system-api/src/model/metadata/SchemaDatabaseMetadataResolverStore.ts"],"sourcesContent":["import { DatabaseContext } from '../database'\nimport { DatabaseMetadata, DatabaseMetadataResolver } from '@contember/database'\n\nexport class SchemaDatabaseMetadataResolverStore {\n\tprivate cache: Map<string, DatabaseMetadata> = new Map()\n\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t\tprivate db: DatabaseContext,\n\t) {\n\t}\n\n\tpublic async getMetadata(schema: string): Promise<DatabaseMetadata> {\n\t\tconst cached = this.cache.get(schema)\n\t\tif (cached) {\n\t\t\treturn cached\n\t\t}\n\n\t\tconst newValue = await this.resolver.resolveMetadata(this.db.client, schema)\n\t\tthis.cache.set(schema, newValue)\n\t\treturn newValue\n\t}\n\n\tpublic invalidate(schema: string): void {\n\t\tthis.cache.delete(schema)\n\t}\n}\n\nexport class MigrationsDatabaseMetadataResolverStoreFactory {\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tpublic create(db: DatabaseContext) {\n\t\treturn new SchemaDatabaseMetadataResolverStore(this.resolver, db)\n\t}\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,oCAAoC;AAAA,EAGhD,YACS,UACA,IACP;AAFO,SAAA,WAAA;AACA,SAAA,KAAA;AAJT,kBAAA,MAAQ,6BAA2C,IAAA,CAAI;AAAA,EAMvD;AAAA,EAEA,MAAa,YAAY,QAA2C;AACnE,UAAM,SAAS,KAAK,MAAM,IAAI,MAAM;AACpC,QAAI,QAAQ;AACX,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,MAAM,KAAK,SAAS,gBAAgB,KAAK,GAAG,QAAQ,MAAM;AAC3E,SAAK,MAAM,IAAI,QAAQ,QAAQ;AAC/B,WAAO;AAAA,EACR;AAAA,EAEO,WAAW,QAAsB;AACvC,SAAK,MAAM,OAAO,MAAM;AAAA,EACzB;AACD;AAEO,MAAM,+CAA+C;AAAA,EAC3D,YACS,UACP;AADO,SAAA,WAAA;AAAA,EAET;AAAA,EAEO,OAAO,IAAqB;AAClC,WAAO,IAAI,oCAAoC,KAAK,UAAU,EAAE;AAAA,EACjE;AACD;"}
|
|
1
|
+
{"version":3,"file":"SchemaDatabaseMetadataResolverStore.js","sources":["../../../../../../packages/engine-system-api/src/model/metadata/SchemaDatabaseMetadataResolverStore.ts"],"sourcesContent":["import { DatabaseContext } from '../database/index.js'\nimport { DatabaseMetadata, DatabaseMetadataResolver } from '@contember/database'\n\nexport class SchemaDatabaseMetadataResolverStore {\n\tprivate cache: Map<string, DatabaseMetadata> = new Map()\n\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t\tprivate db: DatabaseContext,\n\t) {\n\t}\n\n\tpublic async getMetadata(schema: string): Promise<DatabaseMetadata> {\n\t\tconst cached = this.cache.get(schema)\n\t\tif (cached) {\n\t\t\treturn cached\n\t\t}\n\n\t\tconst newValue = await this.resolver.resolveMetadata(this.db.client, schema)\n\t\tthis.cache.set(schema, newValue)\n\t\treturn newValue\n\t}\n\n\tpublic invalidate(schema: string): void {\n\t\tthis.cache.delete(schema)\n\t}\n}\n\nexport class MigrationsDatabaseMetadataResolverStoreFactory {\n\tconstructor(\n\t\tprivate resolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tpublic create(db: DatabaseContext) {\n\t\treturn new SchemaDatabaseMetadataResolverStore(this.resolver, db)\n\t}\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,oCAAoC;AAAA,EAGhD,YACS,UACA,IACP;AAFO,SAAA,WAAA;AACA,SAAA,KAAA;AAJT,kBAAA,MAAQ,6BAA2C,IAAA,CAAI;AAAA,EAMvD;AAAA,EAEA,MAAa,YAAY,QAA2C;AACnE,UAAM,SAAS,KAAK,MAAM,IAAI,MAAM;AACpC,QAAI,QAAQ;AACX,aAAO;AAAA,IACR;AAEA,UAAM,WAAW,MAAM,KAAK,SAAS,gBAAgB,KAAK,GAAG,QAAQ,MAAM;AAC3E,SAAK,MAAM,IAAI,QAAQ,QAAQ;AAC/B,WAAO;AAAA,EACR;AAAA,EAEO,WAAW,QAAsB;AACvC,SAAK,MAAM,OAAO,MAAM;AAAA,EACzB;AACD;AAEO,MAAM,+CAA+C;AAAA,EAC3D,YACS,UACP;AADO,SAAA,WAAA;AAAA,EAET;AAAA,EAEO,OAAO,IAAqB;AAClC,WAAO,IAAI,oCAAoC,KAAK,UAAU,EAAE;AAAA,EACjE;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutedMigrationsResolver.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/ExecutedMigrationsResolver.ts"],"sourcesContent":["import { ExecutedMigration } from '../dtos'\nimport { ExecutedMigrationByVersionQuery, ExecutedMigrationsQuery } from '../queries'\nimport { DatabaseContext } from '../database'\n\nexport class ExecutedMigrationsResolver {\n\tasync getMigrations(db: DatabaseContext, afterVersion?: string): Promise<ExecutedMigration[]> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationsQuery(afterVersion))\n\t}\n\n\tasync getMigrationByVersion(db: DatabaseContext, version: string): Promise<ExecutedMigration | null> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationByVersionQuery(version))\n\t}\n}\n"],"names":["ExecutedMigrationsQuery","ExecutedMigrationByVersionQuery"],"mappings":";;;;;;;AAIO,MAAM,2BAA2B;AAAA,EACvC,MAAM,cAAc,IAAqB,cAAqD;AAC7F,WAAO,GAAG,aAAa,MAAM,IAAIA,wBAAAA,wBAAwB,YAAY,CAAC;AAAA,EACvE;AAAA,EAEA,MAAM,sBAAsB,IAAqB,SAAoD;AACpG,WAAO,GAAG,aAAa,MAAM,IAAIC,gCAAAA,gCAAgC,OAAO,CAAC;AAAA,EAC1E;AACD;;"}
|
|
1
|
+
{"version":3,"file":"ExecutedMigrationsResolver.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/ExecutedMigrationsResolver.ts"],"sourcesContent":["import { ExecutedMigration } from '../dtos/index.js'\nimport { ExecutedMigrationByVersionQuery, ExecutedMigrationsQuery } from '../queries/index.js'\nimport { DatabaseContext } from '../database/index.js'\n\nexport class ExecutedMigrationsResolver {\n\tasync getMigrations(db: DatabaseContext, afterVersion?: string): Promise<ExecutedMigration[]> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationsQuery(afterVersion))\n\t}\n\n\tasync getMigrationByVersion(db: DatabaseContext, version: string): Promise<ExecutedMigration | null> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationByVersionQuery(version))\n\t}\n}\n"],"names":["ExecutedMigrationsQuery","ExecutedMigrationByVersionQuery"],"mappings":";;;;;;;AAIO,MAAM,2BAA2B;AAAA,EACvC,MAAM,cAAc,IAAqB,cAAqD;AAC7F,WAAO,GAAG,aAAa,MAAM,IAAIA,wBAAAA,wBAAwB,YAAY,CAAC;AAAA,EACvE;AAAA,EAEA,MAAM,sBAAsB,IAAqB,SAAoD;AACpG,WAAO,GAAG,aAAa,MAAM,IAAIC,gCAAAA,gCAAgC,OAAO,CAAC;AAAA,EAC1E;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutedMigrationsResolver.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/ExecutedMigrationsResolver.ts"],"sourcesContent":["import { ExecutedMigration } from '../dtos'\nimport { ExecutedMigrationByVersionQuery, ExecutedMigrationsQuery } from '../queries'\nimport { DatabaseContext } from '../database'\n\nexport class ExecutedMigrationsResolver {\n\tasync getMigrations(db: DatabaseContext, afterVersion?: string): Promise<ExecutedMigration[]> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationsQuery(afterVersion))\n\t}\n\n\tasync getMigrationByVersion(db: DatabaseContext, version: string): Promise<ExecutedMigration | null> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationByVersionQuery(version))\n\t}\n}\n"],"names":[],"mappings":";;;;;AAIO,MAAM,2BAA2B;AAAA,EACvC,MAAM,cAAc,IAAqB,cAAqD;AAC7F,WAAO,GAAG,aAAa,MAAM,IAAI,wBAAwB,YAAY,CAAC;AAAA,EACvE;AAAA,EAEA,MAAM,sBAAsB,IAAqB,SAAoD;AACpG,WAAO,GAAG,aAAa,MAAM,IAAI,gCAAgC,OAAO,CAAC;AAAA,EAC1E;AACD;"}
|
|
1
|
+
{"version":3,"file":"ExecutedMigrationsResolver.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/ExecutedMigrationsResolver.ts"],"sourcesContent":["import { ExecutedMigration } from '../dtos/index.js'\nimport { ExecutedMigrationByVersionQuery, ExecutedMigrationsQuery } from '../queries/index.js'\nimport { DatabaseContext } from '../database/index.js'\n\nexport class ExecutedMigrationsResolver {\n\tasync getMigrations(db: DatabaseContext, afterVersion?: string): Promise<ExecutedMigration[]> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationsQuery(afterVersion))\n\t}\n\n\tasync getMigrationByVersion(db: DatabaseContext, version: string): Promise<ExecutedMigration | null> {\n\t\treturn db.queryHandler.fetch(new ExecutedMigrationByVersionQuery(version))\n\t}\n}\n"],"names":[],"mappings":";;;;;AAIO,MAAM,2BAA2B;AAAA,EACvC,MAAM,cAAc,IAAqB,cAAqD;AAC7F,WAAO,GAAG,aAAa,MAAM,IAAI,wBAAwB,YAAY,CAAC;AAAA,EACvE;AAAA,EAEA,MAAM,sBAAsB,IAAqB,SAAoD;AACpG,WAAO,GAAG,aAAa,MAAM,IAAI,gCAAgC,OAAO,CAAC;AAAA,EAC1E;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationAlterer.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/MigrationAlterer.ts"],"sourcesContent":["import { DatabaseContext } from '../database'\nimport { DeleteMigrationCommand } from '../commands'\nimport { Response, ResponseError, ResponseOk } from '../../utils'\nimport { Migration } from '@contember/schema-migrations'\nimport { ModifyMigrationCommand } from '../commands/migrations/ModifyMigrationCommand'\nimport { SchemaProvider } from './SchemaProvider'\nimport { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand'\n\nexport class MigrationAlterer {\n\tconstructor(\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t) {\n\t}\n\n\tpublic async deleteMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t): Promise<Response<undefined, DeleteMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new DeleteMigrationCommand(version))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(DeleteMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tpublic async modifyMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t\tmigration: Partial<Migration>,\n\t): Promise<Response<undefined, UpdateMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new ModifyMigrationCommand(version, migration))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(UpdateMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tprivate async refreshSchema(db: DatabaseContext): Promise<void> {\n\t\tconst schemaWithMeta = await this.schemaProvider.buildSchemaFromMigrations(db)\n\t\tawait db.commandBus.execute(new SaveSchemaCommand(schemaWithMeta))\n\t}\n}\n\nexport enum DeleteMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n\nexport enum UpdateMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n"],"names":["db","DeleteMigrationCommand","ResponseError","ResponseOk","ModifyMigrationCommand","SaveSchemaCommand","DeleteMigrationErrorCode","UpdateMigrationErrorCode"],"mappings":";;;;;;;;;A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AA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"MigrationAlterer.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/MigrationAlterer.ts"],"sourcesContent":["import { DatabaseContext } from '../database/index.js'\nimport { DeleteMigrationCommand } from '../commands/index.js'\nimport { Response, ResponseError, ResponseOk } from '../../utils/index.js'\nimport { Migration } from '@contember/schema-migrations'\nimport { ModifyMigrationCommand } from '../commands/migrations/ModifyMigrationCommand.js'\nimport { SchemaProvider } from './SchemaProvider.js'\nimport { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand.js'\n\nexport class MigrationAlterer {\n\tconstructor(\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t) {\n\t}\n\n\tpublic async deleteMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t): Promise<Response<undefined, DeleteMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new DeleteMigrationCommand(version))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(DeleteMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tpublic async modifyMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t\tmigration: Partial<Migration>,\n\t): Promise<Response<undefined, UpdateMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new ModifyMigrationCommand(version, migration))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(UpdateMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tprivate async refreshSchema(db: DatabaseContext): Promise<void> {\n\t\tconst schemaWithMeta = await this.schemaProvider.buildSchemaFromMigrations(db)\n\t\tawait db.commandBus.execute(new SaveSchemaCommand(schemaWithMeta))\n\t}\n}\n\nexport enum DeleteMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n\nexport enum UpdateMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n"],"names":["db","DeleteMigrationCommand","ResponseError","ResponseOk","ModifyMigrationCommand","SaveSchemaCommand","DeleteMigrationErrorCode","UpdateMigrationErrorCode"],"mappings":";;;;;;;;;AAQO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,gBAChB;AADgB,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAa,gBACZ,IACA,SACyD;AACzD,WAAO,MAAM,GAAG,YAAY,OAAMA,QAAM;AACvC,YAAM,SAAS,MAAMA,IAAG,WAAW,QAAQ,IAAIC,uBAAAA,uBAAuB,OAAO,CAAC;AAC9E,UAAI,CAAC,QAAQ;AACZ,cAAMD,IAAG,OAAO,WAAW,SAAA;AAC3B,eAAO,IAAIE,SAAAA,cAAc,YAAmC,aAAa,OAAO,gBAAgB;AAAA,MACjG;AACA,YAAM,KAAK,cAAcF,GAAE;AAC3B,aAAO,IAAIG,SAAAA,WAAW,MAAS;AAAA,IAChC,CAAC;AAAA,EACF;AAAA,EAEA,MAAa,gBACZ,IACA,SACA,WACyD;AACzD,WAAO,MAAM,GAAG,YAAY,OAAMH,QAAM;AACvC,YAAM,SAAS,MAAMA,IAAG,WAAW,QAAQ,IAAII,uBAAAA,uBAAuB,SAAS,SAAS,CAAC;AACzF,UAAI,CAAC,QAAQ;AACZ,cAAMJ,IAAG,OAAO,WAAW,SAAA;AAC3B,eAAO,IAAIE,SAAAA,cAAc,YAAmC,aAAa,OAAO,gBAAgB;AAAA,MACjG;AACA,YAAM,KAAK,cAAcF,GAAE;AAC3B,aAAO,IAAIG,SAAAA,WAAW,MAAS;AAAA,IAChC,CAAC;AAAA,EACF;AAAA,EAEA,MAAc,cAAc,IAAoC;AAC/D,UAAM,iBAAiB,MAAM,KAAK,eAAe,0BAA0B,EAAE;AAC7E,UAAM,GAAG,WAAW,QAAQ,IAAIE,kBAAAA,kBAAkB,cAAc,CAAC;AAAA,EAClE;AACD;AAEO,IAAK,6CAAAC,8BAAL;AACNA,4BAAA,UAAA,IAAW;AADA,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;AAIL,IAAK,6CAAAC,8BAAL;AACNA,4BAAA,UAAA,IAAW;AADA,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationAlterer.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/MigrationAlterer.ts"],"sourcesContent":["import { DatabaseContext } from '../database'\nimport { DeleteMigrationCommand } from '../commands'\nimport { Response, ResponseError, ResponseOk } from '../../utils'\nimport { Migration } from '@contember/schema-migrations'\nimport { ModifyMigrationCommand } from '../commands/migrations/ModifyMigrationCommand'\nimport { SchemaProvider } from './SchemaProvider'\nimport { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand'\n\nexport class MigrationAlterer {\n\tconstructor(\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t) {\n\t}\n\n\tpublic async deleteMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t): Promise<Response<undefined, DeleteMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new DeleteMigrationCommand(version))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(DeleteMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tpublic async modifyMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t\tmigration: Partial<Migration>,\n\t): Promise<Response<undefined, UpdateMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new ModifyMigrationCommand(version, migration))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(UpdateMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tprivate async refreshSchema(db: DatabaseContext): Promise<void> {\n\t\tconst schemaWithMeta = await this.schemaProvider.buildSchemaFromMigrations(db)\n\t\tawait db.commandBus.execute(new SaveSchemaCommand(schemaWithMeta))\n\t}\n}\n\nexport enum DeleteMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n\nexport enum UpdateMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n"],"names":["db","DeleteMigrationErrorCode","UpdateMigrationErrorCode"],"mappings":";;;;;;;AAQO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,gBAChB;AADgB,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAa,gBACZ,IACA,SACyD;AACzD,WAAO,MAAM,GAAG,YAAY,OAAMA,QAAM;AACvC,YAAM,SAAS,MAAMA,IAAG,WAAW,QAAQ,IAAI,uBAAuB,OAAO,CAAC;AAC9E,UAAI,CAAC,QAAQ;AACZ,cAAMA,IAAG,OAAO,WAAW,SAAA;AAC3B,eAAO,IAAI,cAAc,YAAmC,aAAa,OAAO,gBAAgB;AAAA,MACjG;AACA,YAAM,KAAK,cAAcA,GAAE;AAC3B,aAAO,IAAI,WAAW,MAAS;AAAA,IAChC,CAAC;AAAA,EACF;AAAA,EAEA,MAAa,gBACZ,IACA,SACA,WACyD;AACzD,WAAO,MAAM,GAAG,YAAY,OAAMA,QAAM;AACvC,YAAM,SAAS,MAAMA,IAAG,WAAW,QAAQ,IAAI,uBAAuB,SAAS,SAAS,CAAC;AACzF,UAAI,CAAC,QAAQ;AACZ,cAAMA,IAAG,OAAO,WAAW,SAAA;AAC3B,eAAO,IAAI,cAAc,YAAmC,aAAa,OAAO,gBAAgB;AAAA,MACjG;AACA,YAAM,KAAK,cAAcA,GAAE;AAC3B,aAAO,IAAI,WAAW,MAAS;AAAA,IAChC,CAAC;AAAA,EACF;AAAA,EAEA,MAAc,cAAc,IAAoC;AAC/D,UAAM,iBAAiB,MAAM,KAAK,eAAe,0BAA0B,EAAE;AAC7E,UAAM,GAAG,WAAW,QAAQ,IAAI,kBAAkB,cAAc,CAAC;AAAA,EAClE;AACD;AAEO,IAAK,6CAAAC,8BAAL;AACNA,4BAAA,UAAA,IAAW;AADA,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;AAIL,IAAK,6CAAAC,8BAAL;AACNA,4BAAA,UAAA,IAAW;AADA,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"MigrationAlterer.js","sources":["../../../../../../packages/engine-system-api/src/model/migrations/MigrationAlterer.ts"],"sourcesContent":["import { DatabaseContext } from '../database/index.js'\nimport { DeleteMigrationCommand } from '../commands/index.js'\nimport { Response, ResponseError, ResponseOk } from '../../utils/index.js'\nimport { Migration } from '@contember/schema-migrations'\nimport { ModifyMigrationCommand } from '../commands/migrations/ModifyMigrationCommand.js'\nimport { SchemaProvider } from './SchemaProvider.js'\nimport { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand.js'\n\nexport class MigrationAlterer {\n\tconstructor(\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t) {\n\t}\n\n\tpublic async deleteMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t): Promise<Response<undefined, DeleteMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new DeleteMigrationCommand(version))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(DeleteMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tpublic async modifyMigration(\n\t\tdb: DatabaseContext,\n\t\tversion: string,\n\t\tmigration: Partial<Migration>,\n\t): Promise<Response<undefined, UpdateMigrationErrorCode>> {\n\t\treturn await db.transaction(async db => {\n\t\t\tconst result = await db.commandBus.execute(new ModifyMigrationCommand(version, migration))\n\t\t\tif (!result) {\n\t\t\t\tawait db.client.connection.rollback()\n\t\t\t\treturn new ResponseError(UpdateMigrationErrorCode.notFound, `Migration ${version} was not found`)\n\t\t\t}\n\t\t\tawait this.refreshSchema(db)\n\t\t\treturn new ResponseOk(undefined)\n\t\t})\n\t}\n\n\tprivate async refreshSchema(db: DatabaseContext): Promise<void> {\n\t\tconst schemaWithMeta = await this.schemaProvider.buildSchemaFromMigrations(db)\n\t\tawait db.commandBus.execute(new SaveSchemaCommand(schemaWithMeta))\n\t}\n}\n\nexport enum DeleteMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n\nexport enum UpdateMigrationErrorCode {\n\tnotFound = 'notFound',\n}\n"],"names":["db","DeleteMigrationErrorCode","UpdateMigrationErrorCode"],"mappings":";;;;;;;AAQO,MAAM,iBAAiB;AAAA,EAC7B,YACkB,gBAChB;AADgB,SAAA,iBAAA;AAAA,EAElB;AAAA,EAEA,MAAa,gBACZ,IACA,SACyD;AACzD,WAAO,MAAM,GAAG,YAAY,OAAMA,QAAM;AACvC,YAAM,SAAS,MAAMA,IAAG,WAAW,QAAQ,IAAI,uBAAuB,OAAO,CAAC;AAC9E,UAAI,CAAC,QAAQ;AACZ,cAAMA,IAAG,OAAO,WAAW,SAAA;AAC3B,eAAO,IAAI,cAAc,YAAmC,aAAa,OAAO,gBAAgB;AAAA,MACjG;AACA,YAAM,KAAK,cAAcA,GAAE;AAC3B,aAAO,IAAI,WAAW,MAAS;AAAA,IAChC,CAAC;AAAA,EACF;AAAA,EAEA,MAAa,gBACZ,IACA,SACA,WACyD;AACzD,WAAO,MAAM,GAAG,YAAY,OAAMA,QAAM;AACvC,YAAM,SAAS,MAAMA,IAAG,WAAW,QAAQ,IAAI,uBAAuB,SAAS,SAAS,CAAC;AACzF,UAAI,CAAC,QAAQ;AACZ,cAAMA,IAAG,OAAO,WAAW,SAAA;AAC3B,eAAO,IAAI,cAAc,YAAmC,aAAa,OAAO,gBAAgB;AAAA,MACjG;AACA,YAAM,KAAK,cAAcA,GAAE;AAC3B,aAAO,IAAI,WAAW,MAAS;AAAA,IAChC,CAAC;AAAA,EACF;AAAA,EAEA,MAAc,cAAc,IAAoC;AAC/D,UAAM,iBAAiB,MAAM,KAAK,eAAe,0BAA0B,EAAE;AAC7E,UAAM,GAAG,WAAW,QAAQ,IAAI,kBAAkB,cAAc,CAAC;AAAA,EAClE;AACD;AAEO,IAAK,6CAAAC,8BAAL;AACNA,4BAAA,UAAA,IAAW;AADA,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;AAIL,IAAK,6CAAAC,8BAAL;AACNA,4BAAA,UAAA,IAAW;AADA,SAAAA;AAAA,GAAA,4BAAA,CAAA,CAAA;"}
|
|
@@ -21,15 +21,15 @@ class ProjectMigrator {
|
|
|
21
21
|
this.migrationsDatabaseMetadataResolverStoreFactory = migrationsDatabaseMetadataResolverStoreFactory;
|
|
22
22
|
this.contentQueryExecutor = contentQueryExecutor;
|
|
23
23
|
}
|
|
24
|
-
async migrate({ db, project, identity, options: { ignoreOrder = false, skipExecuted = false }, migrationsToExecute, stages }) {
|
|
25
|
-
if (migrationsToExecute.length === 0) {
|
|
24
|
+
async migrate({ db, project, identity, options: { ignoreOrder = false, skipExecuted = false }, migrationsToExecute, stages, schemaState }) {
|
|
25
|
+
if (migrationsToExecute.length === 0 && !schemaState) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
const schemaWithMeta = await this.schemaProvider.fetch({ db });
|
|
29
29
|
let schema = schemaWithMeta.schema;
|
|
30
30
|
let id = schemaWithMeta.meta.id;
|
|
31
31
|
const validated = await this.validateMigrations(db, schema, schemaWithMeta.meta.version ?? null, migrationsToExecute, { ignoreOrder, skipExecuted });
|
|
32
|
-
if (validated.length === 0) {
|
|
32
|
+
if (validated.length === 0 && !schemaState) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const sorted = [...validated].sort((a, b) => a.version.localeCompare(b.version));
|
|
@@ -71,16 +71,98 @@ class ProjectMigrator {
|
|
|
71
71
|
}
|
|
72
72
|
id = await db.commandBus.execute(new SaveMigrationCommand.SaveMigrationCommand(migration));
|
|
73
73
|
}
|
|
74
|
+
const latestVersion = sorted.length > 0 ? sorted[sorted.length - 1].version : schemaWithMeta.meta.version;
|
|
75
|
+
if (schemaState) {
|
|
76
|
+
schema = {
|
|
77
|
+
...schema,
|
|
78
|
+
acl: schemaState.acl,
|
|
79
|
+
validation: schemaState.validation,
|
|
80
|
+
actions: schemaState.actions,
|
|
81
|
+
settings: schemaState.settings
|
|
82
|
+
};
|
|
83
|
+
const errors = schemaUtils.SchemaValidator.validate(schema);
|
|
84
|
+
if (errors.length > 0) {
|
|
85
|
+
throw new InvalidSchemaError(
|
|
86
|
+
latestVersion ?? "(schema state)",
|
|
87
|
+
"Schema state is invalid: \n" + errors.map((it) => `${it.path.join(".")}: [${it.code}] ${it.message}`).join("\n")
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!latestVersion) {
|
|
92
|
+
if (schemaState) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
throw new exceptions.ImplementationException();
|
|
96
|
+
}
|
|
97
|
+
if (!id) {
|
|
98
|
+
throw new exceptions.ImplementationException();
|
|
99
|
+
}
|
|
100
|
+
await db.commandBus.execute(
|
|
101
|
+
new SaveSchemaCommand.SaveSchemaCommand({
|
|
102
|
+
schema,
|
|
103
|
+
meta: {
|
|
104
|
+
id,
|
|
105
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
106
|
+
version: latestVersion,
|
|
107
|
+
checksum: schemaUtils.calculateSchemaChecksum(schema)
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
async migrateFromSnapshot({ db, project, stages, snapshot, covers, schemaState }) {
|
|
113
|
+
const sortedCovers = [...covers].sort((a, b) => a.version.localeCompare(b.version));
|
|
114
|
+
const latestVersion = sortedCovers.length > 0 ? sortedCovers[sortedCovers.length - 1].version : null;
|
|
115
|
+
if (!latestVersion) {
|
|
116
|
+
throw new exceptions.ImplementationException("Snapshot must cover at least one migration");
|
|
117
|
+
}
|
|
118
|
+
const executedMigrations = await this.executedMigrationsResolver.getMigrations(db);
|
|
119
|
+
if (executedMigrations.length > 0) {
|
|
120
|
+
throw new ProjectNotEmptyError(latestVersion, "Cannot apply snapshot: project already has executed migrations");
|
|
121
|
+
}
|
|
122
|
+
const metadataStore = this.migrationsDatabaseMetadataResolverStoreFactory.create(db);
|
|
123
|
+
let schema = schemaUtils.emptySchema;
|
|
124
|
+
for (const modification of snapshot.modifications) {
|
|
125
|
+
[schema] = await this.applyModification(
|
|
126
|
+
db.client,
|
|
127
|
+
stages,
|
|
128
|
+
schema,
|
|
129
|
+
modification,
|
|
130
|
+
snapshot.formatVersion,
|
|
131
|
+
latestVersion,
|
|
132
|
+
project,
|
|
133
|
+
metadataStore
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const errors = schemaUtils.SchemaValidator.validate(schema);
|
|
137
|
+
if (errors.length > 0) {
|
|
138
|
+
throw new InvalidSchemaError(
|
|
139
|
+
latestVersion,
|
|
140
|
+
"Snapshot generates invalid schema: \n" + errors.map((it) => `${it.path.join(".")}: [${it.code}] ${it.message}`).join("\n")
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
let id;
|
|
144
|
+
for (const migration of sortedCovers) {
|
|
145
|
+
id = await db.commandBus.execute(new SaveMigrationCommand.SaveMigrationCommand(migration));
|
|
146
|
+
}
|
|
74
147
|
if (!id) {
|
|
75
148
|
throw new exceptions.ImplementationException();
|
|
76
149
|
}
|
|
150
|
+
if (schemaState) {
|
|
151
|
+
schema = {
|
|
152
|
+
...schema,
|
|
153
|
+
acl: schemaState.acl,
|
|
154
|
+
validation: schemaState.validation,
|
|
155
|
+
actions: schemaState.actions,
|
|
156
|
+
settings: schemaState.settings
|
|
157
|
+
};
|
|
158
|
+
}
|
|
77
159
|
await db.commandBus.execute(
|
|
78
160
|
new SaveSchemaCommand.SaveSchemaCommand({
|
|
79
161
|
schema,
|
|
80
162
|
meta: {
|
|
81
163
|
id,
|
|
82
164
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
83
|
-
version:
|
|
165
|
+
version: latestVersion,
|
|
84
166
|
checksum: schemaUtils.calculateSchemaChecksum(schema)
|
|
85
167
|
}
|
|
86
168
|
})
|
|
@@ -146,7 +228,7 @@ class ProjectMigrator {
|
|
|
146
228
|
const errors = schemaUtils.SchemaValidator.validate(schema);
|
|
147
229
|
if (errors.length > 0) {
|
|
148
230
|
throw new InvalidSchemaError(
|
|
149
|
-
toExecute[toExecute.length - 1]
|
|
231
|
+
toExecute[toExecute.length - 1]?.version ?? version ?? "(schema)",
|
|
150
232
|
"Migration generates invalid schema: \n" + errors.map((it) => it.path.join(".") + ": " + it.message).join("\n")
|
|
151
233
|
);
|
|
152
234
|
}
|
|
@@ -234,6 +316,12 @@ class NotSuccessfulContentMigrationError extends MigrationError {
|
|
|
234
316
|
__publicField(this, "code", types.MigrateErrorCode.ContentMigrationNotSuccessful);
|
|
235
317
|
}
|
|
236
318
|
}
|
|
319
|
+
class ProjectNotEmptyError extends MigrationError {
|
|
320
|
+
constructor() {
|
|
321
|
+
super(...arguments);
|
|
322
|
+
__publicField(this, "code", types.MigrateErrorCode.ProjectNotEmpty);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
237
325
|
exports.AlreadyExecutedMigrationError = AlreadyExecutedMigrationError;
|
|
238
326
|
exports.FailedContentMigrationError = FailedContentMigrationError;
|
|
239
327
|
exports.InvalidSchemaError = InvalidSchemaError;
|
|
@@ -242,4 +330,5 @@ exports.MigrationFailedError = MigrationFailedError;
|
|
|
242
330
|
exports.MustFollowLatestMigrationError = MustFollowLatestMigrationError;
|
|
243
331
|
exports.NotSuccessfulContentMigrationError = NotSuccessfulContentMigrationError;
|
|
244
332
|
exports.ProjectMigrator = ProjectMigrator;
|
|
333
|
+
exports.ProjectNotEmptyError = ProjectNotEmptyError;
|
|
245
334
|
//# sourceMappingURL=ProjectMigrator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectMigrator.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/ProjectMigrator.ts"],"sourcesContent":["import { calculateMigrationChecksum, Migration, MigrationDescriber, MigrationVersionHelper } from '@contember/schema-migrations'\nimport { Client, DatabaseMetadata, QueryError, wrapIdentifier } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SaveMigrationCommand } from '../commands'\nimport { Stage } from '../dtos'\nimport { DatabaseContext } from '../database'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver'\nimport { MigrateErrorCode } from '../../schema'\nimport { calculateSchemaChecksum, SchemaValidator, SchemaValidatorSkippedErrors } from '@contember/schema-utils'\nimport { logger } from '@contember/logger'\nimport { MigrationsDatabaseMetadataResolverStoreFactory, SchemaDatabaseMetadataResolverStore } from '../metadata'\nimport { ContentMigrationQuery, MigrationInput } from './MigrationInput'\nimport { ContentQueryExecutor } from '../dependencies'\nimport { SchemaProvider } from './SchemaProvider'\nimport { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand'\nimport { ImplementationException } from '../../utils'\n\ntype MigrationVariables = {\n\tsystem_schema: string\n\tproject_slug: string\n}\n\nexport class ProjectMigrator {\n\tconstructor(\n\t\tprivate readonly migrationDescriber: MigrationDescriber,\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly migrationsDatabaseMetadataResolverStoreFactory: MigrationsDatabaseMetadataResolverStoreFactory,\n\t\tprivate readonly contentQueryExecutor: ContentQueryExecutor,\n\t) {}\n\n\tpublic async migrate({ db, project, identity, options: { ignoreOrder = false, skipExecuted = false }, migrationsToExecute, stages }: {\n\t\tdb: DatabaseContext\n\t\tproject: { slug: string; systemSchema: string }\n\t\tidentity: { id: string }\n\t\tstages: Stage[]\n\t\tmigrationsToExecute: readonly MigrationInput[]\n\t\toptions: {\n\t\t\tignoreOrder?: boolean\n\t\t\tskipExecuted?: boolean\n\t\t}\n\t}) {\n\t\tif (migrationsToExecute.length === 0) {\n\t\t\treturn\n\t\t}\n\t\tconst schemaWithMeta = await this.schemaProvider.fetch({ db })\n\t\tlet schema = schemaWithMeta.schema\n\t\tlet id = schemaWithMeta.meta.id\n\n\t\tconst validated = await this.validateMigrations(db, schema, schemaWithMeta.meta.version ?? null, migrationsToExecute, { ignoreOrder, skipExecuted })\n\t\tif (validated.length === 0) {\n\t\t\treturn\n\t\t}\n\n\t\tconst sorted = [...validated].sort((a, b) => a.version.localeCompare(b.version))\n\n\t\tconst metadataStore = this.migrationsDatabaseMetadataResolverStoreFactory.create(db)\n\n\t\tfor (const migration of sorted) {\n\t\t\tif (migration.type === 'schema') {\n\t\t\t\tconst formatVersion = migration.formatVersion\n\n\t\t\t\tfor (const modification of migration.modifications) {\n\t\t\t\t\t;[schema] = await this.applyModification(\n\t\t\t\t\t\tdb.client,\n\t\t\t\t\t\tstages,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tmodification,\n\t\t\t\t\t\tformatVersion,\n\t\t\t\t\t\tmigration.version,\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\tmetadataStore,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (migration.type === 'content') {\n\t\t\t\tif (!id) {\n\t\t\t\t\tthrow new FailedContentMigrationError(migration.version, `Cannot execute content migration without schema`)\n\t\t\t\t}\n\t\t\t\tfor (const query of migration.queries) {\n\t\t\t\t\tawait this.executeContentMigration({\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tdb,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tschemaMeta: { id },\n\t\t\t\t\t\tstages,\n\t\t\t\t\t\tdatabaseMetadata: await metadataStore.getMetadata(db.client.schema),\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\tproject,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\t// event log uses deferred constraint triggers, we need to fire them before ALTER\n\t\t\t\tawait db.client.query(`SET CONSTRAINTS ALL IMMEDIATE`)\n\t\t\t\tawait db.client.query(`SET CONSTRAINTS ALL DEFERRED`)\n\t\t\t}\n\t\t\tid = await db.commandBus.execute(new SaveMigrationCommand(migration))\n\t\t}\n\t\tif (!id) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\n\t\tawait db.commandBus.execute(\n\t\t\tnew SaveSchemaCommand({\n\t\t\t\tschema,\n\t\t\t\tmeta: {\n\t\t\t\t\tid,\n\t\t\t\t\tupdatedAt: new Date(),\n\t\t\t\t\tversion: sorted[sorted.length - 1].version,\n\t\t\t\t\tchecksum: calculateSchemaChecksum(schema),\n\t\t\t\t},\n\t\t\t}),\n\t\t)\n\t}\n\n\tprivate async executeContentMigration({ query, stages, version, ...ctx }: {\n\t\tversion: string\n\t\tdb: DatabaseContext\n\t\tquery: ContentMigrationQuery\n\t\tstages: Stage[]\n\t\tschema: Schema\n\t\tschemaMeta: { id: number }\n\t\tproject: { slug: string; systemSchema: string }\n\t\tidentity: { id: string }\n\t\tdatabaseMetadata: DatabaseMetadata\n\t}) {\n\t\tconst queryStages = query.stage ? stages.filter(it => it.slug === query.stage) : stages\n\t\tfor (const stage of queryStages) {\n\t\t\tconst response = await this.contentQueryExecutor.execute({\n\t\t\t\tstage,\n\t\t\t\t...ctx,\n\t\t\t}, query)\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new FailedContentMigrationError(version, response.errors.join(', '))\n\t\t\t}\n\t\t\tif (query.checkMutationResult !== false) {\n\t\t\t\tfor (const [key, value] of Object.entries(response.result.data ?? {})) {\n\t\t\t\t\tif (typeof value === 'object' && value !== null && 'ok' in value && !value.ok) {\n\t\t\t\t\t\tconst errorDetails = 'errorMessage' in value ? value.errorMessage : 'No details available. Please fetch errorMessage field.'\n\t\t\t\t\t\tthrow new NotSuccessfulContentMigrationError(version, `Mutation ${key} failed: ${errorDetails}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async validateMigrations(\n\t\tdb: DatabaseContext,\n\t\tschema: Schema,\n\t\tversion: string | null,\n\t\tmigrationsToExecute: readonly MigrationInput[],\n\t\t{ ignoreOrder, skipExecuted }: {\n\t\t\tignoreOrder: boolean\n\t\t\tskipExecuted: boolean\n\t\t},\n\t): Promise<readonly MigrationInput[]> {\n\t\tconst executedMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\t\tconst toExecute: MigrationInput[] = []\n\t\tlet skippedErrors: SchemaValidatorSkippedErrors[] = []\n\t\tfor (const migration of migrationsToExecute) {\n\t\t\tconst executedMigration = executedMigrations.find(it => it.version === migration.version)\n\t\t\tif (executedMigration) {\n\t\t\t\tif (skipExecuted && (migration.type !== 'schema' || executedMigration.checksum === calculateMigrationChecksum(migration))) {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tthrow new AlreadyExecutedMigrationError(migration.version, `Migration is already executed`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (version && migration.version < version && !ignoreOrder) {\n\t\t\t\tthrow new MustFollowLatestMigrationError(migration.version, `Must follow latest executed migration ${version}`)\n\t\t\t}\n\t\t\tif (migration.type === 'schema') {\n\t\t\t\tconst described = this.migrationDescriber.describeModifications(schema, migration)\n\t\t\t\tif (described.length === 0) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst latestModification = described[described.length - 1]\n\t\t\t\tschema = latestModification.schema\n\t\t\t\tskippedErrors = [\n\t\t\t\t\t...skippedErrors.filter(it => it.skipUntil && MigrationVersionHelper.extractVersion(it.skipUntil) >= migration.version),\n\t\t\t\t\t...migration.skippedErrors ?? [],\n\t\t\t\t]\n\t\t\t\tconst errors = SchemaValidator.validate(schema, skippedErrors)\n\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\tthrow new InvalidSchemaError(\n\t\t\t\t\t\tmigration.version,\n\t\t\t\t\t\t'Migration generates invalid schema: \\n'\n\t\t\t\t\t\t\t+ errors.map(it => `${it.path.join('.')}: [${it.code}] ${it.message}`).join('\\n'),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttoExecute.push(migration)\n\t\t}\n\t\t// intentionally not using skippedErrors here\n\t\tconst errors = SchemaValidator.validate(schema)\n\t\tif (errors.length > 0) {\n\t\t\tthrow new InvalidSchemaError(\n\t\t\t\ttoExecute[toExecute.length - 1].version,\n\t\t\t\t'Migration generates invalid schema: \\n'\n\t\t\t\t\t+ errors.map(it => it.path.join('.') + ': ' + it.message).join('\\n'),\n\t\t\t)\n\t\t}\n\t\treturn toExecute\n\t}\n\n\tprivate sqlPreprocessor(text: string, variables: MigrationVariables): string {\n\t\treturn Object.entries(variables).reduce(\n\t\t\t(content, [key, value]) => content.replace(new RegExp(`\\\\{\\\\{${key}\\\\}\\\\}`, 'g'), value),\n\t\t\ttext,\n\t\t)\n\t}\n\n\tprivate async applyModification(\n\t\tdb: Client,\n\t\tstages: Stage[],\n\t\tschema: Schema,\n\t\tmodification: Migration.Modification,\n\t\tformatVersion: number,\n\t\tmigrationVersion: string,\n\t\tproject: { slug: string; systemSchema: string },\n\t\tmetadataStore: SchemaDatabaseMetadataResolverStore,\n\t): Promise<[Schema]> {\n\t\tconst {\n\t\t\tgetSql,\n\t\t\tschema: newSchema,\n\t\t} = this.migrationDescriber.describeModification(schema, modification, { formatVersion })\n\t\tfor (const stage of stages) {\n\t\t\tconst databaseMetadata = await metadataStore.getMetadata(stage.schema)\n\t\t\tconst sql = getSql({\n\t\t\t\tsystemSchema: project.systemSchema,\n\t\t\t\tdatabaseMetadata,\n\t\t\t\tinvalidateDatabaseMetadata: () => metadataStore.invalidate(stage.schema),\n\t\t\t})\n\t\t\tconst processedSql = this.sqlPreprocessor(sql, {\n\t\t\t\tproject_slug: project.slug,\n\t\t\t\tsystem_schema: project.systemSchema,\n\t\t\t})\n\t\t\tawait this.executeOnStage(db, stage, processedSql, migrationVersion)\n\t\t}\n\t\treturn [newSchema]\n\t}\n\n\tprivate async executeOnStage(db: Client, stage: Stage, sql: string, migrationVersion: string) {\n\t\tawait db.query('SET LOCAL search_path TO ' + wrapIdentifier(stage.schema))\n\t\ttry {\n\t\t\tawait db.query(sql)\n\t\t} catch (e) {\n\t\t\tif (e instanceof QueryError) {\n\t\t\t\tlogger.error(e, { message: 'Migration failed' })\n\t\t\t\tthrow new MigrationFailedError(migrationVersion, e.message)\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n\nexport abstract class MigrationError extends Error {\n\tpublic abstract code: MigrateErrorCode\n\n\tconstructor(public readonly version: string, public readonly migrationError: string) {\n\t\tsuper(`${version}: ${migrationError}`)\n\t}\n}\n\nexport class MustFollowLatestMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.MustFollowLatest\n}\n\nexport class AlreadyExecutedMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.AlreadyExecuted\n}\n\nexport class MigrationFailedError extends MigrationError {\n\tcode = MigrateErrorCode.MigrationFailed\n}\n\nexport class InvalidSchemaError extends MigrationError {\n\tcode = MigrateErrorCode.InvalidSchema\n}\n\nexport class FailedContentMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.ContentMigrationFailed\n}\n\nexport class NotSuccessfulContentMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.ContentMigrationNotSuccessful\n}\n"],"names":["SaveMigrationCommand","ImplementationException","SaveSchemaCommand","calculateSchemaChecksum","calculateMigrationChecksum","MigrationVersionHelper","errors","SchemaValidator","wrapIdentifier","QueryError","logger","MigrateErrorCode"],"mappings":";;;;;;;;;;;;;;;AAsBO,MAAM,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AAA;AAAA,EAAA;AACzB;AAEO,MAAM,2CAA2C,eAAe;AAAA,EAAhE,cAAA;AAAA,UAAA,GAAA,SAAA;AACN,kBAAA,MAAA,QAAOA,MAAAA,iBAAiB,6BAAA;AAAA,EAAA;AACzB;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ProjectMigrator.cjs","sources":["../../../../../../packages/engine-system-api/src/model/migrations/ProjectMigrator.ts"],"sourcesContent":["import { calculateMigrationChecksum, Migration, MigrationDescriber, MigrationVersionHelper } from '@contember/schema-migrations'\nimport { Client, DatabaseMetadata, QueryError, wrapIdentifier } from '@contember/database'\nimport { Schema } from '@contember/schema'\nimport { SaveMigrationCommand } from '../commands/index.js'\nimport { Stage } from '../dtos/index.js'\nimport { DatabaseContext } from '../database/index.js'\nimport { ExecutedMigrationsResolver } from './ExecutedMigrationsResolver.js'\nimport { MigrateErrorCode } from '../../schema/index.js'\nimport { calculateSchemaChecksum, emptySchema, SchemaValidator, SchemaValidatorSkippedErrors } from '@contember/schema-utils'\nimport { logger } from '@contember/logger'\nimport { MigrationsDatabaseMetadataResolverStoreFactory, SchemaDatabaseMetadataResolverStore } from '../metadata/index.js'\nimport { ContentMigrationQuery, MigrationInput, SchemaStateInput } from './MigrationInput.js'\nimport { ContentQueryExecutor } from '../dependencies/index.js'\nimport { SchemaProvider } from './SchemaProvider.js'\nimport { SaveSchemaCommand } from '../commands/schema/SaveSchemaCommand.js'\nimport { ImplementationException } from '../../utils/index.js'\n\ntype MigrationVariables = {\n\tsystem_schema: string\n\tproject_slug: string\n}\n\nexport class ProjectMigrator {\n\tconstructor(\n\t\tprivate readonly migrationDescriber: MigrationDescriber,\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t\tprivate readonly executedMigrationsResolver: ExecutedMigrationsResolver,\n\t\tprivate readonly migrationsDatabaseMetadataResolverStoreFactory: MigrationsDatabaseMetadataResolverStoreFactory,\n\t\tprivate readonly contentQueryExecutor: ContentQueryExecutor,\n\t) {}\n\n\tpublic async migrate({ db, project, identity, options: { ignoreOrder = false, skipExecuted = false }, migrationsToExecute, stages, schemaState }: {\n\t\tdb: DatabaseContext\n\t\tproject: { slug: string; systemSchema: string }\n\t\tidentity: { id: string }\n\t\tstages: Stage[]\n\t\tmigrationsToExecute: readonly MigrationInput[]\n\t\tschemaState?: SchemaStateInput\n\t\toptions: {\n\t\t\tignoreOrder?: boolean\n\t\t\tskipExecuted?: boolean\n\t\t}\n\t}) {\n\t\tif (migrationsToExecute.length === 0 && !schemaState) {\n\t\t\treturn\n\t\t}\n\t\tconst schemaWithMeta = await this.schemaProvider.fetch({ db })\n\t\tlet schema = schemaWithMeta.schema\n\t\tlet id = schemaWithMeta.meta.id\n\n\t\tconst validated = await this.validateMigrations(db, schema, schemaWithMeta.meta.version ?? null, migrationsToExecute, { ignoreOrder, skipExecuted })\n\n\t\tif (validated.length === 0 && !schemaState) {\n\t\t\treturn\n\t\t}\n\n\t\tconst sorted = [...validated].sort((a, b) => a.version.localeCompare(b.version))\n\n\t\tconst metadataStore = this.migrationsDatabaseMetadataResolverStoreFactory.create(db)\n\n\t\tfor (const migration of sorted) {\n\t\t\tif (migration.type === 'schema') {\n\t\t\t\tconst formatVersion = migration.formatVersion\n\n\t\t\t\tfor (const modification of migration.modifications) {\n\t\t\t\t\t;[schema] = await this.applyModification(\n\t\t\t\t\t\tdb.client,\n\t\t\t\t\t\tstages,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tmodification,\n\t\t\t\t\t\tformatVersion,\n\t\t\t\t\t\tmigration.version,\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\tmetadataStore,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (migration.type === 'content') {\n\t\t\t\tif (!id) {\n\t\t\t\t\tthrow new FailedContentMigrationError(migration.version, `Cannot execute content migration without schema`)\n\t\t\t\t}\n\t\t\t\tfor (const query of migration.queries) {\n\t\t\t\t\tawait this.executeContentMigration({\n\t\t\t\t\t\tversion: migration.version,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tdb,\n\t\t\t\t\t\tschema,\n\t\t\t\t\t\tschemaMeta: { id },\n\t\t\t\t\t\tstages,\n\t\t\t\t\t\tdatabaseMetadata: await metadataStore.getMetadata(db.client.schema),\n\t\t\t\t\t\tidentity,\n\t\t\t\t\t\tproject,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\t// event log uses deferred constraint triggers, we need to fire them before ALTER\n\t\t\t\tawait db.client.query(`SET CONSTRAINTS ALL IMMEDIATE`)\n\t\t\t\tawait db.client.query(`SET CONSTRAINTS ALL DEFERRED`)\n\t\t\t}\n\t\t\tid = await db.commandBus.execute(new SaveMigrationCommand(migration))\n\t\t}\n\n\t\tconst latestVersion = sorted.length > 0\n\t\t\t? sorted[sorted.length - 1].version\n\t\t\t: schemaWithMeta.meta.version\n\n\t\tif (schemaState) {\n\t\t\tschema = {\n\t\t\t\t...schema,\n\t\t\t\tacl: schemaState.acl as Schema['acl'],\n\t\t\t\tvalidation: schemaState.validation as Schema['validation'],\n\t\t\t\tactions: schemaState.actions as Schema['actions'],\n\t\t\t\tsettings: schemaState.settings as Schema['settings'],\n\t\t\t}\n\t\t\t// Client-supplied state is otherwise saved blindly; validate it as the normal migration flow would.\n\t\t\tconst errors = SchemaValidator.validate(schema)\n\t\t\tif (errors.length > 0) {\n\t\t\t\tthrow new InvalidSchemaError(\n\t\t\t\t\tlatestVersion ?? '(schema state)',\n\t\t\t\t\t'Schema state is invalid: \\n'\n\t\t\t\t\t\t+ errors.map(it => `${it.path.join('.')}: [${it.code}] ${it.message}`).join('\\n'),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tif (!latestVersion) {\n\t\t\tif (schemaState) {\n\t\t\t\t// State-only update on a fresh project with no migrations — there is no schema\n\t\t\t\t// row to attach the state to yet, so there is nothing to save.\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow new ImplementationException()\n\t\t}\n\n\t\tif (!id) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\n\t\tawait db.commandBus.execute(\n\t\t\tnew SaveSchemaCommand({\n\t\t\t\tschema,\n\t\t\t\tmeta: {\n\t\t\t\t\tid,\n\t\t\t\t\tupdatedAt: new Date(),\n\t\t\t\t\tversion: latestVersion,\n\t\t\t\t\tchecksum: calculateSchemaChecksum(schema),\n\t\t\t\t},\n\t\t\t}),\n\t\t)\n\t}\n\n\tpublic async migrateFromSnapshot({ db, project, stages, snapshot, covers, schemaState }: {\n\t\tdb: DatabaseContext\n\t\tproject: { slug: string; systemSchema: string }\n\t\tstages: Stage[]\n\t\tsnapshot: { formatVersion: number; modifications: Migration.Modification[] }\n\t\tcovers: readonly MigrationInput[]\n\t\tschemaState?: SchemaStateInput\n\t}) {\n\t\tconst sortedCovers = [...covers].sort((a, b) => a.version.localeCompare(b.version))\n\t\tconst latestVersion = sortedCovers.length > 0 ? sortedCovers[sortedCovers.length - 1].version : null\n\t\tif (!latestVersion) {\n\t\t\tthrow new ImplementationException('Snapshot must cover at least one migration')\n\t\t}\n\n\t\t// Hard safety gate: a snapshot may only bootstrap a project that has executed nothing yet.\n\t\tconst executedMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\t\tif (executedMigrations.length > 0) {\n\t\t\tthrow new ProjectNotEmptyError(latestVersion, 'Cannot apply snapshot: project already has executed migrations')\n\t\t}\n\n\t\tconst metadataStore = this.migrationsDatabaseMetadataResolverStoreFactory.create(db)\n\t\tlet schema = emptySchema\n\t\tfor (const modification of snapshot.modifications) {\n\t\t\t;[schema] = await this.applyModification(\n\t\t\t\tdb.client,\n\t\t\t\tstages,\n\t\t\t\tschema,\n\t\t\t\tmodification,\n\t\t\t\tsnapshot.formatVersion,\n\t\t\t\tlatestVersion,\n\t\t\t\tproject,\n\t\t\t\tmetadataStore,\n\t\t\t)\n\t\t}\n\n\t\tconst errors = SchemaValidator.validate(schema)\n\t\tif (errors.length > 0) {\n\t\t\tthrow new InvalidSchemaError(\n\t\t\t\tlatestVersion,\n\t\t\t\t'Snapshot generates invalid schema: \\n'\n\t\t\t\t\t+ errors.map(it => `${it.path.join('.')}: [${it.code}] ${it.message}`).join('\\n'),\n\t\t\t)\n\t\t}\n\n\t\t// Record covered migrations as executed without replaying their SQL, so the registry\n\t\t// ends up identical to a full replay (status, checksums and schema rebuild stay correct).\n\t\tlet id: number | undefined\n\t\tfor (const migration of sortedCovers) {\n\t\t\tid = await db.commandBus.execute(new SaveMigrationCommand(migration))\n\t\t}\n\t\tif (!id) {\n\t\t\tthrow new ImplementationException()\n\t\t}\n\n\t\tif (schemaState) {\n\t\t\tschema = {\n\t\t\t\t...schema,\n\t\t\t\tacl: schemaState.acl as Schema['acl'],\n\t\t\t\tvalidation: schemaState.validation as Schema['validation'],\n\t\t\t\tactions: schemaState.actions as Schema['actions'],\n\t\t\t\tsettings: schemaState.settings as Schema['settings'],\n\t\t\t}\n\t\t}\n\n\t\tawait db.commandBus.execute(\n\t\t\tnew SaveSchemaCommand({\n\t\t\t\tschema,\n\t\t\t\tmeta: {\n\t\t\t\t\tid,\n\t\t\t\t\tupdatedAt: new Date(),\n\t\t\t\t\tversion: latestVersion,\n\t\t\t\t\tchecksum: calculateSchemaChecksum(schema),\n\t\t\t\t},\n\t\t\t}),\n\t\t)\n\t}\n\n\tprivate async executeContentMigration({ query, stages, version, ...ctx }: {\n\t\tversion: string\n\t\tdb: DatabaseContext\n\t\tquery: ContentMigrationQuery\n\t\tstages: Stage[]\n\t\tschema: Schema\n\t\tschemaMeta: { id: number }\n\t\tproject: { slug: string; systemSchema: string }\n\t\tidentity: { id: string }\n\t\tdatabaseMetadata: DatabaseMetadata\n\t}) {\n\t\tconst queryStages = query.stage ? stages.filter(it => it.slug === query.stage) : stages\n\t\tfor (const stage of queryStages) {\n\t\t\tconst response = await this.contentQueryExecutor.execute({\n\t\t\t\tstage,\n\t\t\t\t...ctx,\n\t\t\t}, query)\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new FailedContentMigrationError(version, response.errors.join(', '))\n\t\t\t}\n\t\t\tif (query.checkMutationResult !== false) {\n\t\t\t\tfor (const [key, value] of Object.entries(response.result.data ?? {})) {\n\t\t\t\t\tif (typeof value === 'object' && value !== null && 'ok' in value && !value.ok) {\n\t\t\t\t\t\tconst errorDetails = 'errorMessage' in value ? value.errorMessage : 'No details available. Please fetch errorMessage field.'\n\t\t\t\t\t\tthrow new NotSuccessfulContentMigrationError(version, `Mutation ${key} failed: ${errorDetails}`)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async validateMigrations(\n\t\tdb: DatabaseContext,\n\t\tschema: Schema,\n\t\tversion: string | null,\n\t\tmigrationsToExecute: readonly MigrationInput[],\n\t\t{ ignoreOrder, skipExecuted }: {\n\t\t\tignoreOrder: boolean\n\t\t\tskipExecuted: boolean\n\t\t},\n\t): Promise<readonly MigrationInput[]> {\n\t\tconst executedMigrations = await this.executedMigrationsResolver.getMigrations(db)\n\t\tconst toExecute: MigrationInput[] = []\n\t\tlet skippedErrors: SchemaValidatorSkippedErrors[] = []\n\t\tfor (const migration of migrationsToExecute) {\n\t\t\tconst executedMigration = executedMigrations.find(it => it.version === migration.version)\n\t\t\tif (executedMigration) {\n\t\t\t\tif (skipExecuted && (migration.type !== 'schema' || executedMigration.checksum === calculateMigrationChecksum(migration))) {\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tthrow new AlreadyExecutedMigrationError(migration.version, `Migration is already executed`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (version && migration.version < version && !ignoreOrder) {\n\t\t\t\tthrow new MustFollowLatestMigrationError(migration.version, `Must follow latest executed migration ${version}`)\n\t\t\t}\n\t\t\tif (migration.type === 'schema') {\n\t\t\t\tconst described = this.migrationDescriber.describeModifications(schema, migration)\n\t\t\t\tif (described.length === 0) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst latestModification = described[described.length - 1]\n\t\t\t\tschema = latestModification.schema\n\t\t\t\tskippedErrors = [\n\t\t\t\t\t...skippedErrors.filter(it => it.skipUntil && MigrationVersionHelper.extractVersion(it.skipUntil) >= migration.version),\n\t\t\t\t\t...migration.skippedErrors ?? [],\n\t\t\t\t]\n\t\t\t\tconst errors = SchemaValidator.validate(schema, skippedErrors)\n\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\tthrow new InvalidSchemaError(\n\t\t\t\t\t\tmigration.version,\n\t\t\t\t\t\t'Migration generates invalid schema: \\n'\n\t\t\t\t\t\t\t+ errors.map(it => `${it.path.join('.')}: [${it.code}] ${it.message}`).join('\\n'),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttoExecute.push(migration)\n\t\t}\n\t\t// intentionally not using skippedErrors here\n\t\tconst errors = SchemaValidator.validate(schema)\n\t\tif (errors.length > 0) {\n\t\t\tthrow new InvalidSchemaError(\n\t\t\t\ttoExecute[toExecute.length - 1]?.version ?? version ?? '(schema)',\n\t\t\t\t'Migration generates invalid schema: \\n'\n\t\t\t\t\t+ errors.map(it => it.path.join('.') + ': ' + it.message).join('\\n'),\n\t\t\t)\n\t\t}\n\t\treturn toExecute\n\t}\n\n\tprivate sqlPreprocessor(text: string, variables: MigrationVariables): string {\n\t\treturn Object.entries(variables).reduce(\n\t\t\t(content, [key, value]) => content.replace(new RegExp(`\\\\{\\\\{${key}\\\\}\\\\}`, 'g'), value),\n\t\t\ttext,\n\t\t)\n\t}\n\n\tprivate async applyModification(\n\t\tdb: Client,\n\t\tstages: Stage[],\n\t\tschema: Schema,\n\t\tmodification: Migration.Modification,\n\t\tformatVersion: number,\n\t\tmigrationVersion: string,\n\t\tproject: { slug: string; systemSchema: string },\n\t\tmetadataStore: SchemaDatabaseMetadataResolverStore,\n\t): Promise<[Schema]> {\n\t\tconst {\n\t\t\tgetSql,\n\t\t\tschema: newSchema,\n\t\t} = this.migrationDescriber.describeModification(schema, modification, { formatVersion })\n\t\tfor (const stage of stages) {\n\t\t\tconst databaseMetadata = await metadataStore.getMetadata(stage.schema)\n\t\t\tconst sql = getSql({\n\t\t\t\tsystemSchema: project.systemSchema,\n\t\t\t\tdatabaseMetadata,\n\t\t\t\tinvalidateDatabaseMetadata: () => metadataStore.invalidate(stage.schema),\n\t\t\t})\n\t\t\tconst processedSql = this.sqlPreprocessor(sql, {\n\t\t\t\tproject_slug: project.slug,\n\t\t\t\tsystem_schema: project.systemSchema,\n\t\t\t})\n\t\t\tawait this.executeOnStage(db, stage, processedSql, migrationVersion)\n\t\t}\n\t\treturn [newSchema]\n\t}\n\n\tprivate async executeOnStage(db: Client, stage: Stage, sql: string, migrationVersion: string) {\n\t\tawait db.query('SET LOCAL search_path TO ' + wrapIdentifier(stage.schema))\n\t\ttry {\n\t\t\tawait db.query(sql)\n\t\t} catch (e) {\n\t\t\tif (e instanceof QueryError) {\n\t\t\t\tlogger.error(e, { message: 'Migration failed' })\n\t\t\t\tthrow new MigrationFailedError(migrationVersion, e.message)\n\t\t\t}\n\t\t\tthrow e\n\t\t}\n\t}\n}\n\nexport abstract class MigrationError extends Error {\n\tpublic abstract code: MigrateErrorCode\n\n\tconstructor(public readonly version: string, public readonly migrationError: string) {\n\t\tsuper(`${version}: ${migrationError}`)\n\t}\n}\n\nexport class MustFollowLatestMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.MustFollowLatest\n}\n\nexport class AlreadyExecutedMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.AlreadyExecuted\n}\n\nexport class MigrationFailedError extends MigrationError {\n\tcode = MigrateErrorCode.MigrationFailed\n}\n\nexport class InvalidSchemaError extends MigrationError {\n\tcode = MigrateErrorCode.InvalidSchema\n}\n\nexport class FailedContentMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.ContentMigrationFailed\n}\n\nexport class NotSuccessfulContentMigrationError extends MigrationError {\n\tcode = MigrateErrorCode.ContentMigrationNotSuccessful\n}\n\nexport class ProjectNotEmptyError extends MigrationError {\n\tcode = MigrateErrorCode.ProjectNotEmpty\n}\n"],"names":["SaveMigrationCommand","SchemaValidator","ImplementationException","SaveSchemaCommand","calculateSchemaChecksum","emptySchema","calculateMigrationChecksum","MigrationVersionHelper","errors","wrapIdentifier","QueryError","logger","MigrateErrorCode"],"mappings":";;;;;;;;;;;;;;;AAsBO,MAAM,gBAAgB;AAAA,EAC5B,YACkB,oBACA,gBACA,4BACA,gDACA,sBAChB;AALgB,SAAA,qBAAA;AACA,SAAA,iBAAA;AACA,SAAA,6BAAA;AACA,SAAA,iDAAA;AACA,SAAA,uBAAA;AAAA,EACf;AAAA,EAEH,MAAa,QAAQ,EAAE,IAAI,SAAS,UAAU,SAAS,EAAE,cAAc,OAAO,eAAe,MAAA,GAAS,qBAAqB,QAAQ,eAWhI;AACF,QAAI,oBAAoB,WAAW,KAAK,CAAC,aAAa;AACrD;AAAA,IACD;AACA,UAAM,iBAAiB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI;AAC7D,QAAI,SAAS,eAAe;AAC5B,QAAI,KAAK,eAAe,KAAK;AAE7B,UAAM,YAAY,MAAM,KAAK,mBAAmB,IAAI,QAAQ,eAAe,KAAK,WAAW,MAAM,qBAAqB,EAAE,aAAa,cAAc;AAEnJ,QAAI,UAAU,WAAW,KAAK,CAAC,aAAa;AAC3C;AAAA,IACD;AAEA,UAAM,SAAS,CAAC,GAAG,SAAS,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,cAAc,EAAE,OAAO,CAAC;AAE/E,UAAM,gBAAgB,KAAK,+CAA+C,OAAO,EAAE;AAEnF,eAAW,aAAa,QAAQ;AAC/B,UAAI,UAAU,SAAS,UAAU;AAChC,cAAM,gBAAgB,UAAU;AAEhC,mBAAW,gBAAgB,UAAU,eAAe;AAClD,WAAC,MAAM,IAAI,MAAM,KAAK;AAAA,YACtB,GAAG;AAAA,YACH;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA;AAAA,UAAA;AAAA,QAEF;AAAA,MACD,WAAW,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A,UAAA,GAAA,SAAA;AACN,kBAAA,MAAA,QAAOA,MAAAA,iBAAiB,6BAAA;AAAA,EAAA;AACzB;AAEO,MAAM,6BAA6B,eAAe;AAAA,EAAlD,cAAA;AAAA,UAAA,GAAA,SAAA;AACN,kBAAA,MAAA,QAAOA,MAAAA,iBAAiB,eAAA;AAAA,EAAA;AACzB;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { calculateMigrationChecksum, MigrationVersionHelper } from "@contember/schema-migrations";
|
|
2
2
|
import { wrapIdentifier, QueryError } from "@contember/database";
|
|
3
3
|
import { SaveMigrationCommand } from "../commands/migrations/SaveMigrationCommand.js";
|
|
4
|
-
import { calculateSchemaChecksum,
|
|
4
|
+
import { SchemaValidator, calculateSchemaChecksum, emptySchema } from "@contember/schema-utils";
|
|
5
5
|
import { MigrateErrorCode } from "../../schema/types.js";
|
|
6
6
|
import "../../schema/dev.graphql.js";
|
|
7
7
|
import "../../schema/system.graphql.js";
|
|
@@ -19,15 +19,15 @@ class ProjectMigrator {
|
|
|
19
19
|
this.migrationsDatabaseMetadataResolverStoreFactory = migrationsDatabaseMetadataResolverStoreFactory;
|
|
20
20
|
this.contentQueryExecutor = contentQueryExecutor;
|
|
21
21
|
}
|
|
22
|
-
async migrate({ db, project, identity, options: { ignoreOrder = false, skipExecuted = false }, migrationsToExecute, stages }) {
|
|
23
|
-
if (migrationsToExecute.length === 0) {
|
|
22
|
+
async migrate({ db, project, identity, options: { ignoreOrder = false, skipExecuted = false }, migrationsToExecute, stages, schemaState }) {
|
|
23
|
+
if (migrationsToExecute.length === 0 && !schemaState) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
const schemaWithMeta = await this.schemaProvider.fetch({ db });
|
|
27
27
|
let schema = schemaWithMeta.schema;
|
|
28
28
|
let id = schemaWithMeta.meta.id;
|
|
29
29
|
const validated = await this.validateMigrations(db, schema, schemaWithMeta.meta.version ?? null, migrationsToExecute, { ignoreOrder, skipExecuted });
|
|
30
|
-
if (validated.length === 0) {
|
|
30
|
+
if (validated.length === 0 && !schemaState) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
const sorted = [...validated].sort((a, b) => a.version.localeCompare(b.version));
|
|
@@ -69,16 +69,98 @@ class ProjectMigrator {
|
|
|
69
69
|
}
|
|
70
70
|
id = await db.commandBus.execute(new SaveMigrationCommand(migration));
|
|
71
71
|
}
|
|
72
|
+
const latestVersion = sorted.length > 0 ? sorted[sorted.length - 1].version : schemaWithMeta.meta.version;
|
|
73
|
+
if (schemaState) {
|
|
74
|
+
schema = {
|
|
75
|
+
...schema,
|
|
76
|
+
acl: schemaState.acl,
|
|
77
|
+
validation: schemaState.validation,
|
|
78
|
+
actions: schemaState.actions,
|
|
79
|
+
settings: schemaState.settings
|
|
80
|
+
};
|
|
81
|
+
const errors = SchemaValidator.validate(schema);
|
|
82
|
+
if (errors.length > 0) {
|
|
83
|
+
throw new InvalidSchemaError(
|
|
84
|
+
latestVersion ?? "(schema state)",
|
|
85
|
+
"Schema state is invalid: \n" + errors.map((it) => `${it.path.join(".")}: [${it.code}] ${it.message}`).join("\n")
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!latestVersion) {
|
|
90
|
+
if (schemaState) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
throw new ImplementationException();
|
|
94
|
+
}
|
|
95
|
+
if (!id) {
|
|
96
|
+
throw new ImplementationException();
|
|
97
|
+
}
|
|
98
|
+
await db.commandBus.execute(
|
|
99
|
+
new SaveSchemaCommand({
|
|
100
|
+
schema,
|
|
101
|
+
meta: {
|
|
102
|
+
id,
|
|
103
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
104
|
+
version: latestVersion,
|
|
105
|
+
checksum: calculateSchemaChecksum(schema)
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
async migrateFromSnapshot({ db, project, stages, snapshot, covers, schemaState }) {
|
|
111
|
+
const sortedCovers = [...covers].sort((a, b) => a.version.localeCompare(b.version));
|
|
112
|
+
const latestVersion = sortedCovers.length > 0 ? sortedCovers[sortedCovers.length - 1].version : null;
|
|
113
|
+
if (!latestVersion) {
|
|
114
|
+
throw new ImplementationException("Snapshot must cover at least one migration");
|
|
115
|
+
}
|
|
116
|
+
const executedMigrations = await this.executedMigrationsResolver.getMigrations(db);
|
|
117
|
+
if (executedMigrations.length > 0) {
|
|
118
|
+
throw new ProjectNotEmptyError(latestVersion, "Cannot apply snapshot: project already has executed migrations");
|
|
119
|
+
}
|
|
120
|
+
const metadataStore = this.migrationsDatabaseMetadataResolverStoreFactory.create(db);
|
|
121
|
+
let schema = emptySchema;
|
|
122
|
+
for (const modification of snapshot.modifications) {
|
|
123
|
+
[schema] = await this.applyModification(
|
|
124
|
+
db.client,
|
|
125
|
+
stages,
|
|
126
|
+
schema,
|
|
127
|
+
modification,
|
|
128
|
+
snapshot.formatVersion,
|
|
129
|
+
latestVersion,
|
|
130
|
+
project,
|
|
131
|
+
metadataStore
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
const errors = SchemaValidator.validate(schema);
|
|
135
|
+
if (errors.length > 0) {
|
|
136
|
+
throw new InvalidSchemaError(
|
|
137
|
+
latestVersion,
|
|
138
|
+
"Snapshot generates invalid schema: \n" + errors.map((it) => `${it.path.join(".")}: [${it.code}] ${it.message}`).join("\n")
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
let id;
|
|
142
|
+
for (const migration of sortedCovers) {
|
|
143
|
+
id = await db.commandBus.execute(new SaveMigrationCommand(migration));
|
|
144
|
+
}
|
|
72
145
|
if (!id) {
|
|
73
146
|
throw new ImplementationException();
|
|
74
147
|
}
|
|
148
|
+
if (schemaState) {
|
|
149
|
+
schema = {
|
|
150
|
+
...schema,
|
|
151
|
+
acl: schemaState.acl,
|
|
152
|
+
validation: schemaState.validation,
|
|
153
|
+
actions: schemaState.actions,
|
|
154
|
+
settings: schemaState.settings
|
|
155
|
+
};
|
|
156
|
+
}
|
|
75
157
|
await db.commandBus.execute(
|
|
76
158
|
new SaveSchemaCommand({
|
|
77
159
|
schema,
|
|
78
160
|
meta: {
|
|
79
161
|
id,
|
|
80
162
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
81
|
-
version:
|
|
163
|
+
version: latestVersion,
|
|
82
164
|
checksum: calculateSchemaChecksum(schema)
|
|
83
165
|
}
|
|
84
166
|
})
|
|
@@ -144,7 +226,7 @@ class ProjectMigrator {
|
|
|
144
226
|
const errors = SchemaValidator.validate(schema);
|
|
145
227
|
if (errors.length > 0) {
|
|
146
228
|
throw new InvalidSchemaError(
|
|
147
|
-
toExecute[toExecute.length - 1]
|
|
229
|
+
toExecute[toExecute.length - 1]?.version ?? version ?? "(schema)",
|
|
148
230
|
"Migration generates invalid schema: \n" + errors.map((it) => it.path.join(".") + ": " + it.message).join("\n")
|
|
149
231
|
);
|
|
150
232
|
}
|
|
@@ -232,6 +314,12 @@ class NotSuccessfulContentMigrationError extends MigrationError {
|
|
|
232
314
|
__publicField(this, "code", MigrateErrorCode.ContentMigrationNotSuccessful);
|
|
233
315
|
}
|
|
234
316
|
}
|
|
317
|
+
class ProjectNotEmptyError extends MigrationError {
|
|
318
|
+
constructor() {
|
|
319
|
+
super(...arguments);
|
|
320
|
+
__publicField(this, "code", MigrateErrorCode.ProjectNotEmpty);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
235
323
|
export {
|
|
236
324
|
AlreadyExecutedMigrationError,
|
|
237
325
|
FailedContentMigrationError,
|
|
@@ -240,6 +328,7 @@ export {
|
|
|
240
328
|
MigrationFailedError,
|
|
241
329
|
MustFollowLatestMigrationError,
|
|
242
330
|
NotSuccessfulContentMigrationError,
|
|
243
|
-
ProjectMigrator
|
|
331
|
+
ProjectMigrator,
|
|
332
|
+
ProjectNotEmptyError
|
|
244
333
|
};
|
|
245
334
|
//# sourceMappingURL=ProjectMigrator.js.map
|