Skip to content

Commit f888def

Browse files
committed
chore(migrate): align naming and types as well as references
Adjusted existing migration scripts to reference which migration any of the workarounds for missing tables and indices mitigate. Ensured compatibility and alignment with names that would be autogenerated by EclipseLink for better consistency and maintainability.
1 parent 6f49209 commit f888def

8 files changed

Lines changed: 54 additions & 58 deletions

modules/dataverse-migrate-db/extra-migrations/V5.1.1.0__prepare-table-exttooltype.sql

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,9 @@
22

33
CREATE TABLE IF NOT EXISTS externaltooltype
44
(
5-
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
6-
type VARCHAR(255) NOT NULL,
7-
externalTool_id BIGINT NOT NULL,
8-
CONSTRAINT pk_externaltooltype PRIMARY KEY (id)
5+
id SERIAL PRIMARY KEY,
6+
type VARCHAR(255) NOT NULL,
7+
externalTool_id BIGINT NOT NULL CONSTRAINT fk_externaltooltype_externaltool_id REFERENCES externaltool (id)
98
);
109

11-
ALTER TABLE externaltooltype
12-
ADD CONSTRAINT fk_externaltooltype_externaltool_id FOREIGN KEY (externalTool_id) REFERENCES externaltool (id);
13-
14-
CREATE INDEX IF NOT EXISTS index_actionlogrecord_actiontype
15-
ON externaltooltype (id);
16-
17-
CREATE INDEX IF NOT EXISTS index_actionlogrecord_useridentifier
18-
ON externaltooltype (externaltool_id);
19-
20-
CREATE INDEX IF NOT EXISTS index_externaltooltype_externaltool_id
21-
ON externaltooltype (externaltool_id);
10+
CREATE INDEX IF NOT EXISTS index_externaltooltype_externaltool_id ON externaltooltype (externaltool_id);

modules/dataverse-migrate-db/extra-migrations/V5.4.1.0__prepare-table-auxfile.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- This is a workaround for the missing auxiliaryfile table
1+
-- This is a workaround for the missing auxiliaryfile table in migration V5.4.1.1
22

