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

Re : Understanding Rollback

$
0
0
Can give a example of rollback with rollback<tag>,on command, 
thanks

Re : informix - performance - view generation - subselect

$
0
0
If you want to take a look at it, the general function is the class MissingViewChangeGenerator. This in turn uses CreateViewChange, CreateViewStatement, and CreateViewGenerator. The CreateViewGenerator seems to be where most of the SQL is generated. There is a special CreateViewGeneratorInformix that is just for Informix. 

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

Re : Understanding Rollback

$
0
0
Here are a few resources:

The Liquibase docs on rollback have a bit about what the rollback command means when you rollback using a tag:

“Roll Back To” Modes

You can specify what changes to rollback in three ways:

Tag

Specifying a tag to rollback to will roll back all change-sets that were executed against the target database after the given tag was applied. See the “command line” documentation for how to tag your database.

This StackOverflow answer shows how can include a database tag command in your changelogs:

http://stackoverflow.com/a/11869496/11051

This StackOverflow question also discusses rollback and tags, although it isn't clear from the question or the answer that you would have to do as described in the link above and use the tag database command somewhere in the changelogs or from the command line after deploying. As the answer above says, it is a better practice I think to include the tag database command in the changelog, so that it can't accidentally be forgotten.

http://stackoverflow.com/questions/4085600/liquibase-rolling-back-a-set-of-changesets

By the way, StackOverflow is a great resource for Liquibase questions. 

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

Re : Adding comments to changesets no longer works reliably

$
0
0
This is fixed for the upcoming 3.2.1 release. Planning on releasing it next week.

Nathan

Re : informix - performance - view generation - subselect

$
0
0
In the class CreateViewGeneratorInformix in the generateSql method there is the statement

  1. String createClause = "CREATE VIEW  " + viewName + " AS SELECT * FROM (" + statement.getSelectQuery() + ") AS v";
The problem is that the select query is inserted within the "AS SELECT * FROM (". So that first the hole table is loaded to execute the view.

Can anyone confirm this? Or am I wrong?

Use Liquidbase to create objects in empty database

$
0
0
Hi,

I am trying to use Liquibase to create objects in empty database.
Since we have quite a lot of objects I decided to split them into separate XML files based on
purpose of objects (security.xml, services.xml, datasources.xml etc).

My idea is that during the development the changes will always be written into appropriate XML file.

In each of these files I have changesets to create tables, add PK, add FK - the usual I think.

Now, when first XML starts to be executed, it will create tables and tries to add FK to tables that has not
been created yet, because they reside in another XML that has not been processed yet.

Is there any way how to solve this and still keep my setup ?

My idea would be to use <preconditions> to execute changeset that would create missing table before adding the FK.
Or maybe there is a way how to specify that one changeset has predecessors ?

Im really new to Liquibase and maybe I do it completely wrong :)

Thanks for any suggestions,
Zbynek

Re : informix - performance - view generation - subselect

Re : sqlFile tag not expanding placeholders


Re : Understanding Rollback

$
0
0
thank you very much! I think I have got it,I should define a tagDatabase. By the way, and is there a completed document of changeSet file? include insert,rollback,tagDatabase and so on.    

CURRENT_TIMESTAMP with mariadb

$
0
0
Hello,

I'm trying to replicate the next sql:
  1. CREATE TABLE IF NOT EXISTS lang (
  2.     lang_id INT NOT NULL AUTO_INCREMENT,
  3.     country VARCHAR(2) NOT NULL,
  4.     language VARCHAR(2) NOT NULL,
  5.     description VARCHAR(45) NOT NULL,
  6.     created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  7.     PRIMARY KEY (lang_id)
  8. );
