@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.73 kB
Source Map (JSON)
{"version":3,"file":"index-builder.mjs","names":["constants"],"sources":["../../../../src/libs/collection/migration/index-builder.ts"],"sourcesContent":["import constants from \"../../../constants/constants.js\";\nimport logger from \"../../../libs/logger/index.js\";\nimport type { ServiceContext } from \"../../../types.js\";\nimport type { CollectionSchemaIndex } from \"../schema/types.js\";\n\nexport const addIndex = async (\n\tcontext: ServiceContext,\n\ttableName: string,\n\tindex: CollectionSchemaIndex,\n) => {\n\tlet query = context.db.client.schema\n\t\t.createIndex(index.name)\n\t\t.on(tableName)\n\t\t.columns(index.columns);\n\n\tif (index.unique) query = query.unique();\n\n\tawait query.execute();\n\tlogger.debug({\n\t\tmessage: `Operation of type 'add' ran on index '${index.name}' for table '${tableName}'`,\n\t\tscope: constants.logScopes.migrations,\n\t});\n};\n\nexport const dropIndex = async (\n\tcontext: ServiceContext,\n\ttableName: string,\n\tindexName: string,\n) => {\n\tawait context.db.client.schema.dropIndex(indexName).ifExists().execute();\n\tlogger.debug({\n\t\tmessage: `Operation of type 'remove' ran on index '${indexName}' for table '${tableName}'`,\n\t\tscope: constants.logScopes.migrations,\n\t});\n};\n"],"mappings":"sFAKA,MAAa,EAAW,MACvB,EACA,EACA,IACI,CACJ,IAAI,EAAQ,EAAQ,GAAG,OAAO,OAC5B,YAAY,EAAM,IAAI,CAAC,CACvB,GAAG,CAAS,CAAC,CACb,QAAQ,EAAM,OAAO,EAEnB,EAAM,SAAQ,EAAQ,EAAM,OAAO,GAEvC,MAAM,EAAM,QAAQ,EACpB,EAAO,MAAM,CACZ,QAAS,yCAAyC,EAAM,KAAK,eAAe,EAAU,GACtF,MAAOA,EAAU,UAAU,UAC5B,CAAC,CACF,EAEa,EAAY,MACxB,EACA,EACA,IACI,CACJ,MAAM,EAAQ,GAAG,OAAO,OAAO,UAAU,CAAS,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EACvE,EAAO,MAAM,CACZ,QAAS,4CAA4C,EAAU,eAAe,EAAU,GACxF,MAAOA,EAAU,UAAU,UAC5B,CAAC,CACF"}