@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 +9 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -6
- package/dist/index.mjs.map +1 -1
- package/dist/metadata/relations.d.ts.map +1 -1
- package/dist/migrations/internal-migrations/5.0.0-02-document-id.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2315,7 +2315,7 @@ const createMorphToOne = (attributeName, attribute) => {
|
|
|
2315
2315
|
});
|
|
2316
2316
|
};
|
|
2317
2317
|
const createMorphToMany = (attributeName, attribute, meta, metadata) => {
|
|
2318
|
-
if ("joinTable" in attribute && attribute.joinTable) {
|
|
2318
|
+
if ("joinTable" in attribute && attribute.joinTable && !attribute.joinTable.__internal__) {
|
|
2319
2319
|
return;
|
|
2320
2320
|
}
|
|
2321
2321
|
const joinTableName = identifiers.getMorphTableName(meta.tableName, attributeName);
|
|
@@ -2385,6 +2385,7 @@ const createMorphToMany = (attributeName, attribute, meta, metadata) => {
|
|
|
2385
2385
|
columnToAttribute: {}
|
|
2386
2386
|
});
|
|
2387
2387
|
const joinTable = {
|
|
2388
|
+
__internal__: true,
|
|
2388
2389
|
name: joinTableName,
|
|
2389
2390
|
joinColumn: {
|
|
2390
2391
|
name: joinColumnName,
|
|
@@ -2454,7 +2455,7 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
|
|
|
2454
2455
|
if (!targetMeta) {
|
|
2455
2456
|
throw new Error(`Unknown target ${attribute.target}`);
|
|
2456
2457
|
}
|
|
2457
|
-
if ("joinTable" in attribute && attribute.joinTable) {
|
|
2458
|
+
if ("joinTable" in attribute && attribute.joinTable && !attribute.joinTable.__internal__) {
|
|
2458
2459
|
return;
|
|
2459
2460
|
}
|
|
2460
2461
|
const joinTableName = identifiers.getJoinTableName(
|
|
@@ -2538,6 +2539,7 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
|
|
|
2538
2539
|
columnToAttribute: {}
|
|
2539
2540
|
};
|
|
2540
2541
|
const joinTable = {
|
|
2542
|
+
__internal__: true,
|
|
2541
2543
|
name: joinTableName,
|
|
2542
2544
|
joinColumn: {
|
|
2543
2545
|
name: joinColumnName,
|
|
@@ -2597,6 +2599,7 @@ const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
|
|
|
2597
2599
|
);
|
|
2598
2600
|
}
|
|
2599
2601
|
inverseAttribute.joinTable = {
|
|
2602
|
+
__internal__: true,
|
|
2600
2603
|
name: joinTableName,
|
|
2601
2604
|
joinColumn: joinTable.inverseJoinColumn,
|
|
2602
2605
|
inverseJoinColumn: joinTable.joinColumn,
|
|
@@ -6144,15 +6147,15 @@ const getNextIdsToCreateDocumentId = async (db, knex2, {
|
|
|
6144
6147
|
};
|
|
6145
6148
|
const migrateDocumentIdsWithLocalizations = async (db, knex2, meta) => {
|
|
6146
6149
|
const singularName = meta.singularName.toLowerCase();
|
|
6147
|
-
const joinColumn =
|
|
6148
|
-
const inverseJoinColumn =
|
|
6150
|
+
const joinColumn = snakeCase(`${singularName}_id`);
|
|
6151
|
+
const inverseJoinColumn = snakeCase(`inv_${singularName}_id`);
|
|
6149
6152
|
let ids;
|
|
6150
6153
|
do {
|
|
6151
6154
|
ids = await getNextIdsToCreateDocumentId(db, knex2, {
|
|
6152
6155
|
joinColumn,
|
|
6153
6156
|
inverseJoinColumn,
|
|
6154
6157
|
tableName: meta.tableName,
|
|
6155
|
-
joinTableName:
|
|
6158
|
+
joinTableName: snakeCase(`${meta.tableName}_localizations_links`)
|
|
6156
6159
|
});
|
|
6157
6160
|
if (ids.length > 0) {
|
|
6158
6161
|
await knex2(meta.tableName).update({ document_id: createId() }).whereIn("id", ids);
|
|
@@ -6174,7 +6177,7 @@ const createDocumentIdColumn = async (knex2, tableName) => {
|
|
|
6174
6177
|
});
|
|
6175
6178
|
};
|
|
6176
6179
|
const hasLocalizationsJoinTable = async (knex2, tableName) => {
|
|
6177
|
-
const joinTableName =
|
|
6180
|
+
const joinTableName = snakeCase(`${tableName}_localizations_links`);
|
|
6178
6181
|
return knex2.schema.hasTable(joinTableName);
|
|
6179
6182
|
};
|
|
6180
6183
|
const createdDocumentId = {
|