@strapi/database 5.0.0-rc.11 → 5.0.0-rc.13

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.
package/dist/index.js CHANGED
@@ -2347,7 +2347,7 @@ const createMorphToOne = (attributeName, attribute) => {
2347
2347
  });
2348
2348
  };
2349
2349
  const createMorphToMany = (attributeName, attribute, meta, metadata) => {
2350
- if ("joinTable" in attribute && attribute.joinTable) {
2350
+ if ("joinTable" in attribute && attribute.joinTable && !attribute.joinTable.__internal__) {
2351
2351
  return;
2352
2352
  }
2353
2353
  const joinTableName = identifiers.getMorphTableName(meta.tableName, attributeName);
@@ -2417,6 +2417,7 @@ const createMorphToMany = (attributeName, attribute, meta, metadata) => {
2417
2417
  columnToAttribute: {}
2418
2418
  });
2419
2419
  const joinTable = {
2420
+ __internal__: true,
2420
2421
  name: joinTableName,
2421
2422
  joinColumn: {
2422
2423
  name: joinColumnName,
@@ -2486,7 +2487,7 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
2486
2487
  if (!targetMeta) {
2487
2488
  throw new Error(`Unknown target ${attribute.target}`);
2488
2489
  }
2489
- if ("joinTable" in attribute && attribute.joinTable) {
2490
+ if ("joinTable" in attribute && attribute.joinTable && !attribute.joinTable.__internal__) {
2490
2491
  return;
2491
2492
  }
2492
2493
  const joinTableName = identifiers.getJoinTableName(
@@ -2570,6 +2571,7 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
2570
2571
  columnToAttribute: {}
2571
2572
  };
2572
2573
  const joinTable = {
2574
+ __internal__: true,
2573
2575
  name: joinTableName,
2574
2576
  joinColumn: {
2575
2577
  name: joinColumnName,
@@ -2629,6 +2631,7 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
2629
2631
  );
2630
2632
  }
2631
2633
  inverseAttribute.joinTable = {
2634
+ __internal__: true,
2632
2635
  name: joinTableName,
2633
2636
  joinColumn: joinTable.inverseJoinColumn,
2634
2637
  inverseJoinColumn: joinTable.joinColumn,
@@ -6176,15 +6179,15 @@ const getNextIdsToCreateDocumentId = async (db, knex2, {
6176
6179
  };
6177
6180
  const migrateDocumentIdsWithLocalizations = async (db, knex2, meta) => {
6178
6181
  const singularName = meta.singularName.toLowerCase();
6179
- const joinColumn = identifiers.getJoinColumnAttributeIdName(singularName);
6180
- const inverseJoinColumn = identifiers.getInverseJoinColumnAttributeIdName(singularName);
6182
+ const joinColumn = _.snakeCase(`${singularName}_id`);
6183
+ const inverseJoinColumn = _.snakeCase(`inv_${singularName}_id`);
6181
6184
  let ids;
6182
6185
  do {
6183
6186
  ids = await getNextIdsToCreateDocumentId(db, knex2, {
6184
6187
  joinColumn,
6185
6188
  inverseJoinColumn,
6186
6189
  tableName: meta.tableName,
6187
- joinTableName: identifiers.getJoinTableName(meta.tableName, `localizations`)
6190
+ joinTableName: _.snakeCase(`${meta.tableName}_localizations_links`)
6188
6191
  });
6189
6192
  if (ids.length > 0) {
6190
6193
  await knex2(meta.tableName).update({ document_id: cuid2.createId() }).whereIn("id", ids);
@@ -6206,7 +6209,7 @@ const createDocumentIdColumn = async (knex2, tableName) => {
6206
6209
  });
6207
6210
  };
6208
6211
  const hasLocalizationsJoinTable = async (knex2, tableName) => {
6209
- const joinTableName = identifiers.getJoinTableName(tableName, "localizations");
6212
+ const joinTableName = _.snakeCase(`${tableName}_localizations_links`);
6210
6213
  return knex2.schema.hasTable(joinTableName);
6211
6214
  };
6212
6215
  const createdDocumentId = {