mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
1 parent
ee4dc90cf3
commit
1472c1567c
8 files changed
+48
-23
No files matched your search
@@ -21,7 +21,7 @@ const logger = new Logger('upgrade');
|
||||
type UpgradeScript = () => Promise<boolean | void>;
|
||||
|
||||
async function iterateAllDomain(cb: (ddoc: DomainDoc, current?: number, total?: number) => Promise<any>) {
|
||||
const ddocs = await domain.getMulti().project({ _id: 1 }).toArray();
|
||||
const ddocs = await domain.getMulti().project({ _id: 1, owner: 1 }).toArray();
|
||||
for (const i in ddocs) await cb(ddocs[i], +i, ddocs.length);
|
||||
}
|
||||
|
||||
@@ -220,6 +220,13 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
return true;
|
||||
},
|
||||
// Set domain owner perm
|
||||
async function _13_14() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllDomain((ddoc) => domain.setUserRole(ddoc._id, ddoc.owner, 'root'));
|
||||
await db.collection('domain.user').updateMany({ role: 'admin' }, { $set: { role: 'root' } });
|
||||
return true;
|
||||
},
|
||||
];
|
||||
|
||||
export = scripts;
|
||||
Reference in new issue
Block a user