How to undo a migration using Flyway? - java

I am working on a Spring project and I have FlyWay as a dependency to manage my migrations, I made a mistake on the SQL command. When I ran the project I got an error showing a problem with the script, a silly mistake that was easy to fix, I misspelled a column name. However, the undo command from the flyway is not working.
I was trying to undo a migration using FlyWay and I follow the tutorial from FlyWay documentation: link-flyway
However, I got this output:
C:\Users\leonardo.freitas\Documents\workspace\api>C:\Users\leonardo.freitas\Documents\workspace\flyway-9.8.1\flyway undo
A new version of Flyway is available
Upgrade to Flyway 9.8.2: https://rd.gt/2X0gakb
ERROR: The command 'undo' was not recognized. Make sure you have added 'flyway-proprietary' as a dependency.
Caused by: No command extension found to handle command: undo
That's my migration history:
C:\Users\leonardo.freitas\Documents\workspace\api>C:\Users\leonardo.freitas\Documents\workspace\flyway-9.8.1\flyway info
A new version of Flyway is available
Upgrade to Flyway 9.8.2: https://rd.gt/2X0gakb
Flyway Community Edition 9.8.1 by Redgate
See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#9.8.1
ERROR: Skipping filesystem location: sql (not found)
Database: jdbc:mysql://localhost:3306/volimed (MySQL 8.0)
Schema version: 5
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
| Category | Version | Description | Type | Installed On | State | Undoable |
C:\Users\leonardo.freitas\Documents\workspace\api>C:\Users\leonardo.freitas\Documents\workspace\flyway-9.8.1\flyway info
A new version of Flyway is available
Upgrade to Flyway 9.8.2: https://rd.gt/2X0gakb
Flyway Community Edition 9.8.1 by Redgate
See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#9.8.1
ERROR: Skipping filesystem location: sql (not found)
Database: jdbc:mysql://localhost:3306/volimed (MySQL 8.0)
Schema version: 5
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
| Category | Version | Description | Type | Installed On | State | Undoable |
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
| Versioned | 1 | create-table-medicos | SQL | 2022-11-19 03:12:19 | Future | No |
| Versioned | 2 | alter-table-medicos-add-telefone | SQL | 2022-11-19 13:32:45 | Future | No |
| Versioned | 3 | create-table-pacientes | SQL | 2022-11-19 13:46:17 | Future | No |
| Versioned | 4 | alter-table-medicos-add-column-active | SQL | 2022-11-19 15:28:46 | Future | No |
| Versioned | 5 | alter-table-paciente-add-column-active | SQL | 2022-11-19 15:45:28 | Failed (Future) | No |
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
And I want to redu the last migration.

Undo command is supported in both the Teams and Enterprise edition . Flyway Enterprise is the only version with auto generation of Undo scripts though. Bill, could you point me towards where the information is conflicting?

I find out a way to resolve this problem, I went to the FlyWay table and deleted the last row, when I ran the project the FlyWay applied the migration again.

Related

Fitnesse: Slim server fails to start; using Eclipse

I'm trying to get a very basic Fitnesse test to run; using Fitnesse / Slim; Java in Eclipse.
Test runs, or at least starts, but doesn't finish; get this error:
Unable to start test system 'slim': fitnesse.slim.SlimError: Error SLiM server died before a connection could be established. JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
Fitnesse test is:
!define TEST_SYSTEM {slim}
!path: C:\Users\<my folder>\EclipseWorkspace\CalculatorProject
| import | packageCalculator |
| TestCalculator |
| operand | result? |
| 4 | 8 |
| 2 | 4 |
| 7 | 14 |
| 2 | 4 |
This is a similar issue: Fitnesse: SLiM server died before a connection could be established; suggests this might be a regression bug; but I tried earlier versions of fitnesse, which made no difference
And it's not this one either: https://github.com/unclebob/fitnesse/issues/726; there is no space in the classpath
Help!!!

Java class is not a valid argument to the jvm

