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

Re : how can I run a set of changeSet in transaction

$
0
0
I was thinking in use the updateSQL to an output file, take this file and put it all in one single changeSet as sql.
But if i di't it, I'll lose all my preCondition.

Manual Script execution

$
0
0
Hi Team,

I have a scenario, where I ran few DMLs using Liquibase. My team created some manual script & execution using some SQL Editor. Later we integrated those scripts with liquibase and tries to re-run without rollback.

How can I identify the manually executed changes after the liquibase ran in the next Automated deployment.


Right now I am getting integrity constraint exception if I ran again. I want to automate the process to rollback to last liquibase state.

The liquibase.exception occurs during generateChangeLog when mssql constraint has comments

$
0
0
Hello

I created the TestDb on Microsoft SQL Server 2014, then I created the table
 
CREATE TABLE [dbo].[TestTable](
    [Id] [uniqueidentifier] NOT NULL,
    [Name] [nchar](10) NULL,
    [Number] [int] NULL,
 CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[TestTable] ADD  CONSTRAINT [DF_ConstraintName]  DEFAULT ('No name') FOR [Name]
GO

After that I create
CREATE DEFAULT [dbo].[DefaultZeroValue]
AS
0
GO

and did
EXEC sp_bindefault 'DefaultZeroValue', 'TestTable.Number';

After all this, I did
liquibase --defaultsFile="test.prop" generateChangeLog

and I got newchangelog.mssql.sql with content

--liquibase formatted sql

--changeset TestDb:1510256718974-1
CREATE TABLE [TestTable] ([Id] [uniqueidentifier] NOT NULL, [Name] [nchar](10) CONSTRAINT [DF_TestTable_Name] DEFAULT 'No name', [Number] [int] CONSTRAINT [DF_TestTable_Number] DEFAULT create default DefaultZeroValue
    as 0);

--changeset TestDb:1510256718974-2
ALTER TABLE [TestTable] ADD CONSTRAINT [PK_TestTable] PRIMARY KEY ([Id]);


But if I change the type of column Number from int to bit and do again sp_bindefault, then after executing
liquibase --defaultsFile="test.prop" generateChangeLog
I get the exception:

DEBUG 09.11.17 23:38: liquibase: Executing QUERY database command: SELECT CAST([ep].[value] AS [nvarchar](MAX)) AS [REMARKS] FROM [sys].[extended_properties] AS [ep] WHERE [ep].[class] = 1 AND [ep].[major_id] = OBJECT_ID(N'[dbo].[DATABASECHANGELOGLOCK]') AND [ep].[minor_id] = COLUMNPROPERTY([ep].[major_id], N'LOCKEDBY', 'ColumnId') AND [ep].[name] = 'MS_Description'
DEBUG 09.11.17 23:38: liquibase: Executing QUERY database command: SELECT CAST(value as varchar(max)) as REMARKS FROM sys.extended_properties WHERE name='MS_Description' AND major_id = OBJECT_ID('[dbo].[TestTable]') AND minor_id = 0
Unexpected error running Liquibase: liquibase.exception.DatabaseException: java.lang.NumberFormatException: For input string: "create default DefaultZeroValue  as 0"

SEVERE 09.11.17 23:38: liquibase: liquibase.exception.DatabaseException: java.lang.NumberFormatException: For input string: "create default DefaultZeroValue  as 0"
liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: java.lang.NumberFormatException: For input string: "create default DefaultZeroValue  as 0"
        at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:265)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1011)
        at liquibase.integration.commandline.Main.run(Main.java:188)
        at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: java.lang.NumberFormatException: For input string: "create default DefaultZeroValue  as 0"
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
        at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:263)
        ... 3 more
Caused by: liquibase.exception.DatabaseException: java.lang.NumberFormatException: For input string: "create default DefaultZeroValue  as 0"
        at liquibase.snapshot.jvm.ColumnSnapshotGenerator.addTo(ColumnSnapshotGenerator.java:129)
        at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:73)
        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:246)
        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:363)
        at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:385)
        at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:293)
        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:267)
        at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:80)
        at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:53)
        at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:28)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:150)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:139)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:219)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:141)
        at liquibase.command.GenerateChangeLogCommand.run(GenerateChangeLogCommand.java:45)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        ... 4 more
