mirror of
https://github.com/google/nomulus.git
synced 2025-05-24 21:20:08 +02:00
Disable auto-generation on id for HostHistory and ContactHistory (#827)
This commit is contained in:
parent
d052da4864
commit
035431c90d
10 changed files with 18 additions and 42 deletions
|
@ -31,8 +31,6 @@ import javax.persistence.Access;
|
||||||
import javax.persistence.AccessType;
|
import javax.persistence.AccessType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.IdClass;
|
import javax.persistence.IdClass;
|
||||||
import javax.persistence.PostLoad;
|
import javax.persistence.PostLoad;
|
||||||
|
@ -63,7 +61,6 @@ public class ContactHistory extends HistoryEntry implements SqlEntity {
|
||||||
@Id String contactRepoId;
|
@Id String contactRepoId;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TempHistorySequenceGenerator")
|
|
||||||
@Column(name = "historyRevisionId")
|
@Column(name = "historyRevisionId")
|
||||||
@Access(AccessType.PROPERTY)
|
@Access(AccessType.PROPERTY)
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,8 +32,6 @@ import javax.persistence.Access;
|
||||||
import javax.persistence.AccessType;
|
import javax.persistence.AccessType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.IdClass;
|
import javax.persistence.IdClass;
|
||||||
import javax.persistence.PostLoad;
|
import javax.persistence.PostLoad;
|
||||||
|
@ -65,7 +63,6 @@ public class HostHistory extends HistoryEntry implements SqlEntity {
|
||||||
@Id String hostRepoId;
|
@Id String hostRepoId;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TempHistorySequenceGenerator")
|
|
||||||
@Column(name = "historyRevisionId")
|
@Column(name = "historyRevisionId")
|
||||||
@Access(AccessType.PROPERTY)
|
@Access(AccessType.PROPERTY)
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</embeddable>
|
</embeddable>
|
||||||
|
|
||||||
<sequence-generator name="HistorySequenceGenerator" sequence-name="history_id_sequence"/>
|
|
||||||
|
|
||||||
<!-- TODO(shicong): Drop this sequence and change all history tables to use the above one. -->
|
|
||||||
<sequence-generator name="TempHistorySequenceGenerator" sequence-name="temp_history_id_sequence"/>
|
|
||||||
|
|
||||||
<persistence-unit-metadata>
|
<persistence-unit-metadata>
|
||||||
<persistence-unit-defaults>
|
<persistence-unit-defaults>
|
||||||
<entity-listeners>
|
<entity-listeners>
|
||||||
|
|
|
@ -48,7 +48,6 @@ public class ContactHistoryTest extends EntityTestCase {
|
||||||
VKey<ContactResource> contactVKey = contact.createVKey();
|
VKey<ContactResource> contactVKey = contact.createVKey();
|
||||||
ContactResource contactFromDb = jpaTm().transact(() -> jpaTm().load(contactVKey));
|
ContactResource contactFromDb = jpaTm().transact(() -> jpaTm().load(contactVKey));
|
||||||
ContactHistory contactHistory = createContactHistory(contactFromDb, contact.getRepoId());
|
ContactHistory contactHistory = createContactHistory(contactFromDb, contact.getRepoId());
|
||||||
contactHistory.id = null;
|
|
||||||
jpaTm().transact(() -> jpaTm().insert(contactHistory));
|
jpaTm().transact(() -> jpaTm().insert(contactHistory));
|
||||||
jpaTm()
|
jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
|
@ -73,7 +72,6 @@ public class ContactHistoryTest extends EntityTestCase {
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setContactBase(null)
|
.setContactBase(null)
|
||||||
.build();
|
.build();
|
||||||
contactHistory.id = null;
|
|
||||||
jpaTm().transact(() -> jpaTm().insert(contactHistory));
|
jpaTm().transact(() -> jpaTm().insert(contactHistory));
|
||||||
|
|
||||||
jpaTm()
|
jpaTm()
|
||||||
|
|
|
@ -49,7 +49,6 @@ public class HostHistoryTest extends EntityTestCase {
|
||||||
VKey.create(HostResource.class, "host1", Key.create(HostResource.class, "host1"));
|
VKey.create(HostResource.class, "host1", Key.create(HostResource.class, "host1"));
|
||||||
HostResource hostFromDb = jpaTm().transact(() -> jpaTm().load(hostVKey));
|
HostResource hostFromDb = jpaTm().transact(() -> jpaTm().load(hostVKey));
|
||||||
HostHistory hostHistory = createHostHistory(hostFromDb, host.getRepoId());
|
HostHistory hostHistory = createHostHistory(hostFromDb, host.getRepoId());
|
||||||
hostHistory.id = null;
|
|
||||||
jpaTm().transact(() -> jpaTm().insert(hostHistory));
|
jpaTm().transact(() -> jpaTm().insert(hostHistory));
|
||||||
jpaTm()
|
jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
|
@ -70,7 +69,6 @@ public class HostHistoryTest extends EntityTestCase {
|
||||||
HostResource hostFromDb = jpaTm().transact(() -> jpaTm().load(host.createVKey()));
|
HostResource hostFromDb = jpaTm().transact(() -> jpaTm().load(host.createVKey()));
|
||||||
HostHistory hostHistory =
|
HostHistory hostHistory =
|
||||||
createHostHistory(hostFromDb, host.getRepoId()).asBuilder().setHostBase(null).build();
|
createHostHistory(hostFromDb, host.getRepoId()).asBuilder().setHostBase(null).build();
|
||||||
hostHistory.id = null;
|
|
||||||
jpaTm().transact(() -> jpaTm().insert(hostHistory));
|
jpaTm().transact(() -> jpaTm().insert(hostHistory));
|
||||||
|
|
||||||
jpaTm()
|
jpaTm()
|
||||||
|
|
|
@ -80,7 +80,6 @@ public class LegacyHistoryObjectTest extends EntityTestCase {
|
||||||
ContactHistory legacyContactHistory = (ContactHistory) fromObjectify;
|
ContactHistory legacyContactHistory = (ContactHistory) fromObjectify;
|
||||||
|
|
||||||
// Next, save that from-Datastore object in SQL and verify we can load it back in
|
// Next, save that from-Datastore object in SQL and verify we can load it back in
|
||||||
legacyContactHistory.id = null;
|
|
||||||
jpaTm()
|
jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
() -> {
|
() -> {
|
||||||
|
@ -160,7 +159,6 @@ public class LegacyHistoryObjectTest extends EntityTestCase {
|
||||||
HostHistory legacyHostHistory = (HostHistory) fromObjectify;
|
HostHistory legacyHostHistory = (HostHistory) fromObjectify;
|
||||||
|
|
||||||
// Next, save that from-Datastore object in SQL and verify we can load it back in
|
// Next, save that from-Datastore object in SQL and verify we can load it back in
|
||||||
legacyHostHistory.id = null;
|
|
||||||
jpaTm()
|
jpaTm()
|
||||||
.transact(
|
.transact(
|
||||||
() -> {
|
() -> {
|
||||||
|
|
|
@ -59,3 +59,4 @@ V58__drop_default_value_and_sequences_for_billing_event.sql
|
||||||
V59__use_composite_primary_key_for_contact_and_host_history_table.sql
|
V59__use_composite_primary_key_for_contact_and_host_history_table.sql
|
||||||
V60__remove_pollmessage_sequence.sql
|
V60__remove_pollmessage_sequence.sql
|
||||||
V61__domain_hist_columns.sql
|
V61__domain_hist_columns.sql
|
||||||
|
V62__disable_key_auto_generation_for_history_tables.sql
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
-- 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.
|
||||||
|
|
||||||
|
drop sequence "history_id_sequence";
|
||||||
|
|
||||||
|
drop sequence "temp_history_id_sequence";
|
|
@ -11,7 +11,6 @@
|
||||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
create sequence temp_history_id_sequence start 1 increment 50;
|
|
||||||
|
|
||||||
create table "AllocationToken" (
|
create table "AllocationToken" (
|
||||||
token text not null,
|
token text not null,
|
||||||
|
|
|
@ -931,30 +931,6 @@ CREATE SEQUENCE public."Transaction_id_seq"
|
||||||
ALTER SEQUENCE public."Transaction_id_seq" OWNED BY public."Transaction".id;
|
ALTER SEQUENCE public."Transaction_id_seq" OWNED BY public."Transaction".id;
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: history_id_sequence; Type: SEQUENCE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE SEQUENCE public.history_id_sequence
|
|
||||||
START WITH 1
|
|
||||||
INCREMENT BY 50
|
|
||||||
NO MINVALUE
|
|
||||||
NO MAXVALUE
|
|
||||||
CACHE 1;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: temp_history_id_sequence; Type: SEQUENCE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE SEQUENCE public.temp_history_id_sequence
|
|
||||||
START WITH 1
|
|
||||||
INCREMENT BY 50
|
|
||||||
NO MINVALUE
|
|
||||||
NO MAXVALUE
|
|
||||||
CACHE 1;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: ClaimsList revision_id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: ClaimsList revision_id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue