@strapi/database 4.25.22 → 4.25.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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -4
- package/dist/index.mjs.map +1 -1
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1330,7 +1330,7 @@ const createSchemaDiff = (db) => {
|
|
|
1330
1330
|
const diffColumns = (oldColumn, column) => {
|
|
1331
1331
|
const changes = [];
|
|
1332
1332
|
const isIgnoredType = ["increments"].includes(column.type);
|
|
1333
|
-
const oldType = oldColumn.type;
|
|
1333
|
+
const oldType = db.dialect.getSqlType(oldColumn.type);
|
|
1334
1334
|
const type = db.dialect.getSqlType(column.type);
|
|
1335
1335
|
if (oldType !== type && !isIgnoredType) {
|
|
1336
1336
|
changes.push("type");
|
|
@@ -1821,10 +1821,10 @@ const createSchemaProvider = (db) => {
|
|
|
1821
1821
|
await this.drop();
|
|
1822
1822
|
await this.create();
|
|
1823
1823
|
},
|
|
1824
|
-
async syncSchema() {
|
|
1824
|
+
async syncSchema(oldSchema) {
|
|
1825
1825
|
debug$1("Synchronizing database schema");
|
|
1826
|
-
const
|
|
1827
|
-
const { status, diff } = await this.schemaDiff.diff(
|
|
1826
|
+
const currentSchema = oldSchema ?? await db.dialect.schemaInspector.getSchema();
|
|
1827
|
+
const { status, diff } = await this.schemaDiff.diff(currentSchema, schema);
|
|
1828
1828
|
if (status === "CHANGED") {
|
|
1829
1829
|
await this.builder.updateSchema(diff);
|
|
1830
1830
|
}
|
|
@@ -1849,6 +1849,10 @@ const createSchemaProvider = (db) => {
|
|
|
1849
1849
|
const hash = await this.schemaStorage.hashSchema(schema);
|
|
1850
1850
|
if (oldHash !== hash) {
|
|
1851
1851
|
debug$1("Schema changed");
|
|
1852
|
+
if (!db.config.settings.strictSyncSchema) {
|
|
1853
|
+
debug$1("Syncing schema keeping not Strapi managed elements");
|
|
1854
|
+
return this.syncSchema(oldSchema.schema);
|
|
1855
|
+
}
|
|
1852
1856
|
return this.syncSchema();
|
|
1853
1857
|
}
|
|
1854
1858
|
debug$1("Schema unchanged");
|
|
@@ -6228,6 +6232,7 @@ class Database {
|
|
|
6228
6232
|
settings: {
|
|
6229
6233
|
forceMigration: true,
|
|
6230
6234
|
runMigrations: true,
|
|
6235
|
+
strictSyncSchema: true,
|
|
6231
6236
|
...config.settings ?? {}
|
|
6232
6237
|
}
|
|
6233
6238
|
};
|