Re : Understanding Rollback
Re : informix - performance - view generation - subselect
Re : Understanding Rollback
“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
Re : informix - performance - view generation - subselect
- String createClause = "CREATE VIEW " + viewName + " AS SELECT * FROM (" + statement.getSelectQuery() + ") AS v";
Use Liquidbase to create objects in empty database
Re : informix - performance - view generation - subselect
Re : sqlFile tag not expanding placeholders
Re : Understanding Rollback
CURRENT_TIMESTAMP with mariadb
- CREATE TABLE IF NOT EXISTS lang (
- lang_id INT NOT NULL AUTO_INCREMENT,
- country VARCHAR(2) NOT NULL,
- language VARCHAR(2) NOT NULL,
- description VARCHAR(45) NOT NULL,
- created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (lang_id)
- );
- <changeSet id="create table lang" author="fsousa">
- <createTable tableName="lang">
- <column name="lang_id" type="int" autoIncrement="true">
- <constraints primaryKey="true"/>
- </column>
- <column name="country" type="char(2)">
- <constraints nullable="false"/>
- </column>
- <column name="language" type="char(2)">
- <constraints nullable="false"/>
- </column>
- <column name="description" type="varchar(45)">
- <constraints nullable="false"/>
- </column>
- <column name="created" type="timestamp" defaultValueComputed="CURRENT_TIMESTAMP">
- <constraints nullable="false"/>
- </column>
- </createTable>
- </changeSet>
- liquibase updatesql
- -- *********************************************************************
- -- Update Database Script
- -- *********************************************************************
- -- Change Log: master.xml
- -- Ran at: 7/16/14 12:19 AM
- -- Against: root@localhost@jdbc:mysql://localhost:3306/xxxx
- -- Liquibase version: 3.2.0
- -- *********************************************************************
- -- Lock Database
- -- Changeset translate.xml::create table lang::fsousa
- 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));
- 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');
- -- Release Database Lock
- Liquibase 'updatesql' Successful
Partial oracle packages updates
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
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
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:
- 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
Re : Precondition to Check Whether Column is Nullable
Re : DIFF - Getting "schemas equal" result for completely different schemas
Re : Liquibase Mysql Includes
Re : https://forum.liquibase.org wrong SSL certificate
Re : CURRENT_TIMESTAMP with mariadb
Nathan