I have a wrapper.conf file that contains the following (note I've omitted irrelevant entries such as .1, .2, .3, etc.):
set.default.JAVA_HOME=E:\DATA\Dev\jdk1.7.0_65
# Java Application
set.default.KARAF_BASE=E:\hsip-base-5.3.1.1b
wrapper.working.dir=%KARAF_BASE%
wrapper.java.command=java
wrapper.java.mainclass=org.apache.karaf.shell.wrapper.Main
wrapper.java.classpath.1=%KARAF_BASE%/lib/karaf-wrapper.jar
wrapper.java.classpath.2=%KARAF_HOME%/lib/karaf.jar
wrapper.java.classpath.3=%KARAF_HOME%/lib/karaf-jaas-boot.jar
wrapper.java.classpath.4=%KARAF_BASE%/lib/karaf-wrapper-main.jar
wrapper.java.library.path.1=%KARAF_BASE%/lib/
# JVM Parameters
wrapper.java.additional.4=org.apache.karaf.main.Main
On starting apache karaf I'm getting the following error:
STATUS | wrapper | 2017/01/30 14:42:52 | --> Wrapper Started as Service
WARN | wrapper | 2017/01/30 14:42:52 | The value of property 'wrapper.java.additional.4', 'org.apache.karaf.main.Main' is not a valid argument to the jvm. Skipping.
The jar file it is looking for and the class within are fine (%KARAF_BASE%/lib/karaf-wrapper-main.jar)
Is fine. A colleague had a similar problem and it was JVM related but cannot remember what.
Does anyone know where I can even start with this because it should work. I have java 8 on my machine, but I have removed all references to it and my JAVA_HOME is pointing at this version 7, don't know if that makes a difference.
Note, the actual stack traces are something like
INFO | jvm 1 | 2017/01/30 15:11:48 | ERROR: Bundle org.ops4j.pax.url.wrap [1] Error starting mvn:org.ops4j.pax.url/pax-url-wrap/1.2.8 (org.osgi.framework.BundleException: Unresolved constraint in bundle org.ops4j.pax.url.wrap [1]: Unable to resolve 1.0: missing requirement [1.0] package; (package=javax.net.ssl))
INFO | jvm 1 | 2017/01/30 15:11:48 | org.osgi.framework.BundleException: Unresolved constraint in bundle org.ops4j.pax.url.wrap [1]: Unable to resolve 1.0: missing requirement [1.0] package; (package=javax.net.ssl)
INFO | jvm 1 | 2017/01/30 15:11:48 | at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3564)
INFO | jvm 1 | 2017/01/30 15:11:48 | at org.apache.felix.framework.Felix.startBundle(Felix.java:1797)
INFO | jvm 1 | 2017/01/30 15:11:48 | at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1192)
INFO | jvm 1 | 2017/01/30 15:11:48 | at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
INFO | jvm 1 | 2017/01/30 15:11:48 | at java.lang.Thread.run(Unknown Source)

How to install Hibernate 5 into Apache Karaf v4

I've installed Apache Karaf v4.03 and queried the list of available features for Hibernate, as listed below. Unfortunately, I am using Hibernate v5.
hibernate | 3.3.2.GA | | Uninstalled | enterprise-4.0.3 | Hibernate 3.x JPA persistence engine support
hibernate | 4.2.15.Final | | Uninstalled | enterprise-4.0.3 | Hibernate 4.2.x JPA persistence engine support
hibernate-envers | 4.2.15.Final | | Uninstalled | enterprise-4.0.3 | Hibernate Envers 4.2.x
hibernate | 4.3.6.Final | | Uninstalled | enterprise-4.0.3 | Hibernate 4.3.x JPA persistence engine support
hibernate-envers | 4.3.6.Final | | Uninstalled | enterprise-4.0.3 | Hibernate Envers 4.3.x
hibernate-validator | 5.0.3.Final | | Uninstalled | enterprise-4.0.3 | Hibernate Validator support
I am unable to find instructions for installing Hibernate v5 into Karaf v4. Are there published instructions for performing this task, and perhaps a downloadable features file?
Latest hibernate-release comes Karaf ready already:
If you download the hibernate-release-5.0.5.Final.zip from hibernate's page (http://sourceforge.net/projects/hibernate/files/hibernate-orm/5.0.5.Final/hibernate-release-5.0.5.Final.zip/download) and decompress the file, you will see an osgi folder.
There you can find an already prepared feauture: hibernate-osgi-5.0.5.Final-karaf.xml.
You can just copy it to Karaf's deploy folder and then execute:
feature:install hibernate-orm
It should be installed without any problem.
Another way to install hibernate 5.0.5 feature is to add a repo to features with the command:
feature:repo-add command.
Here you can see the list of hibernate's features and the one I have installed:
karaf#root()> feature:list | grep hibernate
hibernate | 3.3.2.GA | | Uninstalled | enterprise-4.0.3 | Hibernate 3.x JPA persistence engine support
hibernate | 4.2.15.Final | | Uninstalled | enterprise-4.0.3 | Hibernate 4.2.x JPA persistence engine support
hibernate-envers | 4.2.15.Final | | Uninstalled | enterprise-4.0.3 | Hibernate Envers 4.2.x
hibernate | 4.3.6.Final | | Uninstalled | enterprise-4.0.3 | Hibernate 4.3.x JPA persistence engine support
hibernate-envers | 4.3.6.Final | | Uninstalled | enterprise-4.0.3 | Hibernate Envers 4.3.x
hibernate-validator | 5.0.3.Final | | Uninstalled | enterprise-4.0.3 | Hibernate Validator support
hibernate-orm | 5.0.5.Final | x | Started | hibernate-osgi | Combines all Hibernate core dependencies and requ
hibernate-envers | 5.0.5.Final | | Uninstalled | hibernate-osgi | Feature for easily adding Envers support to hiber
hibernate-infinispan | 5.0.5.Final | | Uninstalled | hibernate-osgi | Feature for easily adding Infinispan-based cachin
hibernate-ehcache | 5.0.5.Final | | Uninstalled | hibernate-osgi | Feature for easily adding Ehcache-based caching s
karaf#root()>
Run the following commands on Karaf shell to get Hibernate 5.1.0.Final working on Karaf 4.0.x:
feature:repo-add mvn:org.hibernate/hibernate-osgi/5.1.0.Final/xml/karaf
feature:install hibernate-orm
Hibernate 5 already provides a feature that is also available from maven central. Recent karaf versions provide a nice shortcut to install such features:
feature:repo-add hibernate 5.0.5.Final
feature:install hibernate-orm
So there is no need to manually download the hibernate zip.
If you build your own feature that needs hibernate 5 then you need to provide a element in it that points to the full hibernate feature url.
mvn:org.hibernate/hibernate-osgi/5.0.5.Final/xml/karaf

