chore(tfstated): change database account id format to uuidv7
This commit is contained in:
parent
6763596582
commit
15e0a12f61
6 changed files with 10 additions and 7 deletions
|
@ -115,7 +115,7 @@ func (db *DB) LoadAccountUsernames() (map[string]string, error) {
|
|||
return accounts, nil
|
||||
}
|
||||
|
||||
func (db *DB) LoadAccountById(id string) (*model.Account, error) {
|
||||
func (db *DB) LoadAccountById(id uuid.UUID) (*model.Account, error) {
|
||||
account := model.Account{
|
||||
Id: id,
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"go.n16f.net/uuid"
|
||||
)
|
||||
|
||||
func (db *DB) CreateState(path string, accountId string, data []byte) (*model.Version, error) {
|
||||
func (db *DB) CreateState(path string, accountId uuid.UUID, data []byte) (*model.Version, error) {
|
||||
encryptedData, err := db.dataEncryptionKey.EncryptAES256(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to encrypt state data: %w", err)
|
||||
|
@ -142,7 +142,7 @@ func (db *DB) LoadStates() ([]model.State, error) {
|
|||
}
|
||||
|
||||
// returns true in case of lock mismatch
|
||||
func (db *DB) SetState(path string, accountId string, data []byte, lock string) (bool, error) {
|
||||
func (db *DB) SetState(path string, accountId uuid.UUID, data []byte, lock string) (bool, error) {
|
||||
encryptedData, err := db.dataEncryptionKey.EncryptAES256(data)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to encrypt state data: %w", err)
|
||||
|
|
|
@ -6,12 +6,13 @@ import (
|
|||
"time"
|
||||
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/helpers"
|
||||
"go.n16f.net/uuid"
|
||||
)
|
||||
|
||||
type AccountContextKey struct{}
|
||||
|
||||
type Account struct {
|
||||
Id string
|
||||
Id uuid.UUID
|
||||
Username string
|
||||
Salt []byte
|
||||
PasswordHash []byte
|
||||
|
|
|
@ -2,13 +2,15 @@ package model
|
|||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.n16f.net/uuid"
|
||||
)
|
||||
|
||||
type SessionContextKey struct{}
|
||||
|
||||
type Session struct {
|
||||
Id string
|
||||
AccountId string
|
||||
AccountId uuid.UUID
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
Data any
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type Version struct {
|
||||
AccountId string
|
||||
AccountId uuid.UUID
|
||||
Created time.Time
|
||||
Data json.RawMessage
|
||||
Id uuid.UUID
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<tbody>
|
||||
{{ range .Versions }}
|
||||
<tr>
|
||||
<td><a href="/versions/{{ .Id }}">{{ index $.Usernames .AccountId }}</a></td>
|
||||
<td><a href="/versions/{{ .Id }}">{{ index $.Usernames .AccountId.String }}</a></td>
|
||||
<td><a href="/versions/{{ .Id }}">{{ .Created }}</a></td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
|
Loading…
Add table
Reference in a new issue