@strapi/database 5.0.0-rc.22 → 5.0.0-rc.24
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 +18 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -9
- package/dist/index.mjs.map +1 -1
- package/dist/metadata/metadata.d.ts.map +1 -1
- package/dist/metadata/relations.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2293,7 +2293,7 @@ const createOneToOne = (attributeName, attribute, meta, metadata) => {
|
|
|
2293
2293
|
}
|
|
2294
2294
|
};
|
|
2295
2295
|
const createOneToMany = (attributeName, attribute, meta, metadata) => {
|
|
2296
|
-
if (!isBidirectional(attribute)) {
|
|
2296
|
+
if (shouldUseJoinTable(attribute) && !isBidirectional(attribute)) {
|
|
2297
2297
|
createJoinTable(metadata, {
|
|
2298
2298
|
attribute,
|
|
2299
2299
|
attributeName,
|
|
@@ -2322,7 +2322,7 @@ const createManyToOne = (attributeName, attribute, meta, metadata) => {
|
|
|
2322
2322
|
}
|
|
2323
2323
|
};
|
|
2324
2324
|
const createManyToMany = (attributeName, attribute, meta, metadata) => {
|
|
2325
|
-
if (!isBidirectional(attribute) || isOwner(attribute)) {
|
|
2325
|
+
if (shouldUseJoinTable(attribute) && (!isBidirectional(attribute) || isOwner(attribute))) {
|
|
2326
2326
|
createJoinTable(metadata, {
|
|
2327
2327
|
attribute,
|
|
2328
2328
|
attributeName,
|
|
@@ -2483,6 +2483,9 @@ const createJoinColumn = (metadata, { attribute, attributeName }) => {
|
|
|
2483
2483
|
}
|
|
2484
2484
|
};
|
|
2485
2485
|
const createJoinTable = (metadata, { attributeName, attribute, meta }) => {
|
|
2486
|
+
if (!shouldUseJoinTable(attribute)) {
|
|
2487
|
+
throw new Error("Attempted to create join table when useJoinTable is false");
|
|
2488
|
+
}
|
|
2486
2489
|
const targetMeta = metadata.get(attribute.target);
|
|
2487
2490
|
if (!targetMeta) {
|
|
2488
2491
|
throw new Error(`Unknown target ${attribute.target}`);
|
|
@@ -2717,6 +2720,9 @@ class Metadata extends Map {
|
|
|
2717
2720
|
for (const meta of this.values()) {
|
|
2718
2721
|
for (const [attributeName, attribute] of Object.entries(meta.attributes)) {
|
|
2719
2722
|
try {
|
|
2723
|
+
if (attribute.unstable_virtual) {
|
|
2724
|
+
continue;
|
|
2725
|
+
}
|
|
2720
2726
|
if (isRelationalAttribute(attribute)) {
|
|
2721
2727
|
createRelation(attributeName, attribute, meta, this);
|
|
2722
2728
|
continue;
|
|
@@ -6290,21 +6296,24 @@ const renameIndex = async (knex2, db, diff) => {
|
|
|
6290
6296
|
debug(`not renaming index ${full.indexName} because name hasn't changed`);
|
|
6291
6297
|
return;
|
|
6292
6298
|
}
|
|
6293
|
-
if (short.indexName.
|
|
6299
|
+
if (short.indexName.endsWith("fk") || full.indexName.endsWith("fk")) {
|
|
6294
6300
|
return;
|
|
6295
6301
|
}
|
|
6296
6302
|
debug(`renaming index from ${full.indexName} to ${short.indexName}`);
|
|
6297
6303
|
try {
|
|
6298
6304
|
await knex2.transaction(async (trx) => {
|
|
6299
6305
|
if (client === "mysql" || client === "mariadb") {
|
|
6300
|
-
await knex2.raw(
|
|
6301
|
-
|
|
6302
|
-
|
|
6306
|
+
await knex2.raw("ALTER TABLE ?? RENAME INDEX ?? TO ??", [
|
|
6307
|
+
full.tableName,
|
|
6308
|
+
full.indexName,
|
|
6309
|
+
short.indexName
|
|
6310
|
+
]).transacting(trx);
|
|
6303
6311
|
} else if (client === "pg" || client === "postgres") {
|
|
6304
|
-
await knex2.raw(
|
|
6305
|
-
} else if (
|
|
6312
|
+
await knex2.raw("ALTER INDEX ?? RENAME TO ??", [full.indexName, short.indexName]).transacting(trx);
|
|
6313
|
+
} else if (["sqlite", "sqlite3", "better-sqlite3"].includes(client)) {
|
|
6314
|
+
debug(`SQLite does not support index renaming, not renaming index ${full.indexName}`);
|
|
6306
6315
|
} else {
|
|
6307
|
-
debug(
|
|
6316
|
+
debug(`No db client name matches, not renaming index ${full.indexName}`);
|
|
6308
6317
|
}
|
|
6309
6318
|
});
|
|
6310
6319
|
} catch (err) {
|