forked from IQSS/dataverse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request IQSS#7355 from poikilotherm/7256-purge-referencedata
7256 purge referencedata
- Loading branch information
Showing
8 changed files
with
73 additions
and
160 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- TODO: we still should add the real base line here, too. That would avoid conflicts between EclipseLink | ||
-- trying to create new tables on existing databases. See https://github.com/IQSS/dataverse/issues/5871 |
17 changes: 17 additions & 0 deletions
17
src/main/resources/db/migration/V5.2.0.1__7256-purge-referencedata.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- #5361 and #7256 is about faster deployments, especially during development, sitting on an empty database. | ||
-- | ||
-- This script has been part of scripts/database/reference_data.sql that had to be executed manually on every new | ||
-- deployment (manually in the sense of Flyway didn't, the outside installer or an admin took care of it). | ||
-- | ||
-- While this is pretty old stuff and should have been done earlier (baseline...), it will be a nice migration | ||
-- and behave like nothing happened if this is an existing installation. All new installation have an empty database | ||
-- on first app boot and benefit from this Flyway-based management. | ||
|
||
-- This is unsupported by JPA, as it is PostgreSQL specific. Has to be done here, cannot be done in code. | ||
-- (Only other option would be a lowercase copy of the data as a separate column, automatically filled py JPA) | ||
CREATE UNIQUE INDEX IF NOT EXISTS dataverse_alias_unique_idx on dataverse (LOWER(alias)); | ||
CREATE UNIQUE INDEX IF NOT EXISTS index_authenticateduser_lower_email ON authenticateduser (lower(email)); | ||
|
||
-- Edit Dataset: Investigate and correct multiple draft issue: https://github.com/IQSS/dataverse/issues/2132 | ||
-- This unique index will prevent the multiple draft issue, yet it cannot be done in JPA code. | ||
CREATE UNIQUE INDEX IF NOT EXISTS one_draft_version_per_dataset ON datasetversion (dataset_id) WHERE versionstate='DRAFT'; |
51 changes: 51 additions & 0 deletions
51
src/main/resources/db/migration/afterMigrate__1-7256-upsert-referenceData.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- #5361 and #7256 is about faster deployments, especially during development, sitting on an empty database. | ||
-- | ||
-- This script has been part of scripts/database/reference_data.sql that had to be executed manually on every new | ||
-- deployment (manually in the sense of Flyway didn't, the outside installer or an admin took care of it). | ||
-- | ||
-- This script will load some initial, common data if not present (so only once, when booting for the first time). | ||
|
||
-- using http://dublincore.org/schemas/xmls/qdc/dcterms.xsd because at http://dublincore.org/schemas/xmls/ it's the | ||
-- schema location for http://purl.org/dc/terms/ which is referenced in http://swordapp.github.io/SWORDv2-Profile/SWORDProfile.html | ||
INSERT INTO foreignmetadataformatmapping (id, name, startelement, displayName, schemalocation) | ||
VALUES | ||
(1, 'http://purl.org/dc/terms/', 'entry', 'dcterms: DCMI Metadata Terms', 'http://dublincore.org/schemas/xmls/qdc/dcterms.xsd') | ||
ON CONFLICT DO NOTHING; | ||
|
||
INSERT INTO foreignmetadatafieldmapping (id, foreignfieldxpath, datasetfieldname, isattribute, parentfieldmapping_id, foreignmetadataformatmapping_id) | ||
VALUES | ||
(1, ':title', 'title', FALSE, NULL, 1 ), | ||
(2, ':identifier', 'otherIdValue', FALSE, NULL, 1 ), | ||
(3, ':creator', 'authorName', FALSE, NULL, 1 ), | ||
(4, ':date', 'productionDate', FALSE, NULL, 1 ), | ||
(5, ':subject', 'keywordValue', FALSE, NULL, 1 ), | ||
(6, ':description', 'dsDescriptionValue', FALSE, NULL, 1 ), | ||
(7, ':relation', 'relatedMaterial', FALSE, NULL, 1 ), | ||
(8, ':isReferencedBy', 'publicationCitation', FALSE, NULL, 1 ), | ||
(9, 'holdingsURI', 'publicationURL', TRUE, 8, 1 ), | ||
(10, 'agency', 'publicationIDType', TRUE, 8, 1 ), | ||
(11, 'IDNo', 'publicationIDNumber', TRUE, 8, 1 ), | ||
(12, ':coverage', 'otherGeographicCoverage', FALSE, NULL, 1 ), | ||
(13, ':type', 'kindOfData', FALSE, NULL, 1 ), | ||
(14, ':source', 'dataSources', FALSE, NULL, 1 ), | ||
(15, 'affiliation', 'authorAffiliation', TRUE, 3, 1 ), | ||
(16, ':contributor', 'contributorName', FALSE, NULL, 1 ), | ||
(17, 'type', 'contributorType', TRUE, 16, 1 ), | ||
(18, ':publisher', 'producerName', FALSE, NULL, 1 ), | ||
(19, ':language', 'language', FALSE, NULL, 1 ) | ||
ON CONFLICT DO NOTHING; | ||
|
||
-- Simple trick: WHERE NOT EXISTS (SELECT id FROM table) is only true if the table is empty. | ||
INSERT INTO guestbook (emailrequired, enabled, institutionrequired, createtime, name, namerequired, positionrequired, dataverse_id) | ||
SELECT false, true, false, now(), 'Default', false, false, null | ||
WHERE NOT EXISTS (SELECT id FROM guestbook); | ||
|
||
-- Simple trick: WHERE NOT EXISTS (SELECT id FROM table) is only true if the table is empty. | ||
INSERT INTO worldmapauth_tokentype | ||
(name, created, contactemail, hostname, | ||
ipaddress, mapitlink, | ||
md5, modified, timelimitminutes) | ||
SELECT 'GEOCONNECT', current_timestamp, 'support@dataverse.org', 'geoconnect.datascience.iq.harvard.edu', | ||
'140.247.115.127', 'http://geoconnect.datascience.iq.harvard.edu/shapefile/map-it', | ||
'38c0a931b2d582a5c43fc79405b30c22', current_timestamp, 30 | ||
WHERE NOT EXISTS (SELECT id from worldmapauth_tokentype); |