2024-11-24 23:52:52 +02:00
|
|
|
import { fetch } from "pouchdb-fetch";
|
|
|
|
|
|
|
|
|
|
const dbsSecurity = {
|
|
|
|
|
web_push_subscriptions: {
|
|
|
|
|
admins: { roles: ["_admin"] },
|
|
|
|
|
members: { roles: [] },
|
|
|
|
|
},
|
|
|
|
|
messages: {
|
|
|
|
|
admins: { roles: ["_admin"] },
|
|
|
|
|
members: { roles: [] },
|
|
|
|
|
},
|
|
|
|
|
server_settings: {
|
|
|
|
|
admins: { roles: ["_admin"] },
|
2024-11-25 01:08:46 +02:00
|
|
|
qr: {
|
|
|
|
|
admins: { roles: ["_admin"] },
|
|
|
|
|
members: { roles: [] },
|
|
|
|
|
|
|
|
|
|
members: { roles: ["_admin"] },
|
|
|
|
|
},
|
|
|
|
|
public_settings: {
|
|
|
|
|
admins: { roles: ["_admin"] },
|
|
|
|
|
members: { roles: [] },
|
|
|
|
|
},
|
2024-11-24 23:52:52 +02:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const up = async () => {
|
|
|
|
|
for (const [dbName, dbSecurity] of Object.entries(dbsSecurity)) {
|
|
|
|
|
await fetch(`${process.env.API_URL}/${dbName}`, {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
});
|
|
|
|
|
await fetch(`${process.env.API_URL}/${dbName}/_security`, {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
body: JSON.stringify(dbSecurity),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const down = async () => {
|
|
|
|
|
for (const dbName of Object.keys(dbsSecurity)) {
|
|
|
|
|
await fetch(`${process.env.API_URL}/${dbName}`, {
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|