33
create table if not exists auxiliaryfile
44
(
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- This is a workaround for the missing license table
1+
-- This is a workaround for the missing license table in migration V5.9.0.1
22

33
create table if not exists license
44
(
@@ -13,9 +13,3 @@ create table if not exists license
1313
);
1414

1515
create index if not exists license_sortorder_id on license (sortorder, id);
16-
17-
-- Save information about CCBY license to temporary table (to be used in a migration after the main license migration)
18-
CREATE TEMPORARY TABLE ccby(
19-
id serial primary key
20-
);
21-
INSERT INTO ccby (id) SELECT id FROM termsofuseandaccess WHERE license = 'CCBY';

modules/dataverse-migrate-db/extra-migrations/V6.0.0.0__prepare-tables-embargo-storageuse.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
-- This is a workaround for the missing embargo table
1+
-- This is a workaround for the missing embargo table in migration V6.0.0.2
22
create table if not exists embargo
33
(
44
id serial primary key,
55
dateavailable date not null,
66
reason text
77
);
88

9-
-- This is a workaround for the missing storageuse table
9+
-- This is a workaround for the missing storageuse table in migration V6.0.0.5
1010
create table if not exists storageuse
1111
(
1212
id serial primary key,

modules/dataverse-migrate-db/extra-migrations/V6.1.0.0__prepare-table-extvocab.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- This is a workaround for the missing externalvocabularyvalue table
1+
-- This is a workaround for the missing externalvocabularyvalue table in migration V6.1.0.3
22
create table if not exists externalvocabularyvalue
33
(
44
id serial primary key,
Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
CREATE TABLE IF NOT EXISTS DatasetType
2-
(
3-
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
4-
name VARCHAR(255) NOT NULL,
5-
CONSTRAINT pk_datasettype PRIMARY KEY (id)
6-
);
1+
-- This is a workaround for the missing dataset type tables in migration V6.3.0.3
72

8-
CREATE TABLE IF NOT EXISTS DatasetType_licenses
3+
create table if not exists datasettype
94
(
10-
DatasetType_id BIGINT NOT NULL,
11-
licenses_id BIGINT NOT NULL
5+
id serial primary key,
6+
name varchar(255) not null constraint unq_datasettype_0 unique
127
);
138

14-
CREATE TABLE IF NOT EXISTS DatasetType_metadataBlocks
9+
create table if not exists datasettype_licenses
1510
(
16-
DatasetType_id BIGINT NOT NULL,
17-
metadataBlocks_id BIGINT NOT NULL
11+
datasettype_id bigint not null
12+
constraint fk_datasettype_license_datasettype_id
13+
references datasettype,
14+
licenses_id bigint not null
15+
constraint fk_datasettype_license_licenses_id
16+
references license,
17+
primary key (datasettype_id, licenses_id)
1818
);
1919

20-
ALTER TABLE DatasetType
21-
ADD CONSTRAINT uc_828171b214f7369ee92a28781 UNIQUE (name);
22-
23-
ALTER TABLE DatasetType_licenses
24-
ADD CONSTRAINT fk_datlic_on_dataset_type FOREIGN KEY (DatasetType_id) REFERENCES DatasetType (id);
25-
26-
ALTER TABLE DatasetType_licenses
27-
ADD CONSTRAINT fk_datlic_on_license FOREIGN KEY (licenses_id) REFERENCES License (id);
28-
29-
ALTER TABLE DatasetType_metadataBlocks
30-
ADD CONSTRAINT fk_datmet_on_dataset_type FOREIGN KEY (DatasetType_id) REFERENCES DatasetType (id);
31-
32-
ALTER TABLE DatasetType_metadataBlocks
33-
ADD CONSTRAINT fk_datmet_on_metadata_block FOREIGN KEY (metadataBlocks_id) REFERENCES MetadataBlock (id);
20+
create table if not exists datasettype_metadatablocks
21+
(
22+
datasettype_id bigint not null
23+
constraint fk_datasettype_metadatablock_datasettype_id
24+
references datasettype,
25+
metadatablocks_id bigint not null
26+
constraint fk_datasettype_metadatablock_metadatablocks_id
27+
references public.metadatablock,
28+
primary key (datasettype_id, metadatablocks_id)
29+
);
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
-- This is a workaround for the missing MakeDataCount tables in migration V6.5.0.10
2+
13
CREATE TABLE IF NOT EXISTS MakeDataCountProcessState
24
(
3-
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
4-
yearMonth VARCHAR(255) NOT NULL,
5-
state INTEGER NOT NULL,
5+
id SERIAL PRIMARY KEY,
6+
yearMonth VARCHAR(255) NOT NULL,
7+
state INTEGER NOT NULL,
68
stateChangeTimestamp TIMESTAMP WITHOUT TIME ZONE,
7-
server VARCHAR(255),
8-
CONSTRAINT pk_makedatacountprocessstate PRIMARY KEY (id)
9+
server VARCHAR(255)
910
);
1011

11-
CREATE INDEX IF NOT EXISTS idx_18d578c22760ad21e31cc873d ON MakeDataCountProcessState (yearMonth);
12+
CREATE INDEX IF NOT EXISTS index_makedatacountprocessstate_yearmonth ON MakeDataCountProcessState (yearMonth);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- This is a workaround for the missing tables in migration V6.6.0.2
2+
3+
create table if not exists dataversefeatureditem
4+
(
5+
id serial primary key,
6+
content text,
7+
displayorder integer not null,
8+
imagefilename varchar(255),
9+
type text,
10+
dataverse_id bigint not null constraint fk_dataversefeatureditem_dataverse_id references dvobject,
11+
dvobject_id bigint constraint fk_dataversefeatureditem_dvobject_id references dvobject
12+
);
13+
14+
create index if not exists index_dataversefeatureditem_displayorder on dataversefeatureditem (displayorder);
15+
-- It's unclear why EclipseLink generated this particular index and with this name... Just going along with it.
16+
create index if not exists index_harvestingclient_harvesttype on dataversefeatureditem (id);

0 commit comments

Comments
 (0)