Add a SQL schema and DAO for KmsSecretRevision (#840)

* Add a SQL schema and DAO for KmsSecretRevision

The dual-object nature of KmsSecret and KmsSecretRevision will not be
necessary once we have moved to SQL. In that world, the only object will
be the one now called KmsSecretRevision. KmsSecretRevision already
stores its parent so all we need to do is convert that key to the String
secretName (or from the secretName to the key, if loading from SQL) and
select the max revision ID for a given secret name.

In a future PR, we will add a dual-writing DAO to these objects and
perform the dual writes, similar to how ReservedList functions.

* Regenerate diagram

* Rename revisionId and cryptoKeyVersionName

* Fix SQL files and diagram
This commit is contained in:
gbrodman 2020-10-30 18:45:43 -04:00 committed by GitHub
parent 40eef2a06c
commit d685f7e2df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1229 additions and 763 deletions

View file

@ -452,6 +452,15 @@
primary key (host_repo_id, history_revision_id)
);
create table "KmsSecret" (
revision_id int8 not null,
creation_time timestamptz not null,
encrypted_value text not null,
crypto_key_version_name text not null,
secret_name text not null,
primary key (revision_id)
);
create table "Lock" (
resource_name text not null,
tld text not null,
@ -727,6 +736,7 @@ create index IDX1iy7njgb7wjmj9piml4l2g0qi on "HostHistory" (history_registrar_id
create index IDXkkwbwcwvrdkkqothkiye4jiff on "HostHistory" (host_name);
create index IDXknk8gmj7s47q56cwpa6rmpt5l on "HostHistory" (history_type);
create index IDX67qwkjtlq5q8dv6egtrtnhqi7 on "HostHistory" (history_modification_time);
create index IDXli9nil3s4t4p21i3xluvvilb7 on "KmsSecret" (secret_name);
create index IDXe7wu46c7wpvfmfnj4565abibp on "PollMessage" (registrar_id);
create index IDXaydgox62uno9qx8cjlj5lauye on "PollMessage" (event_time);
create index premiumlist_name_idx on "PremiumList" (name);