[
https://issues.apache.org/jira/browse/AIRAVATA-3326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17105517#comment-17105517
]
Marcus Christie commented on AIRAVATA-3326:
-------------------------------------------
I've tried some tests with generating a migration script when removing a field
from an entity class, unfortunately none of my tests yield any good results.
I'm following this documentation:
http://openjpa.apache.org/builds/2.4.3/apache-openjpa/docs/ref_guide_mapping.html#ref_guide_mapping_mappingtool
- tried schemaAction=refresh
- tried schemaAction=retain
- tried ignoreErrors=true
- tried readSchema=true
Either I get an empty migration script, or one that for some reason is trying
to remove several constraints from tables, or I get an error like the following:
{noformat}
java.lang.RuntimeException: Failed to run MappingTool to generate migration
script
at
org.apache.airavata.registry.core.utils.migration.MappingToolRunner.run(MappingToolRunner.java:41)
at
org.apache.airavata.registry.core.utils.migration.MigrationSchemaGenerator.main(MigrationSchemaGenerator.java:34)
Caused by: java.lang.NullPointerException: null
at
org.apache.openjpa.jdbc.schema.LocalConstraint.remove(LocalConstraint.java:70)
at org.apache.openjpa.jdbc.schema.Table.removeIndex(Table.java:753)
at org.apache.openjpa.jdbc.schema.Table.remove(Table.java:115)
at org.apache.openjpa.jdbc.schema.Schema.removeTable(Schema.java:212)
at
org.apache.openjpa.jdbc.schema.SchemaTool.dropTables(SchemaTool.java:1004)
at org.apache.openjpa.jdbc.schema.SchemaTool.retain(SchemaTool.java:794)
at org.apache.openjpa.jdbc.schema.SchemaTool.dropDB(SchemaTool.java:437)
at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:357)
at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:517)
at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:1103)
at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:1014)
at
org.apache.airavata.registry.core.utils.migration.MappingToolRunner.run(MappingToolRunner.java:38)
... 1 common frames omitted
{noformat}
These tests are with a Derby database. It's possible that generating migrations
for Derby isn't fully functional. I'll try again with MariaDB once I have that
integrated.
> Improved database migration script creation
> -------------------------------------------
>
> Key: AIRAVATA-3326
> URL: https://issues.apache.org/jira/browse/AIRAVATA-3326
> Project: Airavata
> Issue Type: New Feature
> Components: Registry API
> Reporter: Marcus Christie
> Assignee: Marcus Christie
> Priority: Major
>
> Improve automatic generation of database migration scripts. Work on this was
> started in AIRAVATA-3126. In that issue the OpenJPA MappingTool was
> integrated to run and generate a migration script whenever the schema
> validation fails.
> Continuing on that work, I'd like to
> - create a migration script generation tool (MappingTool) that can be run
> directly from the command line
> - integrate starting a MariaDB, perhaps via docker-compose, and run
> MappingTool against that to generate the mysql scripts
> - finish the documentation on how to take the generated scripts and integrate
> them in the various places in the code base where they belong
> - change ide-migration docker-compose database server to mariadb. MariaDB has
> some good additions to mysql for creating migration scripts that can be
> re-runnable (e.g., {{IF NOT EXISTS}}).
> - clean up remove generate-sql-persistence.xml and maven goal that used it
> Questions
> - when there are new/changed tables in more than one schema, what migration
> script gets created? I'm guessing that they will clobber each other so the
> name of the file needs to be unique to the schema.
> h5. TODO
> - [x] Run derby db and migration script creation in ./target directory
> - [x] derby db not shutting down cleanly?
> - [ ] run MappingTool directly
> - [ ] separate logging configuration from test logging and separate
> airavata-server.properties file
--
This message was sent by Atlassian Jira
(v8.3.4#803005)