You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2020/06/25 21:24:14 UTC

[airavata] 01/02: Merge remote-tracking branch 'origin/AIRAVATA-3326-improved-database-migration-script-creation' into develop

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 4e8579072875bf3933939efc57613cd6be27c8fe
Merge: 6f19a32 57842ba
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Thu Jun 25 17:09:39 2020 -0400

    Merge remote-tracking branch 'origin/AIRAVATA-3326-improved-database-migration-script-creation' into develop

 .../org/apache/airavata/common/utils/JPAUtils.java | 135 +--------------------
 modules/ide-integration/README.md                  |   6 +
 .../META-INF/generate-sql-persistence.xml          |  30 -----
 .../init/02-sharing-registry-migrations.sql        |   5 +-
 .../init/03-appcatalog-migrations.sql              |  13 +-
 .../init/04-expcatalog-migrations.sql              |   4 +-
 .../src/main/resources/docker-compose.yml          |   4 +-
 modules/registry/registry-core/README.md           | 121 ++++++++++++++++--
 modules/registry/registry-core/pom.xml             | 124 +++++++++++++++----
 .../core/utils/JPAUtil/AppCatalogJPAUtils.java     |   2 +-
 .../core/utils/JPAUtil/ExpCatalogJPAUtils.java     |   2 +-
 .../core/utils/JPAUtil/RepCatalogJPAUtils.java     |   2 +-
 .../core/utils/migration/MappingToolRunner.java    |  46 +++++++
 .../utils/migration/MigrationSchemaGenerator.java  | 100 +++++++++++++++
 .../derby/airavata-server.properties               |  72 +++++++++++
 .../mysql/airavata-server.properties               |  63 ++++++++++
 .../migrations-util/mysql/docker-compose.yml       |  15 +++
 .../create_databases.sql}                          |  21 ++--
 18 files changed, 542 insertions(+), 223 deletions(-)

diff --cc modules/ide-integration/src/main/resources/database_scripts/init/03-appcatalog-migrations.sql
index e4ea6b0,a509fb2..0119ceb
--- a/modules/ide-integration/src/main/resources/database_scripts/init/03-appcatalog-migrations.sql
+++ b/modules/ide-integration/src/main/resources/database_scripts/init/03-appcatalog-migrations.sql
@@@ -8,10 -7,5 +7,10 @@@ CREATE TABLE IF NOT EXISTS COMPUTE_RESO
  )ENGINE=InnoDB DEFAULT CHARSET=latin1;
  CREATE TABLE IF NOT EXISTS COMPUTE_RESOURCE_RESERVATION_QUEUE (RESERVATION_ID VARCHAR(255), QUEUE_NAME VARCHAR(255) NOT NULL
  )ENGINE=InnoDB DEFAULT CHARSET=latin1;
- CREATE INDEX I_CMPTN_Q_RESERVATION_ID ON COMPUTE_RESOURCE_RESERVATION_QUEUE (RESERVATION_ID);
- ALTER TABLE COMPUTE_RESOURCE_RESERVATION ADD CONSTRAINT FK_COMPUTE_RESOURCE_RESERVATION FOREIGN KEY (RESOURCE_ID, GROUP_RESOURCE_PROFILE_ID) REFERENCES GROUP_COMPUTE_RESOURCE_PREFERENCE (RESOURCE_ID, GROUP_RESOURCE_PROFILE_ID) ON DELETE CASCADE;
+ CREATE INDEX IF NOT EXISTS I_CMPTN_Q_RESERVATION_ID ON COMPUTE_RESOURCE_RESERVATION_QUEUE (RESERVATION_ID);
+ ALTER TABLE COMPUTE_RESOURCE_RESERVATION ADD CONSTRAINT FK_COMPUTE_RESOURCE_RESERVATION FOREIGN KEY IF NOT EXISTS (RESOURCE_ID, GROUP_RESOURCE_PROFILE_ID) REFERENCES GROUP_COMPUTE_RESOURCE_PREFERENCE (RESOURCE_ID, GROUP_RESOURCE_PROFILE_ID) ON DELETE CASCADE;
 +
 +-- AIRAVATA-3327: Remove deprecated reservation fields
- alter table GROUP_COMPUTE_RESOURCE_PREFERENCE drop column RESERVATION;
- alter table GROUP_COMPUTE_RESOURCE_PREFERENCE drop column RESERVATION_START_TIME;
- alter table GROUP_COMPUTE_RESOURCE_PREFERENCE drop column RESERVATION_END_TIME;
++alter table GROUP_COMPUTE_RESOURCE_PREFERENCE drop column IF EXISTS RESERVATION;
++alter table GROUP_COMPUTE_RESOURCE_PREFERENCE drop column IF EXISTS RESERVATION_START_TIME;
++alter table GROUP_COMPUTE_RESOURCE_PREFERENCE drop column IF EXISTS RESERVATION_END_TIME;
diff --cc modules/registry/registry-core/pom.xml
index fd28405,39cd1ad..f718d00
--- a/modules/registry/registry-core/pom.xml
+++ b/modules/registry/registry-core/pom.xml
@@@ -149,28 -151,95 +154,76 @@@
                  </configuration>
                  <executions>
                      <execution>