Adding Classes to Clojure

In my clojure project I have a dependency on the javax.jms.MessageListener library. I have this class file in my project in the following directory
My-project
|java-
| |src -
| | |myJavaFile.java
| | |jars -
| | |library1.jar
| | |library2.jar
| | |libarary3.jar
| |javax -
| | |jms -
| | |MessageListener.class
|project.clj
|src -
| |my-program1.clj
| |my-program2.clj
| |my-program3.clj
Then in my project.clj file I have my java-source-paths set to
:java-source-paths ["java/src" "java/src/jars/" "java/javax/jms"]
but when I go to run my project via lein repl, I get compilation errors saying
java.lang.NoClassDefFoundError: javax/jms/MessageListener
Caused by: java.lang.ClassNotFoundException: javax.jms.MessageListener
From what I've read the messagelistener.class and my library jars should be included in my classpath when the project is running but that doesn't seem to be the case.
It is my understanding that the directory structure of java projects has to match the name of the namespaces. For instance package_name.classname has to be in the folder package_name on the classpath https://docs.oracle.com/javase/tutorial/java/package/managingfiles.html
But of course using either Leiningen or Boot you just need to add [javax.jms/jms-api "1.1-rev-1"] to the :dependencies.

Maven parent hierarchy + dependencyManagement not transitive?

I thought dependencyManagement from parents were transitive aren't they?
Never see that explicitely in the doc, but it seemed obvious to me...
Here's what i have:
+-----------------------+
| Parent 1 |
|-----------------------|
| dependencyManagement: |
| lib1: 1.0.0 |
+-----------------------+
^
|
|
+-----------+-----------+
| Parent 2 |
|-----------------------|
| dependencyManagement: |
| lib2: 1.0.0 |
+-----------------------+
^
|
+-----------+-----------+
| Project A |
|-----------------------|
| dependencies: |
| lib1 |
| lib2 |
+-----------------------+
When i try to mvn install Project A, i get:
[ERROR] 'dependencies.dependency.version' for lib1-digester:jar is missing. # line XX, column YY
I also tried to add an entry of Parent 1 in the dependencyManagement of Parent 2 with the import scope, with no success..
How can my Project A have versions managed by all it's parent hierarchy?
It seems you are correct after reading the Maven Docs.
In general, all dependencies of those projects are used in your project, as are any that the project inherits from its parents, or from its dependencies, and so on.
Try to update to the latest version of Maven 3. IIRC, there were a couple of bugs in the inheritance of dependencyManagement elements.
A made a small example with other empty projects, and everything went fine...
Finally, there was something strange, here's what happened.
I was actually more like that:
+-----------------------+
| Parent 1 |
|-----------------------|
| dependencyManagement: |<----------------------+
| lib1: 1.0.0 | |
+-----------------------+ |
^ |
| +-------------+------------+
| | Project B |
+-----------+-----------+ |--------------------------|
| Parent 2 | | dependencies: |
|-----------------------| | somethingWrong: 1.0.0 |
| dependencyManagement: | +--------------------------+
| lib2: 1.0.0 |
+-----------------------+
^
|
+-----------+-----------+
| Project A |
|-----------------------|
| dependencies: |
| lib1 |
| lib2 |
+-----------------------+
There was an error in Project B's pom.xml
It shouldn't have any impact on my problem, but correcting that unrelated pom solved my problem...
Sorry for the wasted time

Categories