mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 23:24:03 +00:00
chore: improve naming of persisted tables
This commit is contained in:
parent
1ae35507fe
commit
b17dd81556
4
packages/core/admin/ee/server/bootstrap.js
vendored
4
packages/core/admin/ee/server/bootstrap.js
vendored
@ -5,7 +5,7 @@ const { features } = require('@strapi/strapi/lib/utils/ee');
|
||||
const executeCEBootstrap = require('../../server/bootstrap');
|
||||
const { getService } = require('../../server/utils');
|
||||
const actions = require('./config/admin-actions');
|
||||
const { reserveTablesWithPrefix } = require('./utils/reserved-tables');
|
||||
const { persistTablesWithPrefix } = require('./utils/persisted-tables');
|
||||
|
||||
module.exports = async () => {
|
||||
const { actionProvider } = getService('permission');
|
||||
@ -15,7 +15,7 @@ module.exports = async () => {
|
||||
}
|
||||
|
||||
if (features.isEnabled('audit-logs')) {
|
||||
await reserveTablesWithPrefix('strapi_audit_logs');
|
||||
await persistTablesWithPrefix('strapi_audit_logs');
|
||||
|
||||
await actionProvider.registerMany(actions.auditLogs);
|
||||
}
|
||||
|
||||
@ -14,36 +14,36 @@ const findTablesThatStartWithPrefix = async (prefix) => {
|
||||
* Get all reserved table names from the core store
|
||||
* @returns {Array}
|
||||
*/
|
||||
const getReservedTables = async () =>
|
||||
const getPersistedTables = async () =>
|
||||
strapi.store.get({
|
||||
type: 'core',
|
||||
key: 'reserved_tables',
|
||||
});
|
||||
key: 'persisted_tables',
|
||||
}) ?? [];
|
||||
|
||||
/**
|
||||
* Add all table names that start with a prefix to the reserved tables in
|
||||
* core store
|
||||
* @param {string} tableNamePrefix
|
||||
*/
|
||||
const reserveTablesWithPrefix = async (tableNamePrefix) => {
|
||||
const reservedTables = (await getReservedTables()) || [];
|
||||
|
||||
const persistTablesWithPrefix = async (tableNamePrefix) => {
|
||||
const persistedTables = (await getPersistedTables()) || [];
|
||||
const tableNames = await findTablesThatStartWithPrefix(tableNamePrefix);
|
||||
const notReservedTableNames = tableNames.filter((name) => !persistedTables.includes(name));
|
||||
|
||||
if (!tableNames.length) {
|
||||
if (!notReservedTableNames.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
reservedTables.push(...tableNames.filter((name) => !reservedTables.includes(name)));
|
||||
|
||||
persistedTables.push(...notReservedTableNames);
|
||||
await strapi.store.set({
|
||||
type: 'core',
|
||||
key: 'reserved_tables',
|
||||
value: reservedTables,
|
||||
key: 'persisted_tables',
|
||||
value: persistedTables,
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
reserveTablesWithPrefix,
|
||||
persistTablesWithPrefix,
|
||||
findTablesThatStartWithPrefix,
|
||||
};
|
||||
@ -345,10 +345,10 @@ module.exports = (db) => {
|
||||
}
|
||||
|
||||
const persistedTables = helpers.hasTable(srcSchema, 'strapi_core_store_settings')
|
||||
? await strapi.store.get({
|
||||
? (await strapi.store.get({
|
||||
type: 'core',
|
||||
key: 'reserved_tables',
|
||||
})
|
||||
key: 'persisted_tables',
|
||||
})) ?? []
|
||||
: [];
|
||||
|
||||
for (const srcTable of srcSchema.tables) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user