-                         <id>enhancer</id>
-                         <phase>process-classes</phase>
+                         <!-- Run with:
+                             mvn process-classes docker-compose:up@mysql-up exec:exec@generate-migrations-mysql docker-compose:down@mysql-down
+                         -->
+                         <id>generate-migrations-mysql</id>
                          <goals>
-                             <goal>enhance</goal>
+                             <goal>exec</goal>
                          </goals>
+                         <configuration>
+                             <arguments>
+                                 <argument>-Dairavata.config.dir=${project.basedir}/src/main/resources/migrations-util/mysql</argument>
+                                 <argument>-classpath</argument>
+                                 <classpath/>
+                                 <argument>org.apache.airavata.registry.core.utils.migration.MigrationSchemaGenerator</argument>
+                             </arguments>
+                         </configuration>
                      </execution>
                      <execution>
-                         <!-- execute with `mvn compile openjpa:sql@generate-sql` or `mvn process-classes` -->
-                         <id>generate-sql</id>
+                         <!-- Run with:
+                             mvn process-classes docker-compose:up@mysql-up exec:exec@generate-schema-mysql docker-compose:down@mysql-down
+                         -->
+                         <id>generate-schema-mysql</id>
+                         <goals>
+                             <goal>exec</goal>
+                         </goals>
                          <configuration>
-                             <!-- openjpa:sql doesn't work well with multiple persistence-unit's in persistence.xml, so
-                             use this single persistence-unit persistence.xml to list any classes for which SQL schema
-                             generation is desired -->
-                             <persistenceXmlFile>${basedir}/src/main/resources/META-INF/generate-sql-persistence.xml</persistenceXmlFile>
-                             <sqlAction>build</sqlAction>
-                             <connectionDriverName>org.apache.derby.jdbc.ClientDriver</connectionDriverName>
+                             <arguments>
+                                 <argument>-Dairavata.config.dir=${project.basedir}/src/main/resources/migrations-util/mysql</argument>
+                                 <argument>-classpath</argument>
+                                 <classpath/>
+                                 <argument>org.apache.airavata.registry.core.utils.migration.MigrationSchemaGenerator</argument>
+                                 <argument>build</argument>
+                             </arguments>
                          </configuration>
+                     </execution>
+                     <execution>
+                         <!-- Run with:
+                             mvn process-classes exec:exec@generate-migrations-derby
+                         -->
+                         <id>generate-migrations-derby</id>
+                         <goals>
+                             <goal>exec</goal>
+                         </goals>
+                         <configuration>
+                             <arguments>
+                                 <argument>-Dairavata.config.dir=${project.basedir}/src/main/resources/migrations-util/derby</argument>
+                                 <argument>-classpath</argument>
+                                 <classpath/>
+                                 <argument>org.apache.airavata.registry.core.utils.migration.MigrationSchemaGenerator</argument>
+                             </arguments>
+                         </configuration>
+                     </execution>
+                     <execution>
+                         <!-- Run with:
+                             mvn process-classes exec:exec@generate-schema-derby
+                         -->
+                         <id>generate-schema-derby</id>
                          <goals>
-                             <goal>sql</goal>
+                             <goal>exec</goal>
                          </goals>
+                         <configuration>
+                             <arguments>
+                                 <argument>-Dairavata.config.dir=${project.basedir}/src/main/resources/migrations-util/derby</argument>
+                                 <argument>-classpath</argument>
+                                 <classpath/>
+                                 <argument>org.apache.airavata.registry.core.utils.migration.MigrationSchemaGenerator</argument>
+                                 <argument>build</argument>
+                             </arguments>
+                         </configuration>
                      </execution>
                  </executions>
 -            </plugin>
 -            <plugin>
 -                <groupId>org.apache.openjpa</groupId>
 -                <artifactId>openjpa-maven-plugin</artifactId>
 -                <version>2.2.0</version>
 -                <configuration>
 -                    <includes>**/model/*.class</includes>
 -                    <addDefaultConstructor>true</addDefaultConstructor>
 -                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
 -                </configuration>
 -                <executions>
 -                    <execution>
 -                        <id>enhancer</id>
 -                        <phase>process-classes</phase>
 -                        <goals>
 -                            <goal>enhance</goal>
 -                        </goals>
 -                    </execution>
 -                </executions>
                  <dependencies>
                      <dependency>
                          <groupId>org.apache.openjpa</groupId>