Browse Source

Merge pull request #5933 from nocodb/fix/LTAR-upgrader-bug

fix:  LTAR upgrader bug
pull/5940/head
Pranav C 1 year ago committed by GitHub
parent
commit
c07f114006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      packages/nocodb/src/version-upgrader/ncXcdbLTARUpgrader.ts

20
packages/nocodb/src/version-upgrader/ncXcdbLTARUpgrader.ts

@ -31,6 +31,7 @@ async function upgradeModelRelations({
rtn: string;
cn: string;
rcn: string;
cstn?: string;
}[];
}) {
// Iterate over each column and upgrade LTAR
@ -74,6 +75,7 @@ async function upgradeModelRelations({
childColumn: relation.cn,
parentTable: relation.rtn,
childTable: relation.tn,
foreignKeyName: relation.cstn,
});
}
@ -119,17 +121,14 @@ async function upgradeModelRelations({
async function upgradeBaseRelations({
ncMeta,
base,
relations,
}: {
ncMeta: MetaService;
base: any;
relations: any;
}) {
// const sqlMgr = ProjectMgrv2.getSqlMgr({ id: base.project_id }, ncMeta);
const sqlClient = await NcConnectionMgrv2.getSqlClient(base, ncMeta.knex);
// get all relations
const relations = (await sqlClient.relationListAll())?.data?.list;
// get models for the base
const models = await ncMeta.metaList2(null, base.id, MetaTable.MODELS);
@ -154,11 +153,22 @@ export default async function ({ ncMeta }: NcUpgraderCtx) {
orderBy: {},
});
if (!bases.length) return;
const sqlClient = await NcConnectionMgrv2.getSqlClient(
new Base(bases[0]),
ncMeta.knex,
);
// get all relations
const relations = (await sqlClient.relationListAll())?.data?.list;
// iterate and upgrade each base
for (const base of bases) {
await upgradeBaseRelations({
ncMeta,
base: new Base(base),
relations,
});
}
}

Loading…
Cancel
Save