Caused by: java.lang.NumberFormatException: For input string: "create default DefaultZeroValue  as 0"
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.valueOf(Unknown Source)
        at liquibase.util.SqlUtil.parseValue(SqlUtil.java:142)
        at liquibase.snapshot.jvm.ColumnSnapshotGenerator.readDefaultValue(ColumnSnapshotGenerator.java:491)
        at liquibase.snapshot.jvm.ColumnSnapshotGenerator.readColumn(ColumnSnapshotGenerator.java:273)
        at liquibase.snapshot.jvm.ColumnSnapshotGenerator.addTo(ColumnSnapshotGenerator.java:123)
        ... 20 more


For more information, use the --logLevel flag

Please, help

Re : Future of Liquibase?

$
0
0

Hi,


It's always great to hear from people who find value in and who are actively using Liquibase. I can take a moment to provide some updates regarding the future plans for Liquibase.


To be fully transparent, as of late, I’ve been very committed to other projects and have not been able to make time to contribute to Liquibase. This isn’t how I want things to go, and I agree that updates on Liquibase are overdue. To directly address your question, we do have a plan to push out a release that includes a number of high value pull requests that are currently sitting in review. In all honesty, this is something that will be out early next year (likely in January) as I simply don’t have many spare cycles right now. 


Going forward, I know that both myself and the broader team at Datical know we need to do more to keep the Liquibase project moving forward. It’s common for open source efforts to sometimes stagnate or slow, but we certainly don’t want things to come to a halt. As such, you can expect more active maintenance and involvement than there has been of late.


In regards to the the Datical fork, it's not really a fork but simply a branch which will get merged in when I get a chance to make sure it is does not include any changes that will adversely affect other Liquibase users. It will be brought in as part of the 3.6 release.


Lastly, we are spending some time thinking about how we can add more committers to the Liquibase project. When I do get busy, I don’t want to continue to be the sole bottleneck to progress on this project. I don’t have a vetted strategy yet, but I’d look to active, engaged members from the user community to step up and serve as committers. The DBManul merge was a good example of this where a community member was able to go through the work of testing and integrating a large set of pull requests that I was able to bring in a bundle. That was very helpful, but we need something more consistent and organized. As the project and community has grown over the years it has become well past time that I found ways to scale process of accepting pull requests.


Thanks again for being an active user for all these years. I appreciate you sticking with this project, and I hope that you (and others that a part of the Liquibase community) remain with us as we bring development of Liquibase back to a more predictable pace. 


Nathan

 

 

Re : Future of Liquibase?

$
0
0
Nathan,

Thanks so much for the thoughtful and thorough reply! 

This is just the type of transparency I was hoping for - and it clears up any doubts I had about the viability of continuing to use Liquibase. Clearly you and the Datical team understand the present pain points and plan to address both the short term (a new release with important PRs) and the more long term (growing the team with approval permissions) issues. 

Again, I (and the community) appreciate the all the work you've done over the years and I look forward to continuing to use Liquibase and to introduce it to new folks on future projects. 

Cheers, 

-Ben

Re : Future of Liquibase?

$
0
0
No problem, transparency is always the best approach. It's not the first time in the life of Liquibase where I've been not able to keep up with the project needs, but hopefully it will be the last time. 

I will try to take a look at some of the more straight forward pull requests over the next couple weeks, though, and merge in what I can.

Nathan

Running custom extension in Liquibase -element is not bounded

$
0
0

 

Hi,

 

I am trying to write new extension using Liquibase performing the following steps:

1-Download Liquibase core project and configure it using eclipse

2-Create new Java project called custom-Liquibase which is depending on Liquibase core project

3-Create the following hierarchy structure \liquibase-custom\src\liquibase\ext\Vacuum     (Taking this example from liqubase extension) Adding the following files:

                VacuumChange.java

VacuumPostgres.java

                VacuumStatement.java  

