mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 03:43:34 +00:00 
			
		
		
		
	Change core store setup
This commit is contained in:
		
							parent
							
								
									b34ac11e10
								
							
						
					
					
						commit
						b7a2778e89
					
				@ -199,8 +199,8 @@ class Strapi extends EventEmitter {
 | 
			
		||||
    // Usage.
 | 
			
		||||
    await utils.usage.call(this);
 | 
			
		||||
 | 
			
		||||
    // Init core store manager
 | 
			
		||||
    await store.pre.call(this);
 | 
			
		||||
    // Init core store
 | 
			
		||||
    await store.call(this);
 | 
			
		||||
 | 
			
		||||
    // Initialize hooks and middlewares.
 | 
			
		||||
    await Promise.all([
 | 
			
		||||
@ -208,9 +208,6 @@ class Strapi extends EventEmitter {
 | 
			
		||||
      initializeHooks.call(this)
 | 
			
		||||
    ]);
 | 
			
		||||
 | 
			
		||||
    // Core store post middleware and hooks init validation.
 | 
			
		||||
    await store.post.call(this);
 | 
			
		||||
 | 
			
		||||
    // Harmonize plugins configuration.
 | 
			
		||||
    await plugins.call(this);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,6 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  pre: function () {
 | 
			
		||||
module.exports = function () {
 | 
			
		||||
  return new Promise((resolve, reject) => {
 | 
			
		||||
    this.models['core_store'] = {
 | 
			
		||||
      connection: 'default',
 | 
			
		||||
@ -135,37 +134,4 @@ module.exports = {
 | 
			
		||||
 | 
			
		||||
    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