Create a Java entity to store ThreatMatch objects in SQL (#617)

* Squash everything together
Create SafeBrowsing_Threats table

Create LocalDateConverter and add indexes to SafeBrowsingThreats

Add indexes to SafeBrowsingThreats and make small style changes

Pass in DateTimeFormatter

Delete LocalDateConverterTest.java

Rebase

Make changes to ThreatType comments

Create LocalDateConverterTest

Add review changes

Add SafeBrowsingThreatTest

Rename repoId, refactor LocalDateConverterTest/SafeBrowsingThreatTest, add foreign keys

Change imports

Add foreign keys and rename version number

Add new generated db-schema file

Clean up null test cases

Add changes

Add foreign keys into SafeBrowsingThreatTeat and apply style checks

Add SafeBrowsingThreatTest into SqlIntegrationTestSuite and change golden file

Make small changes to SafeBrowsingThreatTest

Add tests for ForeignKeyViolations and remove setId in SafeBrowsingThreat

* Change V35 -> V36

* Add a foreign key test for a reference to Registrar

* Move some variables around
This commit is contained in:
Legina Chen
2020-06-22 12:07:59 -07:00
committed by GitHub
parent 2c243a7d5f
commit ec09226baa
10 changed files with 588 additions and 2 deletions
@@ -0,0 +1,38 @@
-- Copyright 2020 The Nomulus Authors. All Rights Reserved.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
create table "SafeBrowsingThreat" (
id bigserial not null,
check_date text not null,
domain_name text not null,
domain_repo_id text not null,
registrar_id text not null,
threat_type text not null,
tld text not null,
primary key (id)
);
create index safebrowsing_threat_registrar_id_idx on "SafeBrowsingThreat" (registrar_id);
create index safebrowsing_threat_tld_idx on "SafeBrowsingThreat" (tld);
create index safebrowsing_threat_check_date_idx on "SafeBrowsingThreat" (check_date);
alter table if exists "SafeBrowsingThreat"
add constraint fk_safebrowsing_threat_registrar_id
foreign key (registrar_id)
references "Registrar";
alter table if exists "SafeBrowsingThreat"
add constraint fk_safebrowsing_threat_domain_repo_id
foreign key (domain_repo_id)
references "Domain";