mirror of
https://github.com/strapi/strapi.git
synced 2025-11-08 06:07:41 +00:00
Change core store setup
This commit is contained in:
parent
b34ac11e10
commit
b7a2778e89
@ -199,8 +199,8 @@ class Strapi extends EventEmitter {
|
|||||||
// Usage.
|
// Usage.
|
||||||
await utils.usage.call(this);
|
await utils.usage.call(this);
|
||||||
|
|
||||||
// Init core store manager
|
// Init core store
|
||||||
await store.pre.call(this);
|
await store.call(this);
|
||||||
|
|
||||||
// Initialize hooks and middlewares.
|
// Initialize hooks and middlewares.
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@ -208,9 +208,6 @@ class Strapi extends EventEmitter {
|
|||||||
initializeHooks.call(this)
|
initializeHooks.call(this)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Core store post middleware and hooks init validation.
|
|
||||||
await store.post.call(this);
|
|
||||||
|
|
||||||
// Harmonize plugins configuration.
|
// Harmonize plugins configuration.
|
||||||
await plugins.call(this);
|
await plugins.call(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = function () {
|
||||||
pre: function () {
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.models['core_store'] = {
|
this.models['core_store'] = {
|
||||||
connection: 'default',
|
connection: 'default',
|
||||||
@ -135,37 +134,4 @@ module.exports = {
|
|||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
},
|
|
||||||
post: function () {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
const Model = this.models['core_store'];
|
|
||||||
|
|
||||||
if (Model.orm !== 'bookshelf') {
|
|
||||||
return resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasTable = await this.connections[Model.connection].schema.hasTable(Model.tableName || Model.collectionName);
|
|
||||||
|
|
||||||
if (!hasTable) {
|
|
||||||
const quote = Model.client === 'pg' ? '"' : '`';
|
|
||||||
|
|
||||||
this.connections[Model.connection].raw(`
|
|
||||||
CREATE TABLE ${quote}${Model.tableName || Model.collectionName}${quote} (
|
|
||||||
id ${Model.client === 'pg' ? 'SERIAL' : 'INT AUTO_INCREMENT'} NOT NULL PRIMARY KEY,
|
|
||||||
${quote}key${quote} text,
|
|
||||||
${quote}value${quote} text,
|
|
||||||
environment text,
|
|
||||||
type text,
|
|
||||||
tag text
|
|
||||||
);
|
|
||||||
|
|
||||||
ALTER TABLE ${quote}${Model.tableName || Model.collectionName}${quote} ADD COLUMN ${quote}parent${quote} integer, ADD FOREIGN KEY (${quote}parent${quote}) REFERENCES ${quote}${Model.tableName || Model.collectionName}${quote}(${quote}id${quote});
|
|
||||||
`).then(() => {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user