From 657b436b41bc101fe6167344641244ba12eb3b81 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Mon, 15 Oct 2018 10:55:34 -0400 Subject: [PATCH 1/4] moving required db changes to main upgrade script --- scripts/database/5043-update.sql | 2 -- scripts/database/upgrades/upgrade_v4.9.4_to_v4.10.sql | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 scripts/database/5043-update.sql diff --git a/scripts/database/5043-update.sql b/scripts/database/5043-update.sql deleted file mode 100644 index b9393f6c90f..00000000000 --- a/scripts/database/5043-update.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE datasetfieldtype ADD COLUMN uri text; -ALTER TABLE metadatablock ADD COLUMN namespaceuri text; \ No newline at end of file diff --git a/scripts/database/upgrades/upgrade_v4.9.4_to_v4.10.sql b/scripts/database/upgrades/upgrade_v4.9.4_to_v4.10.sql index 0f53ccff732..f252ad22dfc 100644 --- a/scripts/database/upgrades/upgrade_v4.9.4_to_v4.10.sql +++ b/scripts/database/upgrades/upgrade_v4.9.4_to_v4.10.sql @@ -1,4 +1,6 @@ ALTER TABLE usernotification ADD requestor_id BIGINT; +ALTER TABLE datasetfieldtype ADD COLUMN uri text; +ALTER TABLE metadatablock ADD COLUMN namespaceuri text; From 7c677348b78d6dc584d6580b2be59256cf0168f5 Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Tue, 16 Oct 2018 12:45:54 -0400 Subject: [PATCH 2/4] avoid confusion by removing 3561-update.sql #5186 This script is referenced from https://github.com/IQSS/dataverse/releases/tag/v4.8 and it's unclear why it was not part of upgrade_v4.7.1_to_v4.8.sql New contributors have found the presence of this script in the "scripts/database" directory confusing and have assumed that the process they should follow is to create a similar script, not knowing about our upgrade_v4.7.1_to_v4.8.sql process. --- scripts/database/3561-update.sql | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 scripts/database/3561-update.sql diff --git a/scripts/database/3561-update.sql b/scripts/database/3561-update.sql deleted file mode 100644 index 8ddd3d3c02c..00000000000 --- a/scripts/database/3561-update.sql +++ /dev/null @@ -1,24 +0,0 @@ --- create the workflow tables -CREATE TABLE WORKFLOW (ID SERIAL NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID)); -CREATE TABLE PENDINGWORKFLOWINVOCATION (INVOCATIONID VARCHAR(255) NOT NULL, DOIPROVIDER VARCHAR(255), IPADDRESS VARCHAR(255), NEXTMINORVERSIONNUMBER BIGINT, NEXTVERSIONNUMBER BIGINT, PENDINGSTEPIDX INTEGER, TYPEORDINAL INTEGER, USERID VARCHAR(255), WORKFLOW_ID BIGINT, DATASET_ID BIGINT, PRIMARY KEY (INVOCATIONID)); - -CREATE INDEX INDEX_DATASETLOCK_user_id ON DATASETLOCK (user_id); -CREATE INDEX INDEX_DATASETLOCK_dataset_id ON DATASETLOCK (dataset_id); - --- Alter Dataset lock -ALTER TABLE DATASETLOCK ADD CONSTRAINT FK_DATASETLOCK_DATASET_ID FOREIGN KEY (DATASET_ID) REFERENCES DVOBJECT (ID); -ALTER TABLE DATASETLOCK ADD CONSTRAINT FK_DATASETLOCK_USER_ID FOREIGN KEY (USER_ID) REFERENCES AUTHENTICATEDUSER (ID); -ALTER TABLE DATASETLOCK ADD COLUMN REASON VARCHAR(255); - --- All existing dataset locks are due to ingest. -UPDATE DATASETLOCK set REASON='Ingest'; - --- /!\ Important! --- change "1" to the an admin user id. --- -INSERT INTO datasetlock (info, starttime, dataset_id, user_id, reason) -SELECT '', localtimestamp, dataset_id, 1, 'InReview' -FROM datasetversion -WHERE inreview=true; - -ALTER TABLE DATASETVERSION DROP COLUMN inreview; From b802c85b49707af392ecbda3e127419b6fbe2ecf Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Tue, 16 Oct 2018 14:09:57 -0400 Subject: [PATCH 3/4] add SQL Upgrade Scripts section to Dev Guide #5186 --- PULL_REQUEST_TEMPLATE.md | 2 +- doc/sphinx-guides/source/developers/index.rst | 1 + .../source/developers/making-releases.rst | 2 +- .../source/developers/sql-upgrade-scripts.rst | 40 +++++++++++++++++++ .../source/developers/testing.rst | 2 +- doc/sphinx-guides/source/developers/tips.rst | 2 +- .../source/developers/version-control.rst | 2 +- 7 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index f883e74982c..2c834088c1f 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -15,7 +15,7 @@ Welcome! New contributors should at least glance at [CONTRIBUTING.md](/CONTRIBUT - [ ] Merged latest from "develop" [branch][] and resolved conflicts [tests]: http://guides.dataverse.org/en/latest/developers/testing.html -[SQL updates]: https://github.com/IQSS/dataverse/tree/develop/scripts/database/upgrades +[SQL updates]: http://guides.dataverse.org/en/latest/developers/sql-upgrade-scripts.html [Solr updates]: https://github.com/IQSS/dataverse/blob/develop/conf/solr/7.3.0/schema.xml [docs]: http://guides.dataverse.org/en/latest/developers/documentation.html [branch]: http://guides.dataverse.org/en/latest/developers/branching-strategy.html diff --git a/doc/sphinx-guides/source/developers/index.rst b/doc/sphinx-guides/source/developers/index.rst index fd7749df746..a1fb4dda581 100755 --- a/doc/sphinx-guides/source/developers/index.rst +++ b/doc/sphinx-guides/source/developers/index.rst @@ -16,6 +16,7 @@ Developer Guide tips troubleshooting version-control + sql-upgrade-scripts testing documentation debugging diff --git a/doc/sphinx-guides/source/developers/making-releases.rst b/doc/sphinx-guides/source/developers/making-releases.rst index 6a77b2865b5..9782366b61d 100755 --- a/doc/sphinx-guides/source/developers/making-releases.rst +++ b/doc/sphinx-guides/source/developers/making-releases.rst @@ -36,7 +36,7 @@ Upload the following artifacts to the draft release you created: - war file (``mvn package`` from Jenkins) - installer (``cd scripts/installer && make``) -- database migration script +- database migration script (see also the :doc:`sql-upgrade-scripts` section) - other files as needed, such as an updated Solr schema Publish Release diff --git a/doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst b/doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst new file mode 100644 index 00000000000..bd39bae5a31 --- /dev/null +++ b/doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst @@ -0,0 +1,40 @@ +=================== +SQL Upgrade Scripts +=================== + +The database schema for Dataverse is constantly evolving. As other developers make changes to the database schema you will need to keep up with these changes to keep your development environment in working order. Additionally, as you make changes to the database schema, you must help write SQL upgrade scripts as needed and communicate with your fellow developers when the scripts must be applied. + +.. contents:: |toctitle| + :local: + +Location of SQL Upgrade Scripts +------------------------------- + +``scripts/database/upgrades`` is the directory where we keep or SQL upgrade scripts. + +How to Determine if You Need to Create or Update a SQL Upgrade Script +--------------------------------------------------------------------- + +If you are creating a new database table (which maps to an ``@Entity`` in JPA), you do not need to create or update a SQL upgrade script. The reason for this is that we use ``create-tables`` in ``src/main/resources/META-INF/persistence.xml`` so that new tables are automatically created by Glassfish when you deploy your war file. + +If you are doing anything other than creating a new database table such as adding a column to an existing table, you must create or update a SQL upgrade script. + +How to Create or Update a SQL Upgrade Script +-------------------------------------------- + +We assume you have already read the :doc:`version-control` section and have been keeping your feature branch up to date with the "develop" branch. + +First, check https://github.com/IQSS/dataverse/tree/develop/scripts/database/upgrades to see if a SQL upgrade script for the next release already exists. For example, if the current release is 4.9.4 and the next release will be 4.10, the script will be named ``upgrade_v4.9.4_to_v4.10.sql``. If the script exists, just add your changes to the bottom of it. + +If no SQL upgrade script exists, look at https://github.com/IQSS/dataverse/milestones to figure out the name of the next milestone and create a script using the naming convention above. + +As with any task related to Dataverse development, if you need any help writing SQL upgrade scripts, please reach out using any of the channels mentioned under "Getting Help" in the :doc:`intro` section. + +Communicating the Need to Run SQL Updates +----------------------------------------- + +If you have made a pull request that contains SQL updates and that pull request is merged into the "develop" branch, you are responsible for communicating to other developers that when then pull the latest code from "develop" they must run your SQL updates. Post a message to the "dataverse-dev" mailing list at https://groups.google.com/forum/#!forum/dataverse-dev + +---- + +Previous: :doc:`version-control` | Next: :doc:`testing` diff --git a/doc/sphinx-guides/source/developers/testing.rst b/doc/sphinx-guides/source/developers/testing.rst index 50740618bfe..ac43d4111ff 100755 --- a/doc/sphinx-guides/source/developers/testing.rst +++ b/doc/sphinx-guides/source/developers/testing.rst @@ -290,4 +290,4 @@ Future Work on Load/Performance Testing ---- -Previous: :doc:`version-control` | Next: :doc:`documentation` +Previous: :doc:`sql-upgrade-scripts` | Next: :doc:`documentation` diff --git a/doc/sphinx-guides/source/developers/tips.rst b/doc/sphinx-guides/source/developers/tips.rst index 6cf5f9a45d3..da6121d74fc 100755 --- a/doc/sphinx-guides/source/developers/tips.rst +++ b/doc/sphinx-guides/source/developers/tips.rst @@ -79,7 +79,7 @@ For faster iteration while working on JSF pages, it is highly recommended that y Database Schema Exploration --------------------------- -With over 100 tables, the Dataverse PostgreSQL database ("dvndb") can be somewhat daunting for newcomers. Here are some tips for coming up to speed. +With over 100 tables, the Dataverse PostgreSQL database ("dvndb") can be somewhat daunting for newcomers. Here are some tips for coming up to speed. (See also the :doc:`sql-upgrade-scripts` section.) pgAdmin ~~~~~~~~ diff --git a/doc/sphinx-guides/source/developers/version-control.rst b/doc/sphinx-guides/source/developers/version-control.rst index 66562b83a9d..b6a81ad7676 100644 --- a/doc/sphinx-guides/source/developers/version-control.rst +++ b/doc/sphinx-guides/source/developers/version-control.rst @@ -145,4 +145,4 @@ GitHub documents how to make changes to a fork at https://help.github.com/articl ---- -Previous: :doc:`troubleshooting` | Next: :doc:`testing` +Previous: :doc:`troubleshooting` | Next: :doc:`sql-upgrade-scripts` From e39a94df05a86727ce5e01727882cd614b859af9 Mon Sep 17 00:00:00 2001 From: matthew-a-dunlap Date: Fri, 19 Oct 2018 11:14:48 -0400 Subject: [PATCH 4/4] Minor text changes --- doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst b/doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst index bd39bae5a31..bb70c2b59c8 100644 --- a/doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst +++ b/doc/sphinx-guides/source/developers/sql-upgrade-scripts.rst @@ -2,7 +2,7 @@ SQL Upgrade Scripts =================== -The database schema for Dataverse is constantly evolving. As other developers make changes to the database schema you will need to keep up with these changes to keep your development environment in working order. Additionally, as you make changes to the database schema, you must help write SQL upgrade scripts as needed and communicate with your fellow developers when the scripts must be applied. +The database schema for Dataverse is constantly evolving. As other developers make changes to the database schema you will need to keep up with these changes to have your development environment in working order. Additionally, as you make changes to the database schema, you must write SQL upgrade scripts when needed and communicate with your fellow developers about applying those scripts. .. contents:: |toctitle| :local: