Changeset 497 in code for trunk/db.go
- Timestamp:
- Apr 13, 2021, 4:15:30 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/db.go
r489 r497 110 110 111 111 type Channel struct { 112 ID int64 113 Name string 114 Key string 115 Detached bool 112 ID int64 113 Name string 114 Key string 115 116 Detached bool 117 DetachedInternalMsgID string 116 118 117 119 RelayDetached MessageFilter … … 162 164 key VARCHAR(255), 163 165 detached INTEGER NOT NULL DEFAULT 0, 166 detached_internal_msgid VARCHAR(255), 164 167 relay_detached INTEGER NOT NULL DEFAULT 0, 165 168 reattach_on INTEGER NOT NULL DEFAULT 0, … … 246 249 ); 247 250 `, 251 "ALTER TABLE Channel ADD COLUMN detached_internal_msgid VARCHAR(255)", 248 252 } 249 253 … … 547 551 defer db.lock.RUnlock() 548 552 549 rows, err := db.db.Query(`SELECT id, name, key, detached, relay_detached, reattach_on, detach_after, detach_on 553 rows, err := db.db.Query(`SELECT 554 id, name, key, detached, detached_internal_msgid, 555 relay_detached, reattach_on, detach_after, detach_on 550 556 FROM Channel 551 557 WHERE network = ?`, networkID) … … 558 564 for rows.Next() { 559 565 var ch Channel 560 var key sql.NullString566 var key, detachedInternalMsgID sql.NullString 561 567 var detachAfter int64 562 if err := rows.Scan(&ch.ID, &ch.Name, &key, &ch.Detached, & ch.RelayDetached, &ch.ReattachOn, &detachAfter, &ch.DetachOn); err != nil {568 if err := rows.Scan(&ch.ID, &ch.Name, &key, &ch.Detached, &detachedInternalMsgID, &ch.RelayDetached, &ch.ReattachOn, &detachAfter, &ch.DetachOn); err != nil { 563 569 return nil, err 564 570 } 565 571 ch.Key = key.String 572 ch.DetachedInternalMsgID = detachedInternalMsgID.String 566 573 ch.DetachAfter = time.Duration(detachAfter) * time.Second 567 574 channels = append(channels, ch) … … 584 591 if ch.ID != 0 { 585 592 _, err = db.db.Exec(`UPDATE Channel 586 SET network = ?, name = ?, key = ?, detached = ?, relay_detached = ?, reattach_on = ?, detach_after = ?, detach_on = ?593 SET network = ?, name = ?, key = ?, detached = ?, detached_internal_msgid = ?, relay_detached = ?, reattach_on = ?, detach_after = ?, detach_on = ? 587 594 WHERE id = ?`, 588 networkID, ch.Name, key, ch.Detached, ch.RelayDetached, ch.ReattachOn, detachAfter, ch.DetachOn, ch.ID)595 networkID, ch.Name, key, ch.Detached, toNullString(ch.DetachedInternalMsgID), ch.RelayDetached, ch.ReattachOn, detachAfter, ch.DetachOn, ch.ID) 589 596 } else { 590 597 var res sql.Result 591 res, err = db.db.Exec(`INSERT INTO Channel(network, name, key, detached, relay_detached, reattach_on, detach_after, detach_on)598 res, err = db.db.Exec(`INSERT INTO Channel(network, name, key, detached, detached_internal_msgid, relay_detached, reattach_on, detach_after, detach_on) 592 599 VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, 593 networkID, ch.Name, key, ch.Detached, ch.RelayDetached, ch.ReattachOn, detachAfter, ch.DetachOn)600 networkID, ch.Name, key, ch.Detached, toNullString(ch.DetachedInternalMsgID), ch.RelayDetached, ch.ReattachOn, detachAfter, ch.DetachOn) 594 601 if err != nil { 595 602 return err
Note:
See TracChangeset
for help on using the changeset viewer.