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
|
file: db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql
|
||||||
- include:
|
- include:
|
||||||
file: db/changelog/6-hs-booking/630-booking-item/6203-hs-booking-item-rbac.sql
|
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:
|
- include:
|
||||||
file: db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql
|
file: db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql
|
||||||
- include:
|
- include:
|
||||||
|
@ -758,36 +758,9 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
jpaAttempt.transacted(() -> {
|
jpaAttempt.transacted(() -> {
|
||||||
context(rbacSuperuser);
|
context(rbacSuperuser);
|
||||||
bookingItems.forEach(this::persistRecursively);
|
bookingItems.forEach(this::persistRecursively);
|
||||||
updateLegacyIds(contacts, "hs_booking_item_legacy_id", "legacy_id");
|
|
||||||
}).assertSuccessful();
|
}).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
|
@Test
|
||||||
@Order(19120)
|
@Order(19120)
|
||||||
@Commit
|
@Commit
|
||||||
@ -967,7 +940,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19930)
|
@Order(19930)
|
||||||
void verifyCloudServerLegacyIds() {
|
void verifyCloudServerLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(CLOUD_SERVER)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(CLOUD_SERVER)).isEqualTo("""
|
||||||
23611
|
23611
|
||||||
""".trim());
|
""".trim());
|
||||||
assertThat(missingHostingAsstLegacyIds(CLOUD_SERVER)).isEmpty();
|
assertThat(missingHostingAsstLegacyIds(CLOUD_SERVER)).isEmpty();
|
||||||
@ -977,7 +950,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19931)
|
@Order(19931)
|
||||||
void verifyManagedServerLegacyIds() {
|
void verifyManagedServerLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(MANAGED_SERVER)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(MANAGED_SERVER)).isEqualTo("""
|
||||||
10968
|
10968
|
||||||
10978
|
10978
|
||||||
11061
|
11061
|
||||||
@ -990,7 +963,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19932)
|
@Order(19932)
|
||||||
void verifyManagedWebspaceLegacyIds() {
|
void verifyManagedWebspaceLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(MANAGED_WEBSPACE)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(MANAGED_WEBSPACE)).isEqualTo("""
|
||||||
10630
|
10630
|
||||||
11094
|
11094
|
||||||
11111
|
11111
|
||||||
@ -1004,7 +977,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19933)
|
@Order(19933)
|
||||||
void verifyUnixUserLegacyIds() {
|
void verifyUnixUserLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(UNIX_USER)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(UNIX_USER)).isEqualTo("""
|
||||||
5803
|
5803
|
||||||
5805
|
5805
|
||||||
5809
|
5809
|
||||||
@ -1028,7 +1001,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19934)
|
@Order(19934)
|
||||||
void verifyPgSqlDbLegacyIds() {
|
void verifyPgSqlDbLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(PGSQL_DATABASE)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(PGSQL_DATABASE)).isEqualTo("""
|
||||||
1077
|
1077
|
||||||
1858
|
1858
|
||||||
1860
|
1860
|
||||||
@ -1045,7 +1018,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19934)
|
@Order(19934)
|
||||||
void verifyPgSqlUserLegacyIds() {
|
void verifyPgSqlUserLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(PGSQL_USER)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(PGSQL_USER)).isEqualTo("""
|
||||||
1857
|
1857
|
||||||
1859
|
1859
|
||||||
1860
|
1860
|
||||||
@ -1061,7 +1034,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19935)
|
@Order(19935)
|
||||||
void verifyMariaDbLegacyIds() {
|
void verifyMariaDbLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(MARIADB_DATABASE)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(MARIADB_DATABASE)).isEqualTo("""
|
||||||
1786
|
1786
|
||||||
1805
|
1805
|
||||||
4908
|
4908
|
||||||
@ -1078,7 +1051,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
@Order(19936)
|
@Order(19936)
|
||||||
void verifyMariaDbUserLegacyIds() {
|
void verifyMariaDbUserLegacyIds() {
|
||||||
assumeThatWeAreImportingControlledTestData();
|
assumeThatWeAreImportingControlledTestData();
|
||||||
assertThat(fetchHosingAsetLegacyIds(MARIADB_USER)).isEqualTo("""
|
assertThat(fetchHosingAssetLegacyIds(MARIADB_USER)).isEqualTo("""
|
||||||
1858
|
1858
|
||||||
4908
|
4908
|
||||||
4909
|
4909
|
||||||
@ -1918,17 +1891,7 @@ public class ImportHostingAssets extends BaseOfficeDataImport {
|
|||||||
assumeThat(isImportingControlledTestData()).isTrue();
|
assumeThat(isImportingControlledTestData()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fetchBookingItemLegacyIds() {
|
private String fetchHosingAssetLegacyIds(final HsHostingAssetType type) {
|
||||||
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) {
|
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return ((List<List<?>>) em.createNativeQuery(
|
return ((List<List<?>>) em.createNativeQuery(
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user