But when I run liquibase updateSQL i'm getting NOW() instead of CURRENT_TIMESTAMP. Is this the expected behavior?

  1. <changeSet id="create table lang" author="fsousa">
  2.         <createTable tableName="lang">
  3.             <column name="lang_id" type="int" autoIncrement="true">
  4.                 <constraints primaryKey="true"/>
  5.             </column>
  6.             <column name="country" type="char(2)">
  7.                 <constraints nullable="false"/>
  8.             </column>
  9.             <column name="language" type="char(2)">
  10.                 <constraints nullable="false"/>
  11.             </column>
  12.             <column name="description" type="varchar(45)">
  13.                 <constraints nullable="false"/>
  14.             </column>
  15.             <column name="created" type="timestamp" defaultValueComputed="CURRENT_TIMESTAMP">
  16.                 <constraints nullable="false"/>
  17.             </column>
  18.         </createTable>
  19.     </changeSet>

  1. liquibase updatesql
  2. --  *********************************************************************
  3. --  Update Database Script
  4. --  *********************************************************************
  5. --  Change Log: master.xml
  6. --  Ran at: 7/16/14 12:19 AM
  7. --  Against: root@localhost@jdbc:mysql://localhost:3306/xxxx
  8. --  Liquibase version: 3.2.0
  9. --  *********************************************************************

  10. --  Lock Database
  11. --  Changeset translate.xml::create table lang::fsousa
  12. CREATE TABLE megan.lang (lang_id INT AUTO_INCREMENT NOT NULL, country CHAR(2) NOT NULL, language CHAR(2) NOT NULL, description VARCHAR(45) NOT NULL, created TIMESTAMP DEFAULT NOW() NOT NULL, CONSTRAINT PK_LANG PRIMARY KEY (lang_id));

  13. INSERT INTO megan.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('create table lang', 'fsousa', 'translate.xml', NOW(), 9, '7:14277505d1b016b84d087f4f542547a5', 'createTable', '', 'EXECUTED', '3.2.0');

  14. --  Release Database Lock
  15. Liquibase 'updatesql' Successful

Partial oracle packages updates

$
0
0

I’ve been using liquibase for a while now and often came across with the need to add/delete/update a single procedure/function part of an Oracle package.

The usual way we do it is to put the whole CREATE OR REPLACE PACKAGE/PACKAGE BODY into a separate file and run it as a separate liquibase change.

When there are a lot of precedures/functions included in that package not only that you end up with a big file to run but also it is a concern with the testing as in theory unintentional changes can slip inside that package.

 

You can argue that code review processes / unit tests should pick this up soon enough as they happen. However we all know that some may be support/maintenance packages that are not normally exercised by automatic builds.

 

I am aware that the only way to add/remove/update a function in an Oracle package is by using CREATE OR UPDATE PACKAGE/PACKAGE BODY.

 

However I was wondering whether there is something like providing only the procedure/function to ADD/UPDATE/DELETE in liquibase and liquibase will generate and run the CREATE OR UPDATE PACKAGE for us based on the current package definition taking from the database metadata.

 

Say using something like below:

