MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / initProjectDB

Function initProjectDB

cmd/cql-proxy/api/project.go:1230–1262  ·  view source on GitHub ↗
(dbID proto.DatabaseID, key *asymmetric.PrivateKey)

Source from the content-addressed store, hash-verified

1228}
1229
1230func initProjectDB(dbID proto.DatabaseID, key *asymmetric.PrivateKey) (db *gorp.DbMap, err error) {
1231 nodeID, err := getDatabaseLeaderNodeID(dbID)
1232 if err != nil {
1233 err = errors.Wrapf(err, "could not get project leader node")
1234 return
1235 }
1236
1237 db = storage.NewImpersonatedDB(
1238 conf.GConf.ThisNodeID,
1239 getNodePCaller(nodeID),
1240 dbID,
1241 key,
1242 )
1243
1244 tblUser := db.AddTableWithName(model.ProjectUser{}, metaTableUserInfo).
1245 SetKeys(true, "ID")
1246 tblUser.AddIndex("____idx_user_1", "", []string{"provider", "email"}).SetUnique(true)
1247 tblConfig := db.AddTableWithName(model.ProjectConfig{}, metaTableProjectConfig).
1248 SetKeys(true, "ID")
1249 tblConfig.AddIndex("____idx_config_1", "", []string{"type", "key"}).SetUnique(true)
1250 db.AddTableWithName(model.Session{}, metaTableSession).SetKeys(false, "ID")
1251
1252 err = db.CreateTablesIfNotExists()
1253
1254 // ignore index error
1255 _ = db.CreateIndex()
1256
1257 if log.GetLevel() == log.DebugLevel {
1258 db.TraceOn(string(dbID), log.StandardLogger())
1259 }
1260
1261 return
1262}
1263
1264func getProjectDB(c *gin.Context, dbID proto.DatabaseID) (project *model.Project, db *gorp.DbMap, err error) {
1265 developer := getDeveloperID(c)

Callers 3

getCurrentProjectDBFunction · 0.85
CreateProjectTaskFunction · 0.85
getProjectDBFunction · 0.85

Calls 5

NewImpersonatedDBFunction · 0.92
GetLevelFunction · 0.92
StandardLoggerFunction · 0.92
getDatabaseLeaderNodeIDFunction · 0.85
getNodePCallerFunction · 0.85

Tested by

no test coverage detected