Use LastUpdate to also keep track of the creation date

This would allow a cleanup process to remove forgotten / unused accounts based on LastUpdate field
This commit is contained in:
Damien Degois 2022-11-02 13:11:21 +01:00
parent 6ba9360156
commit 7d0d2dd4dc

4
db.go
View File

@ -164,7 +164,9 @@ func (d *acmedb) handleDBUpgradeTo1() error {
// Create two rows for subdomain to the txt table
func (d *acmedb) NewTXTValuesInTransaction(tx *sql.Tx, subdomain string) error {
var err error
instr := fmt.Sprintf("INSERT INTO txt (Subdomain, LastUpdate) values('%s', 0)", subdomain)
// Set initial LastUpdate to (now-1) to avoid race condition during test while preserving a hint of the creation date
initialLastUpdate := time.Now().Unix() - 1
instr := fmt.Sprintf("INSERT INTO txt (Subdomain, LastUpdate) values('%s', %d)", subdomain, initialLastUpdate)
_, _ = tx.Exec(instr)
_, _ = tx.Exec(instr)
return err