Add a SQL schema to AllocationToken (#763)

* Add a SQL schema to AllocationToken

* Respond to CR

- rename field in tests
- rename allowed_registrar_ids field
- remove unnecessary db load in GATC

* Add TODO for HistoryEntry vkeys

* Run autoformat

* V48 -> V49
This commit is contained in:
gbrodman 2020-08-20 20:18:34 -04:00 committed by GitHub
parent 8ac30a42ed
commit 876d65e232
23 changed files with 352 additions and 45 deletions

View file

@ -0,0 +1,31 @@
-- 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 "AllocationToken" (
token text NOT NULL,
update_timestamp timestamptz,
allowed_registrar_ids text[],
allowed_tlds text[],
creation_time timestamptz NOT NULL,
discount_fraction float8 NOT NULL,
discount_premiums boolean NOT NULL,
discount_years int4 NOT NULL,
domain_name text,
redemption_history_entry text,
token_status_transitions hstore,
token_type text,
PRIMARY KEY (token)
);
CREATE INDEX allocation_token_domain_name_idx ON "AllocationToken" (domain_name);

View file

@ -13,6 +13,22 @@
-- limitations under the License.
create sequence history_id_sequence start 1 increment 1;
create table "AllocationToken" (
token text not null,
update_timestamp timestamptz,
allowed_registrar_ids text[],
allowed_tlds text[],
creation_time timestamptz not null,
discount_fraction float8 not null,
discount_premiums boolean not null,
discount_years int4 not null,
domain_name text,
redemption_history_entry text,
token_status_transitions hstore,
token_type text,
primary key (token)
);
create table "BillingCancellation" (
billing_cancellation_id bigserial not null,
registrar_id text not null,
@ -567,6 +583,7 @@ create sequence history_id_sequence start 1 increment 1;
contents bytea,
primary key (id)
);
create index allocation_token_domain_name_idx on "AllocationToken" (domain_name);
create index IDXih4b2tea127p5rb61gje6e1y2 on "BillingCancellation" (registrar_id);
create index IDX2exdfbx6oiiwnhr8j6gjpqt2j on "BillingCancellation" (event_time);
create index IDXqa3g92jc17e8dtiaviy4fet4x on "BillingCancellation" (billing_time);

View file

@ -34,6 +34,26 @@ SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: AllocationToken; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public."AllocationToken" (
token text NOT NULL,
update_timestamp timestamp with time zone,
allowed_registrar_ids text[],
allowed_tlds text[],
creation_time timestamp with time zone NOT NULL,
discount_fraction double precision NOT NULL,
discount_premiums boolean NOT NULL,
discount_years integer NOT NULL,
domain_name text,
redemption_history_entry text,
token_status_transitions public.hstore,
token_type text
);
--
-- Name: BillingCancellation; Type: TABLE; Schema: public; Owner: -
--
@ -985,6 +1005,14 @@ ALTER TABLE ONLY public."Spec11ThreatMatch" ALTER COLUMN id SET DEFAULT nextval(
ALTER TABLE ONLY public."Transaction" ALTER COLUMN id SET DEFAULT nextval('public."Transaction_id_seq"'::regclass);
--
-- Name: AllocationToken AllocationToken_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."AllocationToken"
ADD CONSTRAINT "AllocationToken_pkey" PRIMARY KEY (token);
--
-- Name: BillingCancellation BillingCancellation_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -1185,6 +1213,13 @@ ALTER TABLE ONLY public."RegistryLock"
ADD CONSTRAINT idx_registry_lock_repo_id_revision_id UNIQUE (repo_id, revision_id);
--
-- Name: allocation_token_domain_name_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX allocation_token_domain_name_idx ON public."AllocationToken" USING btree (domain_name);
--
-- Name: idx1iy7njgb7wjmj9piml4l2g0qi; Type: INDEX; Schema: public; Owner: -
--