Quantcast
Channel: Liquibase Forums
Viewing all 1169 articles
Browse latest View live

Re : SpringBoot ptoject Rollback

$
0
0
No, your database would not get automatically rolled back to an earlier version. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Upload mysql dump into database

$
0
0
Hi.  I am using Liquibase in a Dropwizard java project with Gradle.  I have attempted to load a mysql dump via several different approaches, none of which have been successful.  I'd very much appreciate some guidance on how someone else managed to upload a sql dump.

... attempt 1
<sqlFile dbms="mysql" endDelimiter=";;" path="sql/schema-init.sql"/>


... attempt 2
<executeCommand executable="mysql">
<arg value="-u user"/>
<arg value="-password=password>"/>
<arg value="-h hostname"/>
<arg value="-P 3306"/>
<arg value="db schema name < ./sql/schema-init.sql"/>
</executeCommand>

.. attempt 3
<executeCommand
executable="../sql/init.sh"/>

attempt 1 was to run the mysqldump as a sql file.  It seems that Liquibase had too many issues with the way the sql dump tables were ordered. 

attempt 2 was to use an executeCommand.  The error returned was that the last arg cannot contain the < character needed by mysql to signify upload.

attempt 3 a last ditch attempt to point to a bash script to perform the upload for me
mysql -u hthu --password=password -h db.hthu.provata.app -P 3306 hthu-eligibility < ./schema-init.sql
it failed on account of not being able to see the bash file in the adjacent directory.  Can Liquibase not handle relative paths?
 Cannot run program "../sql/init.sh": error=2, No such file or directory



What's the proper way to conditionallly create a view?

