Browse Source

feat: create column if missing in table(created/updated time)

pull/7304/head
Pranav C 11 months ago
parent
commit
6105f747c0
  1. 25
      packages/nocodb/src/services/columns.service.ts

25
packages/nocodb/src/services/columns.service.ts

@ -1720,7 +1720,30 @@ export class ColumnsService {
if (!dbColumn) {
// create column in db
const column = sqlClient;
const tableUpdateBody = {
...table,
tn: table.table_name,
originalColumns: table.columns.map((c) => ({
...c,
cn: c.column_name,
})),
columns: [
...table.columns.map((c) => ({ ...c, cn: c.column_name })),
{
...colBody,
cn: UITypes.CreateTime ? 'created_at' : 'updated_at',
altered: Altered.NEW_COLUMN,
},
],
};
const sqlClient = await reuseOrSave('sqlClient', reuse, async () =>
NcConnectionMgrv2.getSqlClient(source),
);
const sqlMgr = await reuseOrSave('sqlMgr', reuse, async () =>
ProjectMgrv2.getSqlMgr({ id: source.base_id }),
);
await sqlMgr.sqlOpPlus(source, 'tableUpdate', tableUpdateBody);
}
await Column.insert({

Loading…
Cancel
Save