SELECT dbms_metadata.get_ddl('PACKAGE_BODY',  ‘MY_PACKAGE’, 'SOME OWNER’) from dual INTO some_var

Then doing the right string manipulation and running it.

 

If this functionality is not supported yet I think it can be easily implemented as an oracle liquibase extension.

The reason I am suggesting an oracle liquibase extensionis because I am not sure how other database vendors deal with this sorts of updates.

 

I am just a liquibase user and never dag in liquibase internals but if this not supported yet and is considered needed, I have quite a bit of experience with java programming and I will volunteer to add support for it if considered useful. I just need some directions about the overall liquibase design to put the right code in the right place.

 

What the other liquibase users think.

 

Regards,

Julian

Liquibase attempting to load unrelated classes

$
0
0
I am using the Java Liquibase API with some deployment scripts written in Groovy. The groovy scripts and all dependencies are packaged together into a fat jar.

For some reason when we run this jar we get some weird errors. These do not block anything from happening. Everything works but we have tons of errors in the log where it looks like Liquibase is attempting to load the various groovy classes. We see multiple of the following error for each groovy class:

    [java] SEVERE 7/16/14 12:32 PM: liquibase: Cannot load class 'bounce.class' in classloader: sun.misc.Launcher$AppClassLoader@4af6ae1c.  Reason: java.lang.NullPointerException
    12:32:07      [java] java.lang.NullPointerException
    12:32:07      [java]     at liquibase.servicelocator.DefaultPackageScanClassResolver.loadClass(DefaultPackageScanClassResolver.java:337)
    12:32:07      [java]     at liquibase.servicelocator.DefaultPackageScanClassResolver.loadImplementationsInJar(DefaultPackageScanClassResolver.java:387)
    12:32:07      [java]     at liquibase.servicelocator.DefaultPackageScanClassResolver.findAllClasses(DefaultPackageScanClassResolver.java:226)
    12:32:07      [java]     at liquibase.servicelocator.DefaultPackageScanClassResolver.find(DefaultPackageScanClassResolver.java:116)
    12:32:07      [java]     at liquibase.servicelocator.DefaultPackageScanClassResolver.findImplementations(DefaultPackageScanClassResolver.java:84)
    12:32:07      [java]     at liquibase.servicelocator.ServiceLocator.findClassesImpl(ServiceLocator.java:202)
    12:32:07      [java]     at liquibase.servicelocator.ServiceLocator.findClasses(ServiceLocator.java:177)
    12:32:07      [java]     at liquibase.changelog.ChangeLogHistoryServiceFactory.<init>(ChangeLogHistoryServiceFactory.java:40)
    12:32:07      [java]     at liquibase.changelog.ChangeLogHistoryServiceFactory.getInstance(ChangeLogHistoryServiceFactory.java:20)
    12:32:07      [java]     at liquibase.changelog.ChangeLogHistoryServiceFactory$getInstance.call(Unknown Source)
    12:32:07      [java]     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    12:32:07      [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    12:32:07      [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    12:32:07      [java]     at com.derp.LiquidbaseRunner.hasliquibaseTables(LiquidBaseRunner.groovy:46)

Re : calculateCheckSum command

$
0
0
Hi Ijnelson,

thanks for adding this function.

It was needed to calculate some hashes without any interactions of db.

Some questions:
  • Why I had to add --changeLogFile? additionaly to the "someLogicalFilePathHere" in the part of the id?
  • Why I had to add the --url, --username and --password?

So only this command works:

  1. java -jar $LIQUIBASE_HOME/liquibase.jar --logLevel=debug --changeLogFile=ABSOLUTE_PATH_TO_PROJECT/database/liquibase/main-changelog.xml --driver=com.mysql.jdbc.Driver --classpath=$LIQUIBASE_HOME/lib/mysql-connector-java-5.1.15.jar --url="jdbc:mysql://127.0.0.1/dbname" --username=user  --password=pass calculateCheckSum ABSOLUTE_PATH_TO_PROJECT/database/liquibase/2.46.0/changelog.xml::v2.46.0_1::theAuthor

I did not cloned the git repo and checked the complete method but in my view it is not needed to add the url, username und password.


Cheers,

Steven

Re : changeset with multiple context

Re : Liquibase attempting to load unrelated classes

$
0
0
Liquibase's extension system scans the jar files for classes that could be used by Liquibase. There is a list of packages to look in, however, that should limit the search.

There was a fix in the upcoming 3.2.1 around fat jars that may help. It should be out by the end of the week. If you are still having errors, could you run with logLevel=debug and post the output?

Nathan

Re : Precondition to Check Whether Column is Nullable

$
0
0
There isn't a built-in precondition that will check that, but you could either use the <sqlCheck> precondition and query the metadata tables in the check, or write your own extension that can check nullability without needing a constraint name.  

liquibase.org/extensions has some documentation on writing an extension. The advantage with an extension is that then you don't need to keep writing the SQL in each precondition and can use the liquibase snapshot java APIs to get at the metadata without figuring out the SQL.

If you wanted to send a pull request for a new precondition in the main liquibase code, I would certainly look at incorporating it as well.

nathan

Re : DIFF - Getting "schemas equal" result for completely different schemas

$
0
0
What version of liqubase are you running? And can you run with --logLevel=DEBUG and post the output?

Nathan

Re : Liquibase Mysql Includes

$
0
0
If you submit it as a pull request, I can look at incorporating those changes into the main liquibase repository.

Nathan

Re : https://forum.liquibase.org wrong SSL certificate

$
0
0
The forum is hosted by zoho and out of my control. I think the problem is because you are accessing a custom domain (forum.liquibase.org) that is different than their SSL cert.

I'll see if there is anythign they can do about it.

Nathan

Re : CURRENT_TIMESTAMP with mariadb

$
0
0
With some testing, it appears that the maria support works just fine, they do a good job of pretending they are mysql. Even using a "jdbc:mariadb" URL with org.mariadb.jdbc.Driver.

So the issue you are seeing is actually expected behavior. Liquibase uses CURRENT_TIMESTAMP as a placeholder for "The current timestamp function on this database" which on mariadb is NOW() so it helpfully converts it for you.

Are you wanting to retain CURRENT_TIMESTAMP in your sql?

Nathan
Viewing all 2993 articles
Browse latest View live


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