$
0
0
I use derby and PostgreSQL and they have different syntaxes for aggregating over years and months ("YEAR(timestamp)" vs. "extract(year from timestamp) as year" (both result in a column name year or YEAR to be used in the query).

Derby do it this way:
  1. select sum(t.transaction_amount), YEAR(t.transaction_time), MONTH(t.transaction_time) from transactions t join transaction_types tt on tt.transaction_type_id=t.transaction_type_id join accounts a on a.account_id=t.account_id where tt.transaction_is_work and a.username=? group by YEAR(t.transaction_time), MONTH(t.transaction_time) order by YEAR(t.transaction_time), MONTH(t.transaction_time)
and PostgreSQL do it this way:
  1. select sum(t.transaction_amount), extract(year from t.transaction_time) as year, extract(month from t.transaction_time) as month from transactions t join transaction_types tt on tt.transaction_type_id=t.transaction_type_id join accounts a on a.account_id=t.account_id where tt.transaction_is_work and a.username=? group by extract(year from t.transaction_time), extract(month from t.transaction_time) order by extract(year from t.transaction_time), extract(month from t.transaction_time)
What's the best way to create a view conditionally based on the dbms used? 

Is there some kind of if-then-else logic? (I have googled, but haven't found)

The only way I can think about is to have two separate changesets for creating the same view with a precondition on the dbms used...?

Also, instead of selecting on dbms, I would have preferred to select on capability so that instead of creating a view just for derby I would create a view for all dbms'es that follow the same syntax (and ditto for PostgreSQL). Is this possible?

Re : What's the proper way to conditionallly create a view?

$
0
0

 
Also, instead of selecting on dbms, I would have preferred to select on capability so that instead of creating a view just for derby I would create a view for all dbms'es that follow the same syntax (and ditto for PostgreSQL). Is this possible?
Is it possible to eg. use sqlCheck and continue only if the SQL doesn't fail with a syntax error?

Show WARNING when executing dropAll as SYSTEM on oracle

$
0
0
Hi,

I'm not sure whether I'm not doing something wrong (only simple dev here) but trying to execute dropAll on connection with oracle SYSTEM results with nothing being dropped.

I did some digging and found out the there is a DIFF being calculated and on connection with oracle SYSTEM this always results in empty list (unexpectedObjects = 0).

This works just find on usual connections. Now I know using SYSTEM is extremely nasty but hey I work with what I get from admins....

If its easily possible it would be nice to print a WARNING, I have spent whole morning of debugging Liquibase internals to find out.

Thanks and keep the good job, Liquibase is awesome!
Zbynek

Re : What's the proper way to conditionallly create a view?

$
0
0
The suggestion to have two changesets with the two different definitions is what I would recommend. You can use multiple dbms names separated by commas to show that the changeset should apply to any in the list, and you can also use ! to indicate not - so you can do things like use dbms="postgresql" on one changeset and dbms="!postgresql" on another. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Re : Show WARNING when executing dropAll as SYSTEM on oracle

Re : Show WARNING when executing dropAll as SYSTEM on oracle


Re : Show WARNING when executing dropAll as SYSTEM on oracle

Re : What's the proper way to conditionallly create a view?

$
0
0
Thanks for the feedback!

I don't know which DBMSes that use the same syntax as derby...?  Maybe all/most of them, but "!postgresql" seems a bit drastic...? 

Will changing the dbms list in the precondition change the checksum of the changeset? Ie. can I add a dbms without breaking on installations that already have applied the changeset?

Re : What's the proper way to conditionallly create a view?

$
0
0

 
I don't know which DBMSes that use the same syntax as derby...?  Maybe all/most of them, but "!postgresql" seems a bit drastic...?  
(According to a bit of googling, MySQL and MSSQL use the same syntax as derby (or at least: looks very similar), while e.g. Oracle has a third variant. )

Re : What's the proper way to conditionallly create a view?

$
0
0
Change the dbms attribute will not affect the checksum of a changeset. This is also true for the labels and contexts attributes. 

Steve Donie
Principal Software Engineer
Liquibase Community Engagement
Datical, Inc. http://www.datical.com/

Liquibase maven plugin with JDK11 failing

$
0
0

I'm using Apache Maven 3.3.9 Java version: 11.0.5 And the latest version of liquibase-maven-plugin as follows:


   <plugin>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-maven-plugin</artifactId>
      <configuration>
         <changeLogFile>src\main\resources\changelog.yaml</changeLogFile>
         <driver>oracle.jdbc.OracleDriver</driver>
         <url>thin_url</url>
         <username>user</username>
         <password>password</password>
      </configuration>
   </plugin>        

I've added in my poml.xml the following dependencies

<dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.3.1</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-core</artifactId>
  <version>2.3.0.1</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.3.1</version>
</dependency>

but each time execute the plugin with mvn liquibase:update I've got an Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlElement exception.

Any clue what I'm doing wrong?

Edition Based Redefinition from Oracle and liquibase plugin 3.8.1

$
0
0
Hello

I would like to specify the edition from oracle, it means, before doing any change in the database I have to execute ALTER SESSION SET EDITION = <name_of_edition>. Is there any way to do this usin the liquibase-maven-plugin?
I'm using the latest version 3.8.1

I've tried to add an sql file to my path
   <changeSet author="liquibase-docs"
           id="createProcedure-testHello2">
       <createProcedure
            path="altersession1.sql">CREATE OR REPLACE PROCEDURE testHello2
                     IS
                     BEGIN
                        DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
                     END;
        </createProcedure>
    </changeSet>

I have the following error:
 Attribute 'path' is not allowed to appear in element 'createProcedure'


I've tried the same in yaml format, but it is not creating the stored procedure in the database, even though it seems to run properly.
Any clue how I can do this?

Thanks

Re : Liquibase maven plugin with JDK11 failing


Re : Edition Based Redefinition from Oracle and liquibase plugin 3.8.1

$
0
0

we've been able to solve it executing a first sqlFile changeset that executes ALTER SESSION SET EDITION = <name_of_edition>.

It looks like the connection is properly changed and that we're able to execute the changes in the proper version.


Re : Edition Based Redefinition from Oracle and liquibase plugin 3.8.1

$
0
0
Glad to hear. It sounded like you were having two separate issues. On the second issue (creating a procedure) I think your changeset is malformed. Not sure if Liquibase gave you an error message on that or not. I think there are two issues. The first issue is that you didn't specify a name, and the second issue is that you have both the path to a sql file as well as inline SQL - you should pick one or the other. 

Steve Donie
Principal Software Engineer
Liquibase Community Engagement
Datical, Inc. http://www.datical.com/

Re : Liquibase maven plugin with JDK11 failing

$
0
0
Thanks. I also answered and post the answer here as well, to avoid other people to make the same mistake as me .

I was adding the dependencies in the wrong place. I was adding them as 'regular' dependencies in the pom. I didn't know that I had to add them in the plugin as follows:

       <plugin>
          <groupId>org.liquibase</groupId>
          <artifactId>liquibase-maven-plugin</artifactId>
          <version>${liquibase.version}</version>
          <configuration>
             <changeLogFile>resources\changelog2.yml</changeLogFile>
             <driver>oracle.jdbc.OracleDriver</driver>
             <url>url</url>
             <username>user</username>
             <password>password</password>
             <verbose>true</verbose>
          </configuration>
           <dependencies>
            <dependency>
                <groupId>jakarta.xml.bind</groupId>
                <artifactId>jakarta.xml.bind-api</artifactId>
                <version>2.3.2</version>
            </dependency>
          </dependencies>
       </plugin>        

Re : Edition Based Redefinition from Oracle and liquibase plugin 3.8.1

$
0
0
Hello

You're right, we've been doing test using files in yaml, json and xml format. We had different error messages with the different formats. I'm completely new to liquibase and I didn't properly understand that I had either to use the path or the inline SQL, and from the error messages, I didn't get it right.

In any case, thanks for the answer, we've been able to solve our issue.
Elena



Re : Liquibase maven plugin with JDK11 failing

$
0
0
Excellent! Thanks for adding those details. 

Steve Donie
Principal Software Engineer
Liquibase Community Engagement
Datical, Inc. http://www.datical.com/
Viewing all 1169 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>