(left, right)
| 120 | } |
| 121 | |
| 122 | export function diffColumns(left, right) { |
| 123 | left = JSON.parse(JSON.stringify(left)); |
| 124 | right = JSON.parse(JSON.stringify(right)); |
| 125 | const result = diff(left, right) ?? {}; |
| 126 | |
| 127 | const alteredTables = Object.fromEntries( |
| 128 | Object.entries(result) |
| 129 | .filter((it) => { |
| 130 | return !(it[0].includes('__added') || it[0].includes('__deleted')); |
| 131 | }) |
| 132 | .map((tableEntry) => { |
| 133 | // const entry = { name: it, ...result[it] } |
| 134 | const deletedColumns = Object.entries(tableEntry[1].columns ?? {}) |
| 135 | .filter((it) => { |
| 136 | return it[0].endsWith('__deleted'); |
| 137 | }) |
| 138 | .map((it) => { |
| 139 | return it[1]; |
| 140 | }); |
| 141 | |
| 142 | const addedColumns = Object.entries(tableEntry[1].columns ?? {}) |
| 143 | .filter((it) => { |
| 144 | return it[0].endsWith('__added'); |
| 145 | }) |
| 146 | .map((it) => { |
| 147 | return it[1]; |
| 148 | }); |
| 149 | |
| 150 | tableEntry[1].columns = { |
| 151 | added: addedColumns, |
| 152 | deleted: deletedColumns, |
| 153 | }; |
| 154 | const table = left[tableEntry[0]]; |
| 155 | return [ |
| 156 | tableEntry[0], |
| 157 | { name: table.name, schema: table.schema, ...tableEntry[1] }, |
| 158 | ]; |
| 159 | }), |
| 160 | ); |
| 161 | |
| 162 | return alteredTables; |
| 163 | } |
| 164 | |
| 165 | export function diffPolicies(left, right) { |
| 166 | left = JSON.parse(JSON.stringify(left)); |
no outgoing calls
no test coverage detected