Skip to content

Commit

Permalink
technical debt
Browse files Browse the repository at this point in the history
  • Loading branch information
e154 committed Nov 1, 2023
1 parent 3934312 commit a6343cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions common/apperr/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ var (
ErrBackupNotFound = ErrorWithCode("BACKUP_NOT_FOUND_ERROR", "backup not found", ErrNotFound)
ErrBackupNameNotUnique = ErrorWithCode("BACKUP_NAME_NOT_UNIQUE", "backup name not unique", ErrInvalidRequest)

ErrScriptVersionAdd = ErrorWithCode("SCRIPTVERSION_DEVICE_ADD_ERROR", "failed to add script version", ErrInternal)
ErrScriptVersionList = ErrorWithCode("SCRIPTVERSION_DEVICE_LIST_ERROR", "failed to list script version", ErrInternal)
ErrScriptVersionDelete = ErrorWithCode("SCRIPTVERSION_DEVICE_DELETE_ERROR", "failed to delete script version", ErrInternal)
ErrScriptVersionAdd = ErrorWithCode("SCRIPT_VERSION_ADD_ERROR", "failed to add script version", ErrInternal)
ErrScriptVersionList = ErrorWithCode("SCRIPT_VERSION_LIST_ERROR", "failed to list script version", ErrInternal)
ErrScriptVersionDelete = ErrorWithCode("SCRIPT_VERSION_DELETE_ERROR", "failed to delete script version", ErrInternal)
)
5 changes: 4 additions & 1 deletion db/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ func (n Scripts) Update(ctx context.Context, script *Script) (err error) {
ScriptId: script.Id,
Sum: []byte(hex.EncodeToString(hash[:])),
}
_ = n.Db.WithContext(ctx).Create(version).Error
if err = n.Db.WithContext(ctx).Create(version).Error; err != nil {
err = errors.Wrap(apperr.ErrScriptVersionAdd, err.Error())
return
}

q := `delete from script_versions
where id not in (
Expand Down
1 change: 1 addition & 0 deletions migrations/20231030_145308_add_script_version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ create table script_versions
on update cascade on delete cascade,
lang scripts_lang default 'javascript'::scripts_lang not null,
source text,
sum bytea,
created_at timestamp with time zone default CURRENT_TIMESTAMP
);

Expand Down

0 comments on commit a6343cc

Please sign in to comment.