endpoint tracking (#10)

This commit is contained in:
Michael Quigley 2022-07-29 15:19:28 -04:00
parent 409fee1576
commit 4b3c22d02a
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 4 additions and 2 deletions

View File

@ -9,14 +9,15 @@ type Service struct {
Model
AccountId int
ZitiId string
Endpoint string
}
func (self *Store) CreateService(accountId int, svc *Service, tx *sqlx.Tx) (int, error) {
stmt, err := tx.Prepare("insert into services (account_id, ziti_id) values (?, ?)")
stmt, err := tx.Prepare("insert into services (account_id, ziti_id, endpoint) values (?, ?, ?)")
if err != nil {
return 0, errors.Wrap(err, "error preparing services insert statement")
}
res, err := stmt.Exec(accountId, svc.ZitiId)
res, err := stmt.Exec(accountId, svc.ZitiId, svc.Endpoint)
if err != nil {
return 0, errors.Wrap(err, "error executing services insert statement")
}

View File

@ -36,6 +36,7 @@ create table services (
id integer primary key,
account_id integer constraint fk_accounts_services references accounts on delete cascade,
ziti_id string not null unique,
endpoint string,
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),