@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.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { isKnexQuery } from './utils/knex';
|
|
|
13
13
|
interface Settings {
|
|
14
14
|
forceMigration?: boolean;
|
|
15
15
|
runMigrations?: boolean;
|
|
16
|
+
strictSyncSchema?: boolean;
|
|
16
17
|
[key: string]: unknown;
|
|
17
18
|
}
|
|
18
19
|
export type Logger = Record<'info' | 'warn' | 'error' | 'debug', (message: string | Record<string, unknown>) => void>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAc,MAAM,YAAY,CAAC;AACjD,OAAO,EAAwB,cAAc,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAkB,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAuB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAA4B,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAA4B,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAkB,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AA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AAU,EAAE,iBAAiB,CAAC;IAE9B,aAAa,EAAE,aAAa,CAAC;IAE7B,MAAM,EAAE,aAAa,CAAC;IAEtB,MAAM,CAAC,qBAAqB,2EAAyB;WAExC,IAAI,CAAC,MAAM,EAAE,cAAc;gBAM5B,MAAM,EAAE,cAAc;IA8BlC,KAAK,CAAC,GAAG,EAAE,MAAM;IAQjB,aAAa;IAIb,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IACzC,WAAW,CAAC,SAAS,SAAS,QAAQ,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IA4CrF,aAAa,IAAI,MAAM,GAAG,SAAS;IAInC,aAAa,IAAI,IAAI;IACrB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,YAAY;IAOpD,mBAAmB,CAAC,GAAG,mBAAkB;IAKzC,YAAY,CAAC,GAAG,EAAE,MAAM;IAIlB,OAAO;CAId;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1364,7 +1364,7 @@ const createSchemaDiff = (db) => {
|
|
|
1364
1364
|
const diffColumns = (oldColumn, column) => {
|
|
1365
1365
|
const changes = [];
|
|
1366
1366
|
const isIgnoredType = ["increments"].includes(column.type);
|
|
1367
|
-
const oldType = oldColumn.type;
|
|
1367
|
+
const oldType = db.dialect.getSqlType(oldColumn.type);
|
|
1368
1368
|
const type = db.dialect.getSqlType(column.type);
|
|
1369
1369
|
if (oldType !== type && !isIgnoredType) {
|
|
1370
1370
|
changes.push("type");
|
|
@@ -1855,10 +1855,10 @@ const createSchemaProvider = (db) => {
|
|
|
1855
1855
|
await this.drop();
|
|
1856
1856
|
await this.create();
|
|
1857
1857
|
},
|
|
1858
|
-
async syncSchema() {
|
|
1858
|
+
async syncSchema(oldSchema) {
|
|
1859
1859
|
debug$1("Synchronizing database schema");
|
|
1860
|
-
const
|
|
1861
|
-
const { status, diff } = await this.schemaDiff.diff(
|
|
1860
|
+
const currentSchema = oldSchema ?? await db.dialect.schemaInspector.getSchema();
|
|
1861
|
+
const { status, diff } = await this.schemaDiff.diff(currentSchema, schema);
|
|
1862
1862
|
if (status === "CHANGED") {
|
|
1863
1863
|
await this.builder.updateSchema(diff);
|
|
1864
1864
|
}
|
|
@@ -1883,6 +1883,10 @@ const createSchemaProvider = (db) => {
|
|
|
1883
1883
|
const hash = await this.schemaStorage.hashSchema(schema);
|
|
1884
1884
|
if (oldHash !== hash) {
|
|
1885
1885
|
debug$1("Schema changed");
|
|
1886
|
+
if (!db.config.settings.strictSyncSchema) {
|
|
1887
|
+
debug$1("Syncing schema keeping not Strapi managed elements");
|
|
1888
|
+
return this.syncSchema(oldSchema.schema);
|
|
1889
|
+
}
|
|
1886
1890
|
return this.syncSchema();
|
|
1887
1891
|
}
|
|
1888
1892
|
debug$1("Schema unchanged");
|
|
@@ -6262,6 +6266,7 @@ class Database {
|
|
|
6262
6266
|
settings: {
|
|
6263
6267
|
forceMigration: true,
|
|
6264
6268
|
runMigrations: true,
|
|
6269
|
+
strictSyncSchema: true,
|
|
6265
6270
|
...config.settings ?? {}
|
|
6266
6271
|
}
|
|
6267
6272
|
};
|