remove booking-item-legacy-id
This commit is contained in:
parent
489196f18d
commit
d5396b1128
@ -1,96 +0,0 @@
|
||||
--liquibase formatted sql
|
||||
|
||||
-- TODO: These changesets are just for the external remote views to simulate the legacy tables.
|
||||
-- Once we don't need the external remote views anymore, create revert changesets.
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-booking-item-MIGRATION-mapping:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
|
||||
CREATE TABLE hs_booking_item_legacy_id
|
||||
(
|
||||
uuid uuid NOT NULL REFERENCES hs_booking_item(uuid),
|
||||
legacy_id integer NOT NULL
|
||||
);
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-booking-item-MIGRATION-sequence:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
|
||||
CREATE SEQUENCE IF NOT EXISTS hs_booking_item_legacy_id_seq
|
||||
AS integer
|
||||
START 1000000000
|
||||
OWNED BY hs_booking_item_legacy_id.legacy_id;
|
||||
--//
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-booking-item-MIGRATION-default:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
|
||||
ALTER TABLE hs_booking_item_legacy_id
|
||||
ALTER COLUMN legacy_id
|
||||
SET DEFAULT nextVal('hs_booking_item_legacy_id_seq');
|
||||
--/
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-booking-item-MIGRATION-insert:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
|
||||
CALL defineContext('schema-migration');
|
||||
INSERT INTO hs_booking_item_legacy_id(uuid, legacy_id)
|
||||
SELECT uuid, nextVal('hs_booking_item_legacy_id_seq') FROM hs_booking_item;
|
||||
--/
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-booking-item-MIGRATION-insert-trigger:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
create or replace function insertBookingItemLegacyIdMapping()
|
||||
returns trigger
|
||||
language plpgsql
|
||||
strict as $$
|
||||
begin
|
||||
if TG_OP <> 'INSERT' then
|
||||
raise exception 'invalid usage of trigger';
|
||||
end if;
|
||||
|
||||
INSERT INTO hs_booking_item_legacy_id VALUES
|
||||
(NEW.uuid, nextVal('hs_booking_item_legacy_id_seq'));
|
||||
|
||||
return NEW;
|
||||
end; $$;
|
||||
|
||||
create trigger createBookingItemLegacyIdMapping
|
||||
after insert on hs_booking_item
|
||||
for each row
|
||||
execute procedure insertBookingItemLegacyIdMapping();
|
||||
--/
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
--changeset hs-booking-item-MIGRATION-delete-trigger:1 endDelimiter:--//
|
||||
-- ----------------------------------------------------------------------------
|
||||
create or replace function deleteBookingItemLegacyIdMapping_tf()
|
||||
returns trigger
|
||||
language plpgsql
|
||||
strict as $$
|
||||
begin
|
||||
if TG_OP <> 'DELETE' then
|
||||
raise exception 'invalid usage of trigger';
|
||||
end if;
|
||||
|
||||
DELETE FROM hs_booking_item_legacy_id
|
||||
WHERE uuid = OLD.uuid;
|
||||
|
||||
return OLD;
|
||||
end; $$;
|
||||
|
||||
create trigger deleteBookingItemLegacyIdMapping_tg
|
||||
before delete on hs_booking_item
|
||||
for each row
|
||||
execute procedure deleteBookingItemLegacyIdMapping_tf();
|
||||
--/
|
@ -145,8 +145,6 @@ databaseChangeLog:
|
||||
file: db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql
|
||||
- include:
|
||||
file: db/changelog/6-hs-booking/630-booking-item/6203-hs-booking-item-rbac.sql
|
||||
- include:
|
||||
file: db/changelog/6-hs-booking/630-booking-item/6306-hs-booking-item-migration.sql
|
||||
- include:
|
||||
file: db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql
|
||||
- include:
|
||||
|
@ -758,36 +758,9 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context(rbacSuperuser);
|
||||
bookingItems.forEach(this::persistRecursively);
|
||||
updateLegacyIds(contacts, "hs_booking_item_legacy_id", "legacy_id");
|
||||
}).assertSuccessful();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19019)
|
||||
void verifyBookingItemLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchBookingItemLegacyIds()).isEqualTo("""
|
||||
1000000021
|
||||
1000000022
|
||||
1000000023
|
||||
1000000024
|
||||
1000000025
|
||||
1000000026
|
||||
1000000027
|
||||
1000000028
|
||||
1000000029
|
||||
1000000030
|
||||
1000000031
|
||||
1000000032
|
||||
1000000033
|
||||
1000000034
|
||||
1000000035
|
||||
1000000036
|
||||
1000000037
|
||||
1000000038
|
||||
""".trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19120)
|
||||
@Commit
|
||||
@ -967,7 +940,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19930)
|
||||
void verifyCloudServerLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(CLOUD_SERVER)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(CLOUD_SERVER)).isEqualTo("""
|
||||
23611
|
||||
""".trim());
|
||||
assertThat(missingHostingAsstLegacyIds(CLOUD_SERVER)).isEmpty();
|
||||
@ -977,7 +950,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19931)
|
||||
void verifyManagedServerLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(MANAGED_SERVER)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(MANAGED_SERVER)).isEqualTo("""
|
||||
10968
|
||||
10978
|
||||
11061
|
||||
@ -990,7 +963,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19932)
|
||||
void verifyManagedWebspaceLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(MANAGED_WEBSPACE)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(MANAGED_WEBSPACE)).isEqualTo("""
|
||||
10630
|
||||
11094
|
||||
11111
|
||||
@ -1004,7 +977,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19933)
|
||||
void verifyUnixUserLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(UNIX_USER)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(UNIX_USER)).isEqualTo("""
|
||||
5803
|
||||
5805
|
||||
5809
|
||||
@ -1028,7 +1001,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19934)
|
||||
void verifyPgSqlDbLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(PGSQL_DATABASE)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(PGSQL_DATABASE)).isEqualTo("""
|
||||
1077
|
||||
1858
|
||||
1860
|
||||
@ -1045,7 +1018,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19934)
|
||||
void verifyPgSqlUserLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(PGSQL_USER)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(PGSQL_USER)).isEqualTo("""
|
||||
1857
|
||||
1859
|
||||
1860
|
||||
@ -1061,7 +1034,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19935)
|
||||
void verifyMariaDbLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(MARIADB_DATABASE)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(MARIADB_DATABASE)).isEqualTo("""
|
||||
1786
|
||||
1805
|
||||
4908
|
||||
@ -1078,7 +1051,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
@Order(19936)
|
||||
void verifyMariaDbUserLegacyIds() {
|
||||
assumeThatWeAreImportingControlledTestData();
|
||||
assertThat(fetchHosingAsetLegacyIds(MARIADB_USER)).isEqualTo("""
|
||||
assertThat(fetchHosingAssetLegacyIds(MARIADB_USER)).isEqualTo("""
|
||||
1858
|
||||
4908
|
||||
4909
|
||||
@ -1918,17 +1891,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
||||
assumeThat(isImportingControlledTestData()).isTrue();
|
||||
}
|
||||
|
||||
private String fetchBookingItemLegacyIds() {
|
||||
return ((List<List<?>>) em.createNativeQuery(
|
||||
"""
|
||||
SELECT * FROM hs_booking_item_legacy_id
|
||||
WHERE legacy_id IS NOT NULL
|
||||
ORDER BY legacy_id
|
||||
""",
|
||||
List.class).getResultList()).stream().map(row -> row.get(1).toString()).collect(joining("\n"));
|
||||
}
|
||||
|
||||
private String fetchHosingAsetLegacyIds(final HsHostingAssetType type) {
|
||||
private String fetchHosingAssetLegacyIds(final HsHostingAssetType type) {
|
||||
//noinspection unchecked
|
||||
return ((List<List<?>>) em.createNativeQuery(
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user