-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial migration and dbmodels for sanction checks.
- Loading branch information
Antoine Popineau
committed
Jan 16, 2025
1 parent
9f2e035
commit 47e746b
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dbmodels | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/checkmarble/marble-backend/utils" | ||
) | ||
|
||
const TABLE_SANCTION_CHECKS = "sanction_checks" | ||
|
||
var SelectSanctionChecksColumn = utils.ColumnList[DBSanctionCheck]() | ||
|
||
type DBSanctionCheck struct { | ||
Id string `db:"id"` | ||
DecisionId string `db:"decision_id"` | ||
Status string `db:"status"` | ||
SearchInput []byte `db:"search_input"` | ||
SearchDatasets []string `db:"search_datasets"` | ||
SearchThreshold float64 `db:"search_threshold"` | ||
IsManual bool `db:"is_manual"` | ||
RequestedBy string `db:"requested_by"` | ||
IsArchived bool `db:"is_archived"` | ||
CreatedAt time.Time `db:"created_at"` | ||
UpdatedAt time.Time `db:"updated_at"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dbmodels | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/checkmarble/marble-backend/utils" | ||
) | ||
|
||
const TABLE_SANCTION_CHECK_MATCHES = "sanction_check_matches" | ||
|
||
var SelectSanctionCheckMatchesColumn = utils.ColumnList[DBSanctionCheckMatch]() | ||
|
||
type DBSanctionCheckMatch struct { | ||
Id string `db:"id"` | ||
SanctionCheckId string `db:"sanction_check_id"` | ||
OpenSanctionEntityId string `db:"opensanction_entity_id"` | ||
Status string `db:"status"` | ||
QueryIds []string `db:"query_ids"` | ||
Payload []byte `db:"payload"` | ||
ReviewedBy string `db:"reviewed_by"` | ||
CreatedAt time.Time `db:"created_at"` | ||
UpdatedAt time.Time `db:"updated_at"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package dbmodels | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/checkmarble/marble-backend/utils" | ||
) | ||
|
||
const TABLE_SANCTION_CHECK_MATCH_COMMENTS = "sanction_check_match_comments" | ||
|
||
var SelectSanctionCheckMatchCommentsColumn = utils.ColumnList[DBSanctionCheckMatchComment]() | ||
|
||
type DBSanctionCheckMatchComment struct { | ||
Id string `db:"id"` | ||
SanctionCheckMatchId string `db:"sanction_check_match_id"` | ||
CommentedBy string `db:"commented_by"` | ||
Comment string `db:"comment"` | ||
CreatedAt time.Time `db:"created_at"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
|
||
create table sanction_checks ( | ||
id uuid default uuid_generate_v4(), | ||
decision_id uuid not null, | ||
|
||
status text check (status in ('confirmed_hit', 'in_review', 'error')), | ||
search_input jsonb, | ||
search_datasets text[], | ||
search_threshold float, | ||
is_manual bool default false, | ||
requested_by uuid null, | ||
|
||
is_archived bool default false, | ||
created_at timestamp with time zone default now(), | ||
updated_at timestamp with time zone default now(), | ||
|
||
primary key (id), | ||
constraint fk_decision | ||
foreign key (decision_id) | ||
references decisions (id), | ||
constraint fk_user | ||
foreign key (requested_by) | ||
references users (id) | ||
); | ||
|
||
create index idx_sanction_checks_decision_id on sanction_checks (decision_id); | ||
|
||
create table sanction_check_matches ( | ||
id uuid default uuid_generate_v4(), | ||
sanction_check_id uuid not null, | ||
|
||
opensanction_entity_id text not null, | ||
status text check (status in ('pending', 'confirmed_hit', 'no_hit')), | ||
query_ids text[], | ||
payload jsonb, | ||
reviewed_by uuid, | ||
|
||
created_at timestamp with time zone default now(), | ||
updated_at timestamp with time zone default now(), | ||
|
||
primary key (id), | ||
constraint fk_sanction_check | ||
foreign key (sanction_check_id) | ||
references sanction_checks (id), | ||
constraint fk_user | ||
foreign key (reviewed_by) | ||
references users (id) | ||
); | ||
|
||
create index idx_sanction_check_matches_sanction_check_id on sanction_check_matches (sanction_check_id); | ||
|
||
create table sanction_check_match_comments ( | ||
id uuid default uuid_generate_v4(), | ||
sanction_check_match_id uuid not null, | ||
|
||
commented_by uuid not null, | ||
comment text, | ||
|
||
created_at timestamp with time zone default now(), | ||
|
||
primary key (id), | ||
constraint fk_sanction_check_match | ||
foreign key (sanction_check_match_id) | ||
references sanction_check_matches (id), | ||
constraint fk_user | ||
foreign key (commented_by) | ||
references users (id) | ||
); | ||
|
||
create index idx_sanction_check_match_comments_sanction_check_match_id on sanction_check_match_comments (sanction_check_match_id); | ||
|
||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
|
||
drop table sanction_checks; | ||
drop table sanction_check_matches; | ||
drop table sanction_check_match_comments; | ||
|
||
-- +goose StatementEnd |