UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 979 B
import{copy as e}from"../../i18n/copy.mjs";import t from"../../../constants/constants.mjs";import n from"../../logger/index.mjs";import{addColumn as r}from"./column-builder.mjs";import{addIndex as i}from"./index-builder.mjs";const a=async(a,o)=>{try{let e=a.db.client.schema.createTable(o.migration.tableName);for(let i of o.migration.columnOperations)i.type===`add`&&(e=r(e,i,a.config.db),n.debug({message:`Operation of type 'add' ran on column '${i.column.name}' for table '${o.migration.tableName}'`,scope:t.logScopes.migrations}));return await e.execute(),await Promise.all(o.migration.indexOperations.filter(e=>e.type===`add`).map(e=>i(a,o.migration.tableName,e.index))),{data:void 0,error:void 0}}catch(t){return{data:void 0,error:{message:e(`server:core.collections.migration.table.create.failed.message`,{data:{tableName:o.migration.tableName,errorMessage:t instanceof Error?t.message:String(t)}})}}}};export{a as default}; //# sourceMappingURL=create-table-query.mjs.map