4- Create the following hierarchy structure liquibase-custom\src\liquibase\parser\core\xml

                dbchangelog-ext.xsd

                                                                <xsd:element name="vacuum">

                                   <xsd:complexType>

                                   <xsd:attribute name="tableName" type="xsd:string"/>

                                   </xsd:complexType>

      </xsd:element>

 

 5-create new custom jar from my project liquibase-custom.jar

 6-Adding the following change sets to my mail changelog.xml

                <changeSet id="1" author="nvoxland">

                                <createTable tableName="vacuumtest">

                                <column name="id" type="int"/>

                               <column name="name" type="varchar(50)"/>

                                </createTable>

      </changeSet>

 

    <changeSet id="2" author="nvoxland">

                  <vacuum:vacuum tableName="vacuumtest"/>

    </changeSet>

 

7-Run Liquibase in the following mode by adding the new liquibase-custom.jar to my classpath:

java -jar liquibase.jar  --driver=org.postgresql.Driver --classpath=lib/postgresql-42.1.4.jar;lib/liquibase-custom.jar --changeLogFile=sdk/workspace/changelog/com/example/changelog.xml --url="jdbc:postgresql://localhost:5432/Demo1" --username=postgres --password=1234 update

 

8-I am getting the error :

                Unexpected error running Liquibase: The prefix "vacuum" for element "vacuum:vacuum" is not bound.

 

 

 

I will be happy to know if I missing something in the above steps, or maybe I am not working properly in the way custom change should be written

 

Thanks

Spool file creation

$
0
0
Hi Team

do we have any way to capture DML spool outputs  and prompt outputs (like 3 rows inserted, 4 rows updated) using liquibase?



Liquibase 3.5 CORE-2553

$
0
0

does anyone know the syntax for disabling reorg statement when adding columns to a DB2 database tables (as described in liquibase v3.5 CORE-2553)


Re : Liquibase 3.5 CORE-2553

$
0
0
It somewhat depends on how you run liquibase - from the command line, via the maven plugin, or something else?

In each of the cases, you would set the property autoReorg to true or false. If you are running liquibase from the command line using liquibase.bat or liquibase.sh, you can either:
- add a Java system property to the command line: -Dliquibase.autoReorg=[true|false]
- set a property in a liquibase.properties file - I don't think you need the liquibase prefix in that case, just autoReorg=[false|true]

If you were using the maven plugin, you would set the property the same way you set other liquibase properties in the plugin. 

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

Cannot find database driver for Redshift

$
0
0
Trying to run the following command

java -jar scripts/liquibase-core-3.3.3.jar 

                  --username=root

                 --password="myfakepassword" 

                  --url=jdbc:redshift://<redshift_path>.amazonaws.com:5439/dev

          --changeLogFile=scripts/master.xml

                  --driver=lib/liquibase-redshift-1.0-SNAPSHOT.jar 

                  --classpath=lib/liquibase-redshift-1.0-SNAPSHOT.jar 

                  update


Getting error


 Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: lib/liquibase-redshift-1.0-SNAPSHOT.jar


I tried multiple options under https://github.com/liquibase/liquibase-redshift/releases but did not work . All of them give the same error. 


Is there something obvious I am missing?                        

Re : Cannot find database driver for Redshift

