@strapi/database 5.12.4 → 5.12.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/schema/storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;6BAIlB,QAAQ;YAmBV,QAAQ;QACpB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,IAAI,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/schema/storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;6BAIlB,QAAQ;YAmBV,QAAQ;QACpB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,IAAI,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;uBAmCU,MAAM;gBAIP,MAAM;;;AA/D5B,wBAuFE"}
|
package/dist/schema/storage.js
CHANGED
|
@@ -23,7 +23,15 @@ var createSchemaStorage = ((db)=>{
|
|
|
23
23
|
return {
|
|
24
24
|
async read () {
|
|
25
25
|
await checkTableExists();
|
|
26
|
-
|
|
26
|
+
// NOTE: We get the ID first before fetching the exact entry for performance on MySQL/MariaDB
|
|
27
|
+
// See: https://github.com/strapi/strapi/issues/20312
|
|
28
|
+
const getSchemaID = await db.getConnection().select('id').from(TABLE_NAME).orderBy('time', 'DESC').first();
|
|
29
|
+
if (!getSchemaID) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const res = await db.getConnection().select('*').from(TABLE_NAME).where({
|
|
33
|
+
id: getSchemaID.id
|
|
34
|
+
}).first();
|
|
27
35
|
if (!res) {
|
|
28
36
|
return null;
|
|
29
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sources":["../../src/schema/storage.ts"],"sourcesContent":["import crypto from 'crypto';\n\nimport type { Database } from '..';\nimport type { Schema } from './types';\n\nconst TABLE_NAME = 'strapi_database_schema';\n\nexport default (db: Database) => {\n const hasSchemaTable = () => db.getSchemaConnection().hasTable(TABLE_NAME);\n\n const createSchemaTable = () => {\n return db.getSchemaConnection().createTable(TABLE_NAME, (t) => {\n t.increments('id');\n t.json('schema');\n t.datetime('time', { useTz: false });\n t.string('hash');\n });\n };\n\n const checkTableExists = async () => {\n if (!(await hasSchemaTable())) {\n await createSchemaTable();\n }\n };\n\n return {\n async read(): Promise<{\n id: number;\n time: Date;\n hash: string;\n schema: Schema;\n } | null> {\n await checkTableExists();\n\n const
|
|
1
|
+
{"version":3,"file":"storage.js","sources":["../../src/schema/storage.ts"],"sourcesContent":["import crypto from 'crypto';\n\nimport type { Database } from '..';\nimport type { Schema } from './types';\n\nconst TABLE_NAME = 'strapi_database_schema';\n\nexport default (db: Database) => {\n const hasSchemaTable = () => db.getSchemaConnection().hasTable(TABLE_NAME);\n\n const createSchemaTable = () => {\n return db.getSchemaConnection().createTable(TABLE_NAME, (t) => {\n t.increments('id');\n t.json('schema');\n t.datetime('time', { useTz: false });\n t.string('hash');\n });\n };\n\n const checkTableExists = async () => {\n if (!(await hasSchemaTable())) {\n await createSchemaTable();\n }\n };\n\n return {\n async read(): Promise<{\n id: number;\n time: Date;\n hash: string;\n schema: Schema;\n } | null> {\n await checkTableExists();\n\n // NOTE: We get the ID first before fetching the exact entry for performance on MySQL/MariaDB\n // See: https://github.com/strapi/strapi/issues/20312\n const getSchemaID = await db\n .getConnection()\n .select('id')\n .from(TABLE_NAME)\n .orderBy('time', 'DESC')\n .first();\n\n if (!getSchemaID) {\n return null;\n }\n\n const res = await db\n .getConnection()\n .select('*')\n .from(TABLE_NAME)\n .where({ id: getSchemaID.id })\n .first();\n\n if (!res) {\n return null;\n }\n\n const parsedSchema = typeof res.schema === 'object' ? res.schema : JSON.parse(res.schema);\n\n return {\n ...res,\n schema: parsedSchema,\n };\n },\n\n hashSchema(schema: Schema) {\n return crypto.createHash('md5').update(JSON.stringify(schema)).digest('hex');\n },\n\n async add(schema: Schema) {\n await checkTableExists();\n\n // NOTE: we can remove this to add history\n await db.getConnection(TABLE_NAME).delete();\n\n const time = new Date();\n\n await db\n .getConnection()\n .insert({\n schema: JSON.stringify(schema),\n hash: this.hashSchema(schema),\n time,\n })\n .into(TABLE_NAME);\n },\n\n async clear() {\n await checkTableExists();\n\n await db.getConnection(TABLE_NAME).truncate();\n },\n };\n};\n"],"names":["TABLE_NAME","db","hasSchemaTable","getSchemaConnection","hasTable","createSchemaTable","createTable","t","increments","json","datetime","useTz","string","checkTableExists","read","getSchemaID","getConnection","select","from","orderBy","first","res","where","id","parsedSchema","schema","JSON","parse","hashSchema","crypto","createHash","update","stringify","digest","add","delete","time","Date","insert","hash","into","clear","truncate"],"mappings":";;;;AAKA,MAAMA,UAAa,GAAA,wBAAA;AAEnB,0BAAe,CAAA,CAACC,EAAAA,GAAAA;AACd,IAAA,MAAMC,iBAAiB,IAAMD,EAAAA,CAAGE,mBAAmB,EAAA,CAAGC,QAAQ,CAACJ,UAAAA,CAAAA;AAE/D,IAAA,MAAMK,iBAAoB,GAAA,IAAA;AACxB,QAAA,OAAOJ,GAAGE,mBAAmB,EAAA,CAAGG,WAAW,CAACN,YAAY,CAACO,CAAAA,GAAAA;AACvDA,YAAAA,CAAAA,CAAEC,UAAU,CAAC,IAAA,CAAA;AACbD,YAAAA,CAAAA,CAAEE,IAAI,CAAC,QAAA,CAAA;YACPF,CAAEG,CAAAA,QAAQ,CAAC,MAAQ,EA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ASQ,CAAAA,CAAAA,CAAAA,MAAM,CAAC,KAAA,CAAA;AACxE,SAAA;AAEA,QAAA,MAAMC,KAAIT,MAAc,EAAA;YACtB,MAAMZ,gBAAAA,EAAAA;;AAGN,YAAA,MAAMZ,EAAGe,CAAAA,aAAa,CAAChB,UAAAA,CAAAA,CAAYmC,MAAM,EAAA;AAEzC,YAAA,MAAMC,OAAO,IAAIC,IAAAA,EAAAA;AAEjB,YAAA,MAAMpC,EACHe,CAAAA,aAAa,EACbsB,CAAAA,MAAM,CAAC;gBACNb,MAAQC,EAAAA,IAAAA,CAAKM,SAAS,CAACP,MAAAA,CAAAA;gBACvBc,IAAM,EAAA,IAAI,CAACX,UAAU,CAACH,MAAAA,CAAAA;AACtBW,gBAAAA;AACF,aAAA,CAAA,CACCI,IAAI,CAACxC,UAAAA,CAAAA;AACV,SAAA;QAEA,MAAMyC,KAAAA,CAAAA,GAAAA;YACJ,MAAM5B,gBAAAA,EAAAA;AAEN,YAAA,MAAMZ,EAAGe,CAAAA,aAAa,CAAChB,UAAAA,CAAAA,CAAY0C,QAAQ,EAAA;AAC7C;AACF,KAAA;AACF,CAAA;;;;"}
|
package/dist/schema/storage.mjs
CHANGED
|
@@ -21,7 +21,15 @@ var createSchemaStorage = ((db)=>{
|
|
|
21
21
|
return {
|
|
22
22
|
async read () {
|
|
23
23
|
await checkTableExists();
|
|
24
|
-
|
|
24
|
+
// NOTE: We get the ID first before fetching the exact entry for performance on MySQL/MariaDB
|
|
25
|
+
// See: https://github.com/strapi/strapi/issues/20312
|
|
26
|
+
const getSchemaID = await db.getConnection().select('id').from(TABLE_NAME).orderBy('time', 'DESC').first();
|
|
27
|
+
if (!getSchemaID) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const res = await db.getConnection().select('*').from(TABLE_NAME).where({
|
|
31
|
+
id: getSchemaID.id
|
|
32
|
+
}).first();
|
|
25
33
|
if (!res) {
|
|
26
34
|
return null;
|
|
27
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.mjs","sources":["../../src/schema/storage.ts"],"sourcesContent":["import crypto from 'crypto';\n\nimport type { Database } from '..';\nimport type { Schema } from './types';\n\nconst TABLE_NAME = 'strapi_database_schema';\n\nexport default (db: Database) => {\n const hasSchemaTable = () => db.getSchemaConnection().hasTable(TABLE_NAME);\n\n const createSchemaTable = () => {\n return db.getSchemaConnection().createTable(TABLE_NAME, (t) => {\n t.increments('id');\n t.json('schema');\n t.datetime('time', { useTz: false });\n t.string('hash');\n });\n };\n\n const checkTableExists = async () => {\n if (!(await hasSchemaTable())) {\n await createSchemaTable();\n }\n };\n\n return {\n async read(): Promise<{\n id: number;\n time: Date;\n hash: string;\n schema: Schema;\n } | null> {\n await checkTableExists();\n\n const
|
|
1
|
+
{"version":3,"file":"storage.mjs","sources":["../../src/schema/storage.ts"],"sourcesContent":["import crypto from 'crypto';\n\nimport type { Database } from '..';\nimport type { Schema } from './types';\n\nconst TABLE_NAME = 'strapi_database_schema';\n\nexport default (db: Database) => {\n const hasSchemaTable = () => db.getSchemaConnection().hasTable(TABLE_NAME);\n\n const createSchemaTable = () => {\n return db.getSchemaConnection().createTable(TABLE_NAME, (t) => {\n t.increments('id');\n t.json('schema');\n t.datetime('time', { useTz: false });\n t.string('hash');\n });\n };\n\n const checkTableExists = async () => {\n if (!(await hasSchemaTable())) {\n await createSchemaTable();\n }\n };\n\n return {\n async read(): Promise<{\n id: number;\n time: Date;\n hash: string;\n schema: Schema;\n } | null> {\n await checkTableExists();\n\n // NOTE: We get the ID first before fetching the exact entry for performance on MySQL/MariaDB\n // See: https://github.com/strapi/strapi/issues/20312\n const getSchemaID = await db\n .getConnection()\n .select('id')\n .from(TABLE_NAME)\n .orderBy('time', 'DESC')\n .first();\n\n if (!getSchemaID) {\n return null;\n }\n\n const res = await db\n .getConnection()\n .select('*')\n .from(TABLE_NAME)\n .where({ id: getSchemaID.id })\n .first();\n\n if (!res) {\n return null;\n }\n\n const parsedSchema = typeof res.schema === 'object' ? res.schema : JSON.parse(res.schema);\n\n return {\n ...res,\n schema: parsedSchema,\n };\n },\n\n hashSchema(schema: Schema) {\n return crypto.createHash('md5').update(JSON.stringify(schema)).digest('hex');\n },\n\n async add(schema: Schema) {\n await checkTableExists();\n\n // NOTE: we can remove this to add history\n await db.getConnection(TABLE_NAME).delete();\n\n const time = new Date();\n\n await db\n .getConnection()\n .insert({\n schema: JSON.stringify(schema),\n hash: this.hashSchema(schema),\n time,\n })\n .into(TABLE_NAME);\n },\n\n async clear() {\n await checkTableExists();\n\n await db.getConnection(TABLE_NAME).truncate();\n },\n };\n};\n"],"names":["TABLE_NAME","db","hasSchemaTable","getSchemaConnection","hasTable","createSchemaTable","createTable","t","increments","json","datetime","useTz","string","checkTableExists","read","getSchemaID","getConnection","select","from","orderBy","first","res","where","id","parsedSchema","schema","JSON","parse","hashSchema","crypto","createHash","update","stringify","digest","add","delete","time","Date","insert","hash","into","clear","truncate"],"mappings":";;AAKA,MAAMA,UAAa,GAAA,wBAAA;AAEnB,0BAAe,CAAA,CAACC,EAAAA,GAAAA;AACd,IAAA,MAAMC,iBAAiB,IAAMD,EAAAA,CAAGE,mBAAmB,EAAA,CAAGC,QAAQ,CAACJ,UAAAA,CAAAA;AAE/D,IAAA,MAAMK,iBAAoB,GAAA,IAAA;AACxB,QAAA,OAAOJ,GAAGE,mBAAmB,EAAA,CAAGG,WAAW,CAACN,YAAY,CAACO,CAAAA,GAAAA;AACvDA,YAAAA,CAAAA,CAAEC,UAAU,CAAC,IAAA,CAAA;AACbD,YAAAA,CAAAA,CAAEE,IAAI,CAAC,QAAA,CAAA;YACPF,CAAEG,CAAAA,QAAQ,CAAC,MAAQ,EAAA;gBAAEC,KAAO,EAAA;AAAM,aAAA,CAAA;AAClCJ,YAAAA,CAAAA,CAAEK,MAAM,CAAC,MAAA,CAAA;AACX,SAAA,CAAA;AACF,KAAA;AAEA,IAAA,MAAMC,gBAAmB,GAAA,UAAA;QACvB,IAAI,C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ChB,UAAAA,CAAAA,CAAYmC,MAAM,EAAA;AAEzC,YAAA,MAAMC,OAAO,IAAIC,IAAAA,EAAAA;AAEjB,YAAA,MAAMpC,EACHe,CAAAA,aAAa,EACbsB,CAAAA,MAAM,CAAC;gBACNb,MAAQC,EAAAA,IAAAA,CAAKM,SAAS,CAACP,MAAAA,CAAAA;gBACvBc,IAAM,EAAA,IAAI,CAACX,UAAU,CAACH,MAAAA,CAAAA;AACtBW,gBAAAA;AACF,aAAA,CAAA,CACCI,IAAI,CAACxC,UAAAA,CAAAA;AACV,SAAA;QAEA,MAAMyC,KAAAA,CAAAA,GAAAA;YACJ,MAAM5B,gBAAAA,EAAAA;AAEN,YAAA,MAAMZ,EAAGe,CAAAA,aAAa,CAAChB,UAAAA,CAAAA,CAAY0C,QAAQ,EAAA;AAC7C;AACF,KAAA;AACF,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/database",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.5",
|
|
4
4
|
"description": "Strapi's database layer",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@paralleldrive/cuid2": "2.2.2",
|
|
45
|
-
"@strapi/utils": "5.12.
|
|
45
|
+
"@strapi/utils": "5.12.5",
|
|
46
46
|
"ajv": "8.16.0",
|
|
47
47
|
"date-fns": "2.30.0",
|
|
48
48
|
"debug": "4.3.4",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/fs-extra": "11.0.4",
|
|
57
|
-
"eslint-config-custom": "5.12.
|
|
58
|
-
"tsconfig": "5.12.
|
|
57
|
+
"eslint-config-custom": "5.12.5",
|
|
58
|
+
"tsconfig": "5.12.5"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=18.0.0 <=22.x.x",
|