feat(store): tasks, accounts, runs, dedup journal

This commit is contained in:
2026-07-01 16:58:33 +07:00
parent 0cf9de38c4
commit 67a2367baa
5 changed files with 218 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package store
import (
"context"
"errors"
"github.com/jackc/pgx/v5"
)
func (s *Store) IsMigrated(ctx context.Context, accountID int64, key string) (bool, error) {
var one int
err := s.Pool.QueryRow(ctx,
`SELECT 1 FROM migrated_messages WHERE account_id=$1 AND message_key=$2`,
accountID, key).Scan(&one)
if errors.Is(err, pgx.ErrNoRows) {
return false, nil
}
if err != nil {
return false, err
}
return true, nil
}
func (s *Store) MarkMigrated(ctx context.Context, accountID int64, folder, key string) error {
_, err := s.Pool.Exec(ctx,
`INSERT INTO migrated_messages (account_id, folder, message_key)
VALUES ($1,$2,$3) ON CONFLICT (account_id, message_key) DO NOTHING`,
accountID, folder, key)
return err
}