$
0
0
I haven't tried it, but usually you use the driver property to point to a JDBC driver class and not a jar containing it.
As the redshift repository does not contain such a class i would probably just try without the "--driver" switch and just put the liquibase-redshift.jar in the same folder as liquibase.jar (maybe the classpath is enough, but I'm not sure about that).

kind regards
Daniel

Does liquibase support PostgreSQL 10?

$
0
0
Hi,

Does liquibase 3.5 support support PostgreSQL 10?

mvn liquibase:generateChangeLog fails to generate the initial changelog.

liquibase.properties:
  1. url=jdbc:postgresql://localhost:5432/testdb
  2. driver=org.postgresql.Driver
  3. username=user
  4. password=pass

Error message:
  1. [ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:generateChangeLog (default-cli) on project test-project: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: Error getting jdbc:postgresql://localhost:5432/testdb view with liquibase.statement.core.GetViewDefinitionStatement@fe34b86: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@26bbe604 but got 0: Empty result set, expected one row -> [Help 1]

Database query and response:
  1. ERROR:  column i.indproc does not exist at character 610
  2. HINT:  Perhaps you meant to reference the column "i.indpred".

  3. SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM,  ct.relname AS TABLE_NAME, NOT i.indisunique AS NON_UNIQUE, NULL AS INDEX_QUALIFIER, ci.relname AS INDEX_NAME,  CASE i.indisclustered  WHEN true THEN 1 ELSE CASE am.amname  WHEN 'hash' THEN 2 ELSE 3 END  END AS TYPE,  a.attnum AS ORDINAL_POSITION,  CASE i.indpred WHEN 0 THEN a.attname ELSE ip.proname || '(' || ai.attname || ')' END AS COLUMN_NAME,  NULL AS ASC_OR_DESC,  ci.reltuples AS CARDINALITY,  ci.relpages AS PAGES,  NULL AS FILTER_CONDITION  FROM pg_class ct, pg_class ci, pg_attribute a, pg_am am, pg_attribute ai, pg_index i LEFT JOIN pg_proc ip ON (i.indpred = ip.oid)  WHERE ct.oid=i.indrelid AND ci.oid=i.indexrelid AND a.attrelid=ci.oid AND ci.relam=am.oid  AND ai.attnum = i.indkey[0] AND ai.attrelid = ct.oid  AND ct.relname = 'sql_sizing_profiles' ORDER BY NON_UNIQUE, TYPE, INDEX_NAME, ORDINAL_POSITION;

What is strange is that column pg_index.indproc was available in PostgresQL 7.3 (https://www.postgresql.org/docs/7.3/static/catalog-pg-index.html).
Can it be that liquibase fails to recognise PostgresQL 10 and falls back to some default logic? Although Pg 7.2 should be way too for any kind of support by liquibase.

Thanks,
Gin


Set search_path and not use public

$
0
0
I am running liquibase on Redshift and it looks like I need to have a specific command in my script to 

'set search_path to my_non_public_db'

otherwise, it basically creates everything in public. Hardcoding this statement in the liquibase gets around the problem , however, I want to try and not do it.

Tried the switches

 --defaultSchemaName=my_db  --defaultCatalogName=my_db


but did not help.


Any suggestions?


Liquibase spring weblogic support

$
0
0
Hi guys,

I created a modifies SpringLiquibase instance with the following modifications, because in weblogic the application can't find the selected classes in the zip file.

SpringResourceOpener:
      isPrefixPresent method: added
  1.  || file.matches("^.+:.+") 
to the list to catch other prefixes because classpath*: not recognized

modified ClassLoaderResourceAccessor list method:

The original contains these code:
  1.   if (!fileUrls.hasMoreElements() && (path.startsWith("jar:") || path.startsWith("file:"))) {
                fileUrls = new Vector<URL>(Arrays.asList(new URL(path))).elements();
            }
But this is wrong in weblogic... in weblogic it's start with zip: so the correct code is
  1.  if (!fileUrls.hasMoreElements() && (path.startsWith("jar:") || path.startsWith("file:")) || path.startsWith("zip:")) {
                    fileUrls = new Vector<>(Arrays.asList(new URL(path))).elements();
                }
(Suprise: in the while cycle the application watch the zip: prefix, but it's not added like a jar ;))


Still in the list method the jar file processing maybe wrong (especially in weblogic):
- When the path start jar, wsjar or zip liquibase try to find the files, but it's wrong. Here is the original code
  1.                 JarFile zipfile = new JarFile(zipFilePath, false);

                    try {
                        Enumeration<JarEntry> entries = zipfile.entries();
                        while (entries.hasMoreElements()) {
                            JarEntry entry = entries.nextElement();

                            if (entry.getName().startsWith(path)) {
Here the path is start with zip:.... or jar:....and the JarEntry.getName return the name inside of the jar.
example:

path =>  zip:C:/Oracle/Oracle_Home/user_projects/domains/test/servers/AdminServer/tmp/_WL_user/Gradle___hu_tsystems_molcc___molocc-backend-ear_ear_v20171124-1514/cw1bp9/war/WEB-INF/lib/hu.tsystems.molcc-molocc-interface-1.4.0-SNAPSHOT.jar!/META-INF/liquibase/

entry.getName() => META-INF/liquibase/

My solution:

  1.                     JarFile zipfile = new JarFile(zipFilePath, false);
                        String internalPath = zipAndFile[1];
                        try {
                            Enumeration<JarEntry> entries = zipfile.entries();
                            while (entries.hasMoreElements()) {
                                JarEntry entry = entries.nextElement();

                                if (("/"+entry.getName()).startsWith(internalPath)) {
Can you check this?

Thanks

mvn plugin not working

$
0
0
Hi guys
I´m trying to do a rollback for the very first time and i´m doing  via maven plugin with this command:
  1. liquibase:rollback -Dliquibase.rollbackTag=1.17
But maven responds me with this error:

  1. BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.516 s [INFO] Finished at: 2017-12-07T13:37:13-02:00 [INFO] Final Memory: 11M/155M [INFO] ------------------------------------------------------------------------ [ERROR] No plugin found for prefix 'liquibase' in the current project and in the plugin groups
  2. [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories
  3. [local (C:\Users\romulo\.m2\repository), central (https://repo.maven.apache.org/maven2)]
However i already inserted the plugin:
here´s my pom.xml:

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>PlayManager_LiquiBase</groupId>
    <artifactId>PlayManager_LiquiBase</artifactId>
    <version>1.7.0</version>
    <packaging>jar</packaging>

    <name>PlayManager_LiquiBase</name>
    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
    <dependency>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-core</artifactId>
    <version>3.4.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-maven-plugin -->
    <dependency>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.5.3</version>
    </dependency>

    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.38</version>
    </dependency>
    <dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>2.17</version>
    <type>maven-plugin</type>
    </dependency>
    </dependencies>

    <build>
    <plugins>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
    <source>1.8</source>
    <target>1.8</target>
    </configuration>
    </plugin>


    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
    <execution>
    <phase>package</phase>
    <goals>
    <goal>single</goal>
    </goals>
    </execution>
    </executions>
    <configuration>
    <archive>
    <manifest>
    <mainClass>liquibase.integration.commandline.Main</mainClass>
    </manifest>
    </archive>
    <descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
    <finalName>PlayManager_LiquiBase</finalName>
    <appendAssemblyId>false</appendAssemblyId>
    </configuration>
    </plugin>
    </plugins>

    </build>

    </project>
What i´m doing wrong?

Re : mvn plugin not working

$
0
0
Your problem is that you declared a dependency to the liquibase-maven-plugin and not the use of it.

You need to include the plugin in the <plugins> section and a <dependency> to the jdbc driver of your database.

This is not related to the rollback. Any other goal can not work this way too.

what is the default value for a column of type boolean which is nullable?

$
0
0
what is the default value for a column of type boolean which is nullable?

I assume it is null but just would like to check

Can we Hadoop Hive Database?

$
0
0
 Hi,
I'm new to Hadoop Hive, now I'm interfacing Hive PHP utilizing Apache thrift, its working great. Do I need to know where is the Hive Database record store on the server ? (Database document way). Would anybody be able to please help me, I need to exchange my tables to another server.

Thank u for helpful suggestions?

addAutoIncrement does not work on Liquibase 3.5.3 for Postgres

$
0
0
Hi guys,

I was using Liquibase 3.4.1 and wanted to use addAutoIncrement element. That didn't work and after investigating I found the issue related to core library (https://liquibase.jira.com/browse/CORE-2521). In the issue, itself is said that the bug is fixed with release 3.5.0. I first updated my core dependency to 3.5.3 (latest one) but the error was still there. After downgrading to 3.5.0. my auto increment was finally added to the database. 

Therefore, I think that it is possible that fix for CORE-2521 did not end on master branch but it was maybe just committed to 3.5.0 release branch and never moved to master (just throwing ideas, have no idea how are you doing your branching ). 

I didn't have time to check 3.5.1 and 3.5.2 versions...sorry! 


Hope that this info is useful.

P.S. Postgres version is 9.6

Cheers!




Viewing all 2993 articles
Browse latest View live


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