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