mirror of
https://github.com/strapi/strapi.git
synced 2025-09-01 04:42:58 +00:00
fix: avoid history data loss when license is missing (#23562)
* fix: avoid history data loss when license is missing * fix: history lifecycle test * fix: restore ts-expect-error
This commit is contained in:
parent
dd588fdca6
commit
883f4fcabd
@ -21,7 +21,11 @@ const mockGetRequestContext = jest.fn(() => {
|
||||
});
|
||||
|
||||
const mockStrapi = {
|
||||
service: jest.fn(),
|
||||
service: jest.fn((name: string) => {
|
||||
if (name === 'admin::persist-tables') {
|
||||
return { persistTablesWithPrefix: jest.fn() };
|
||||
}
|
||||
}),
|
||||
plugins: {
|
||||
'content-manager': {
|
||||
service: jest.fn(() => ({
|
||||
@ -81,9 +85,9 @@ describe('history lifecycles service', () => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('inits service only once', () => {
|
||||
lifecyclesService.bootstrap();
|
||||
lifecyclesService.bootstrap();
|
||||
it('inits service only once', async () => {
|
||||
await lifecyclesService.bootstrap();
|
||||
await lifecyclesService.bootstrap();
|
||||
// @ts-expect-error - ignore
|
||||
expect(mockStrapi.documents.use).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
@ -101,6 +101,7 @@ const createLifecyclesService = ({ strapi }: { strapi: Core.Strapi }) => {
|
||||
};
|
||||
|
||||
const serviceUtils = createServiceUtils({ strapi });
|
||||
const { persistTablesWithPrefix } = strapi.service('admin::persist-tables');
|
||||
|
||||
return {
|
||||
async bootstrap() {
|
||||
@ -109,6 +110,9 @@ const createLifecyclesService = ({ strapi }: { strapi: Core.Strapi }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid data loss in case users temporarily don't have a license
|
||||
await persistTablesWithPrefix('strapi_history_versions');
|
||||
|
||||
strapi.documents.use(async (context, next) => {
|
||||
const result = (await next()) as any;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user