node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
'use strict';
var crypto = require('crypto');
const TABLE_NAME = 'strapi_database_schema';
var createSchemaStorage = ((db)=>{
const hasSchemaTable = ()=>db.getSchemaConnection().hasTable(TABLE_NAME);
const createSchemaTable = ()=>{
return db.getSchemaConnection().createTable(TABLE_NAME, (t)=>{
t.increments('id');
t.json('schema');
t.datetime('time', {
useTz: false
});
t.string('hash');
});
};
const checkTableExists = async ()=>{
if (!await hasSchemaTable()) {
await createSchemaTable();
}
};
return {
async read () {
await checkTableExists();
// NOTE: We get the ID first before fetching the exact entry for performance on MySQL/MariaDB
// See: https://github.com/strapi/strapi/issues/20312
const getSchemaID = await db.getConnection().select('id').from(TABLE_NAME).orderBy('time', 'DESC').first();
if (!getSchemaID) {
return null;
}
const res = await db.getConnection().select('*').from(TABLE_NAME).where({
id: getSchemaID.id
}).first();
if (!res) {
return null;
}
const parsedSchema = typeof res.schema === 'object' ? res.schema : JSON.parse(res.schema);
return {
...res,
schema: parsedSchema
};
},
hashSchema (schema) {
return crypto.createHash('md5').update(JSON.stringify(schema)).digest('hex');
},
async add (schema) {
await checkTableExists();
// NOTE: we can remove this to add history
await db.getConnection(TABLE_NAME).delete();
const time = new Date();
await db.getConnection().insert({
schema: JSON.stringify(schema),
hash: this.hashSchema(schema),
time
}).into(TABLE_NAME);
},
async clear () {
await checkTableExists();
await db.getConnection(TABLE_NAME).truncate();
}
};
});
module.exports = createSchemaStorage;
//# sourceMappingURL=storage.js.map