Skip to content

Commit

Permalink
Merge pull request #132 from commerceblock/develop
Browse files Browse the repository at this point in the history
Release 1.2.3 - Db scripts
  • Loading branch information
Nikos Kostoulas authored Feb 4, 2020
2 parents b0977c8 + 533e4ce commit a8d57bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/db-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ db.createCollection("Attestation")
db.createCollection("AttestationInfo")
db.createCollection("ClientCommitment")
db.createCollection("ClientDetails")
db.createCollection("ClientSignup")
db.createCollection("MerkleCommitment")
db.createCollection("MerkleProof")
print(db.getCollectionNames())
Expand All @@ -47,14 +48,16 @@ db.createRole(
{ resource: { db: db_name, collection: "MerkleProof" }, actions: [ "find"] },
{ resource: { db: db_name, collection: "ClientCommitment" }, actions: [ "find", "update", "insert"] },
{ resource: { db: db_name, collection: "ClientDetails" }, actions: [ "find", "update", "insert"] },
{ resource: { db: db_name, collection: "ClientSignup" }, actions: [ "find", "update", "insert"] },

],
roles: []
}
)

// mainstayService role
// This allows writing to all collections except
// ClientCommitment/ClientDetails which only API is allowed to write to
// ClientCommitment/ClientDetails/ClientSignup which only API is allowed to write to
db.createRole(
{
role: "mainstayService",
Expand All @@ -65,6 +68,7 @@ db.createRole(
{ resource: { db: db_name, collection: "MerkleProof" }, actions: ["find", "update", "insert"] },
{ resource: { db: db_name, collection: "ClientCommitment" }, actions: ["find"] },
{ resource: { db: db_name, collection: "ClientDetails" }, actions: ["find"] },
{ resource: { db: db_name, collection: "ClientSignup" }, actions: ["find"] },
],
roles: []
}
Expand Down
28 changes: 28 additions & 0 deletions scripts/db-new-coll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2018 CommerceBlock Team
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.

// MONGO DB ADD COLLECTION script
// Script that adds a new collection to the db
// and modifies privileges for existing roles
//

db = connect(db_user + ":" + db_pass + "@" + db_host + "/admin");

db = db.getSiblingDB(db_name)

db.createCollection("ClientSignup")

db.grantPrivilegesToRole(
"mainstayApi",
[
{ resource: { db: db_name, collection: "ClientSignup" }, actions: [ "find", "update", "insert"] },
],
)

db.grantPrivilegesToRole(
"mainstayService",
[
{ resource: { db: db_name, collection: "ClientSignup" }, actions: [ "find"] },
],
)

0 comments on commit a8d57bb

Please sign in to comment.