@fourlights/strapi-plugin-deep-populate 1.2.2 → 1.2.3

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.
@@ -65,7 +65,7 @@ const schema$1 = {
65
65
  type: "json",
66
66
  configurable: false
67
67
  },
68
- dependencies: { type: "string", configurable: false }
68
+ dependencies: { type: "text", configurable: false }
69
69
  },
70
70
  // experimental feature:
71
71
  indexes: [
@@ -140,13 +140,13 @@ const register = async ({ strapi: strapi2 }) => {
140
140
  const tableName = "caches";
141
141
  const columnName = "dependencies";
142
142
  const hasIndex = await hasDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
143
- if (strapi2.config.get("plugin::deep-populate").cachePopulate === true) {
144
- if (!hasIndex) {
145
- await addDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
146
- }
147
- } else if (hasIndex) {
148
- await removeDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
149
- }
143
+ const hasTable = await strapi2.db.connection.schema.hasTable(tableName);
144
+ const hasColumn = hasTable && await strapi2.db.connection.schema.hasColumn(tableName, columnName);
145
+ const cacheIsEnabled = strapi2.config.get("plugin::deep-populate").cachePopulate === true;
146
+ const shouldCreateIndex = cacheIsEnabled && hasTable && hasColumn && !hasIndex;
147
+ const shouldRemoveIndex = hasIndex && (!cacheIsEnabled || !hasTable || !hasColumn);
148
+ if (shouldCreateIndex) await addDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
149
+ if (shouldRemoveIndex) await removeDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
150
150
  });
151
151
  strapi2.documents.use(async (context, next) => {
152
152
  const { cachePopulate, augmentPopulateStar } = strapi2.config.get("plugin::deep-populate");
@@ -51,7 +51,7 @@ const schema$1 = {
51
51
  type: "json",
52
52
  configurable: false
53
53
  },
54
- dependencies: { type: "string", configurable: false }
54
+ dependencies: { type: "text", configurable: false }
55
55
  },
56
56
  // experimental feature:
57
57
  indexes: [
@@ -126,13 +126,13 @@ const register = async ({ strapi: strapi2 }) => {
126
126
  const tableName = "caches";
127
127
  const columnName = "dependencies";
128
128
  const hasIndex = await hasDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
129
- if (strapi2.config.get("plugin::deep-populate").cachePopulate === true) {
130
- if (!hasIndex) {
131
- await addDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
132
- }
133
- } else if (hasIndex) {
134
- await removeDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
135
- }
129
+ const hasTable = await strapi2.db.connection.schema.hasTable(tableName);
130
+ const hasColumn = hasTable && await strapi2.db.connection.schema.hasColumn(tableName, columnName);
131
+ const cacheIsEnabled = strapi2.config.get("plugin::deep-populate").cachePopulate === true;
132
+ const shouldCreateIndex = cacheIsEnabled && hasTable && hasColumn && !hasIndex;
133
+ const shouldRemoveIndex = hasIndex && (!cacheIsEnabled || !hasTable || !hasColumn);
134
+ if (shouldCreateIndex) await addDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
135
+ if (shouldRemoveIndex) await removeDeepPopulateCacheFullTextIndex(strapi2.db, tableName, columnName);
136
136
  });
137
137
  strapi2.documents.use(async (context, next) => {
138
138
  const { cachePopulate, augmentPopulateStar } = strapi2.config.get("plugin::deep-populate");
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.2",
2
+ "version": "1.2.3",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",