|
@@ -166,6 +166,10 @@ func initDBTables() {
|
|
|
if nil != err {
|
|
|
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [spans] failed: %s", err)
|
|
|
}
|
|
|
+ _, err = db.Exec("CREATE INDEX idx_spans_root_id ON spans(root_id)")
|
|
|
+ if nil != err {
|
|
|
+ logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_spans_root_id] failed: %s", err)
|
|
|
+ }
|
|
|
|
|
|
_, err = db.Exec("DROP TABLE IF EXISTS assets")
|
|
|
if nil != err {
|
|
@@ -175,6 +179,10 @@ func initDBTables() {
|
|
|
if nil != err {
|
|
|
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [assets] failed: %s", err)
|
|
|
}
|
|
|
+ _, err = db.Exec("CREATE INDEX idx_assets_root_id ON assets(root_id)")
|
|
|
+ if nil != err {
|
|
|
+ logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_assets_root_id] failed: %s", err)
|
|
|
+ }
|
|
|
|
|
|
_, err = db.Exec("DROP TABLE IF EXISTS attributes")
|
|
|
if nil != err {
|
|
@@ -184,6 +192,10 @@ func initDBTables() {
|
|
|
if nil != err {
|
|
|
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [attributes] failed: %s", err)
|
|
|
}
|
|
|
+ _, err = db.Exec("CREATE INDEX idx_attributes_root_id ON attributes(root_id)")
|
|
|
+ if nil != err {
|
|
|
+ logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_attributes_root_id] failed: %s", err)
|
|
|
+ }
|
|
|
|
|
|
_, err = db.Exec("DROP TABLE IF EXISTS refs")
|
|
|
if nil != err {
|
|
@@ -1008,12 +1020,6 @@ func deleteBlocksByBoxTx(tx *sql.Tx, box string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func deleteSpansByPathTx(tx *sql.Tx, box, path string) (err error) {
|
|
|
- stmt := "DELETE FROM spans WHERE box = ? AND path = ?"
|
|
|
- err = execStmtTx(tx, stmt, box, path)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
func deleteSpansByRootID(tx *sql.Tx, rootID string) (err error) {
|
|
|
stmt := "DELETE FROM spans WHERE root_id =?"
|
|
|
err = execStmtTx(tx, stmt, rootID)
|
|
@@ -1026,28 +1032,23 @@ func deleteSpansByBoxTx(tx *sql.Tx, box string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func deleteAssetsByPathTx(tx *sql.Tx, box, path string) (err error) {
|
|
|
- stmt := "DELETE FROM assets WHERE box = ? AND docpath = ?"
|
|
|
- err = execStmtTx(tx, stmt, box, path)
|
|
|
+func deleteAssetsByRootID(tx *sql.Tx, rootID string) (err error) {
|
|
|
+ stmt := "DELETE FROM assets WHERE root_id = ?"
|
|
|
+ err = execStmtTx(tx, stmt, rootID)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func deleteAttributeByBlockID(tx *sql.Tx, blockID string) (err error) {
|
|
|
- stmt := "DELETE FROM attributes WHERE block_id = ?"
|
|
|
- err = execStmtTx(tx, stmt, blockID)
|
|
|
+func deleteAssetsByBoxTx(tx *sql.Tx, box string) (err error) {
|
|
|
+ stmt := "DELETE FROM assets WHERE box = ?"
|
|
|
+ err = execStmtTx(tx, stmt, box)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func deleteAttributesByPathTx(tx *sql.Tx, box, path string) (err error) {
|
|
|
- stmt := "DELETE FROM attributes WHERE box = ? AND path = ?"
|
|
|
- err = execStmtTx(tx, stmt, box, path)
|
|
|
+func deleteAttributesByRootID(tx *sql.Tx, rootID string) (err error) {
|
|
|
+ stmt := "DELETE FROM attributes WHERE root_id = ?"
|
|
|
+ err = execStmtTx(tx, stmt, rootID)
|
|
|
return
|
|
|
-}
|
|
|
|
|
|
-func deleteAssetsByBoxTx(tx *sql.Tx, box string) (err error) {
|
|
|
- stmt := "DELETE FROM assets WHERE box = ?"
|
|
|
- err = execStmtTx(tx, stmt, box)
|
|
|
- return
|
|
|
}
|
|
|
|
|
|
func deleteAttributesByBoxTx(tx *sql.Tx, box string) (err error) {
|