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

Re : How to reference new change in xml file

$
0
0
You should be able to have nested nodes in the xsd namespace. It is basically a "I accept whatever" xsd.

Nathan

Re : CreateView and schema

Re : Seems like runOnChange or runAlways is default in 3.2.2

$
0
0
Hi Nathan, 

I appreciate the response in the extreme. 

The changeset was definitely re-executing though it's useful to know that this causes the validation errors as well. One thing we noticed, after changing the logging level to DEBUG, is that it looks like checksums are being calculated on the SQL and not the declarative statements, in particular alter table type changes, though, admittedly this is somewhat conjecture. We also had a couple versions of Liquibase reporting in. In one case we have 3.2.2, in another 3.1.1 and, in my system, ${project.version}. We've since rectified the version issues, on the assumption that any SQL generation changes you make in Liquibase will result in different checksums for the same changelog. 

That said, it's just not clear why the changelog runs again in some cases when EXECUTED is set, and the ID, AUTHOR and FILE have not changed. One thing we were wondering about is that our ID's are the name of the file, so have the .xml ending and wondering if that's causing problems with a regular expression or something. 

Thank you very much for any help you might have with this additional information. 

Sincerely, 

Tim

Re : Upgrading from 2.0.5 to 3.2.0 - Problem with preConditions ?

$
0
0
Thanks for the info, I'll look into it more. I'm working on a large refactorign of the snapshot/precondition logic for 3.3 that will hopefully improve things.

Nathan

Re : Collation support?

$
0
0
There is still nothing built in, although it would be possible to write an extension to support it. Since collation tends to be database-specific I probably won't put it in the main library, but the liquibase-mssql extension would be a good place for it.

For now, I'd suggest using <modifySql> on the original table definition to insert in the collation clause as needed.

Nathan

Re : Seems like runOnChange or runAlways is default in 3.2.2

$
0
0
Are the changes based on the SQL <sql> or <sqlFile> changes? Or are they <alterTable> and other changes?

The IDs matching the filenames shouldn't matter. They are just treated as strings in liquibase.

Nathan

Re : Seems like runOnChange or runAlways is default in 3.2.2

$
0
0
Hi Nathan, 

Below is a 'sanitized' changelog that was re-running every time. The databasechangelog showed this as "EXECUTED" and the filename/author/id had not changed. It just fails on subsequent runs with duplicate constraint violations. 

Thanks very, very much for any light you can shed...

    
    <changeSet id="V4_TA1111_AMeaningfulNameHasBeenChanged.xml" author="twalker">
        <insert schemaName="MYSCHEMA" tableName="MY_TABLE">
            <column name="NAME" value="Something" />
            <column name="DESCRIPTION" value="Something" />
            <column name="GROUP_TYPE" value="Something" />
        </insert>
        <insert schemaName="MYSCHEMA" tableName="MY_TABLE">
            <column name="NAME" value="Something Else" />
            <column name="DESCRIPTION" value="Something Else" />
            <column name="GROUP_TYPE" value="Something Else" />
        </insert>
    </changeSet> 
</databaseChangeLog>    

Re : Howto set/override changeset description

$
0
0
I understand @DatabaseChange when I run my tag the contents of @DatabaseChange.name wind up in the database changelog description.  What I want to do is place the change name and the value on 1 or 2 changeset parameters that were fed into my change.

addNotNullConstraint doesn't work with mysql

$
0
0
I use Liquibase 2.0.5,

here's snippet from my config:

  1.  <addNotNullConstraint columnDataType="VARCHAR(64)"
  2.                               columnName="permissions"
  3.                               defaultNullValue="ROLE_ADMIN"
  4.                               schemaName="users"
  5.                               tableName="apiTokens"/>
No errors or exceptions, but when I try to insert null into permissions column I receive:

ERROR 1048 (23000): Column 'permissions' cannot be null

- but I need null to be replaced with my default value.
Please help.
Thanks a lot in advance

Re : Generating Change Logs for Stored procedures, functions, packages and Triggers

$
0
0
Thank you Robert, Looking forward to hear from Nathan on his ideas.

modifySql ignoring isApplyToRollback() property (again?)

$
0
0
Using 3.1.1, 3.2.2 and the current 3.3.0-SNAPSHOT, I recently tried to have custom SQL appended to a create table statement but not to the associated rollback.  The custom SQL in the append element is appended to the rollback SQL regardless of whether applyToRollback is true or false on the modifySql element.

I put together a patch for this, but I figured I would take a look at Jira and see if it was currently a reported issue.  I see that it has been reported twice, once 5 years ago (https://liquibase.jira.com/browse/CORE-457), and again about 2 years ago (https://liquibase.jira.com/browse/CORE-1348).

The first time, a patch was submitted (which as near as I can tell, was virtually identical to what I was going to do - iterate over all the visitors and only pass the applyToRollback=true ones to the executor.execute() call in the rollback method of the ChangeSet.java class).  So, presumably this worked at some point.  Again, about 2 years ago this was reported (CORE-1348) but the comments indicated that this feature worked in the 3.x codebase and would not be back-ported to 2.x.

I looked through the history of the ChangeSet.java class on GitHub and I couldn't find a version of this file that contained the patch (or anything similar to it) from CORE-457.  Is it worth filing a new defect on Jira for this and submitting the patch I just put together, or was this functionality removed for a reason?  Should this functionality be implemented somewhere other than the rollback method of the ChangeSet.java file?

Any info anyone could provide would be most appreciated.

Daniel Morton

Re : modifySql ignoring isApplyToRollback() property (again?)

$
0
0
Ok... replying to my own post above... After a bit more digging I see that the AbstractJdbcDatabase.executeRollbackStatements contains the changes submitted as part of CORE-457.  However, that code path is only hit when custom rollback steps are not provided (only the Liquibase generated rollback steps will be executed).  When custom rollback steps are provided, the ExecutorService.execute method is called instead, which skips the code where the superfluous visitors are culled.

Unless there is a good reason why this should be the case, I will file a bug and submit a pull request to ensure that the applyToRollback attribute is respected in either execution path.

Regards,

Daniel Morton

Liquibase-mysql

$
0
0
liquibase is not working well with mysql-java-conector version 5.1.28

It is working with 5.1.18 version connector

issues i found with liquibase 3.2.2 and mysql-java-connector 5.1.28

-- trying to create tables even if they existed
-- columnExists precondition is not working.
-- running changeLog files with same ids

Microsoft Azure SQL DB - issue updating with a changelog xml file

$
0
0
Hi Guys,

I wanted to log this as a bug in Liquibase Jira but it would not allow me to create an account because my email address is an invalid domain.  When I run a changeLog XML file against a Microsoft SQL Server 2008 to create my database it works.  When I run that same changelog against a Microsoft Azure SQL Database it fails.

The failure has nothing to do with the changeSets in the changeLog XML file; it is failing when trying to insert a record into the "DATABASECHANGELOG" table.  That table does not have a clustered index (a requirement of all tables in a Microsoft Azure DB).  I noticed that the other liquibase table has a clustered primary key index "DATABASECHANGELOGLOCK", but the one giving the error does not.

Here is the error and my workaround:

liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Error executing SQL INSERT INTO [dbo].[DATABASECHANGELOG] ([ID], [AUTHOR], [FILENAME], [DATEEXECUTED], [ORDEREXECUTED], [MD5SUM], [DESCRIPTION], [COMMENTS], [EXECTYPE], [LIQUIBASE]) VALUES ('1408545942766-203', 'Me (generated)', '/Users/Me/Documents/eclipse_workspace/addynamo-scheduler/./dbchangelog-generated-live-fixed.xml', GETDATE(), 2, '7:652dfcadd409a0dadd415554341b75f0', 'createTable', '', 'EXECUTED', '3.2.2'): Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
    at org.private.service.ManageTestDatabase.ensureCreate(ManageTestDatabase.java:121)
    at org.private.scheduler.test.CreateAzureSchema.setUpBeforeClass(CreateAzureSchema.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: liquibase.exception.DatabaseException: Error executing SQL INSERT INTO [dbo].[DATABASECHANGELOG] ([ID], [AUTHOR], [FILENAME], [DATEEXECUTED], [ORDEREXECUTED], [MD5SUM], [DESCRIPTION], [COMMENTS], [EXECTYPE], [LIQUIBASE]) VALUES ('1408545942766-203', 'Clive (generated)', '/Users/Clive/Documents/eclipse_workspace/addynamo-scheduler/./dbchangelog-generated-live-fixed.xml', GETDATE(), 2, '7:652dfcadd409a0dadd415554341b75f0', 'createTable', '', 'EXECUTED', '3.2.2'): Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:112)
    at liquibase.changelog.StandardChangeLogHistoryService.setExecType(StandardChangeLogHistoryService.java:258)
    at liquibase.database.AbstractJdbcDatabase.markChangeSetExecStatus(AbstractJdbcDatabase.java:1068)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:50)
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:70)
    at liquibase.Liquibase.update(Liquibase.java:195)
    at liquibase.Liquibase.update(Liquibase.java:174)
    at org.private.service.ManageTestDatabase.ensureCreate(ManageTestDatabase.java:119)
    ... 17 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:792)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:689)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:662)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:310)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
    ... 26 more

Running this solves the problem:

  1. ALTER TABLE [dbo].[DATABASECHANGELOG] ADD CONSTRAINT [PK_DATABASECHANGELOG_ID] PRIMARY KEY CLUSTERED ([ID] ASC);

Liquibase Version: 3.2.2
SQL Driver: Microsoft sqljdbc4 (4.0)

Regards,
Seraph

NullPointerException when running generateChangeLog using MySQL and Liquibase 3.2.2

$
0
0
I am trying to generate a changeLog using an already existing database so I can begin using Liquibase from this point forward. When running the command 
  1. liquibase --changeLogFile=changelog.xml generateChangeLog
with the following liquibase.properties file
  1. driver: com.mysql.jdbc.Driver
  2. classpath: C:\\Program Files (x86)\\MySQL\\Connector J 5.1.30\\mysql-connector-java-5.1.30-bin.jar
  3. url: jdbc:mysql://localhost/adtest
  4. username: root
  5. password: ***********
  6. logFile: liquibase.txt
  7. logLevel:debug
I get "Unexpected error running Liquibase: java.lang.NullPointerException
The following is an excerpt from the log file
  1. INFO 8/25/14 1:40 PM: liquibase: changelog.xml does not exist, creating
  2. DEBUG 8/25/14 1:40 PM: liquibase: MissingObjectChangeGenerator type order:     liquibase.structure.core.Catalog    liquibase.structure.core.Schema    liquibase.structure.core.Sequence    liquibase.structure.core.StoredProcedure    liquibase.structure.core.Table    liquibase.structure.core.Column    liquibase.structure.core.PrimaryKey    liquibase.structure.core.UniqueConstraint    liquibase.structure.core.ForeignKey    liquibase.structure.core.Index    liquibase.structure.core.View
  3. SEVERE 8/25/14 1:40 PM: liquibase: java.lang.NullPointerException
  4. liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
  5. at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:139)
  6. at liquibase.integration.commandline.Main.doMigration(Main.java:904)
  7. at liquibase.integration.commandline.Main.run(Main.java:170)
  8. at liquibase.integration.commandline.Main.main(Main.java:89)
  9. Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
  10. at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
  11. at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:137)
  12. ... 3 more
  13. Caused by: java.lang.NullPointerException
  14. at liquibase.diff.output.changelog.core.MissingForeignKeyChangeGenerator.fixMissing(MissingForeignKeyChangeGenerator.java:43)
  15. at liquibase.diff.output.changelog.ChangeGeneratorChain.fixMissing(ChangeGeneratorChain.java:44)
  16. at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixMissing(ChangeGeneratorFactory.java:99)
  17. at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:147)
  18. at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:127)
  19. at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:73)
  20. at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:61)
  21. at liquibase.command.GenerateChangeLogCommand.run(GenerateChangeLogCommand.java:54)
  22. at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
  23. ... 4 more
Any help would be greatly appreciated

Need help with using Liquibase with Teradata 14

$
0
0
This is what I have been trying to run:

liquibase --driver=com.teradata.jdbc.TeraDriver --classpath=D:\Teradata\TeraJDBC__indep_indep.15.00.00.20\terajdbc4.jar  --changeLogFile=db.changelog.xml --url="jdbc:teradata://DEVBox" --username=dbadmin --password=password generateChangeLog

I get this error: Unexpected error running Liquibase: Unknown Reason

Thank you

Re : NullPointerException when running generateChangeLog using MySQL and Liquibase 3.2.2

$
0
0
Looking at the source code mentioned in the stack trace, I see this at liquibase.diff.output.changelog.core.MissingForeignKeyChangeGenerator.fixMissing(MissingForeignKeyChangeGenerator.java:43)

       change.setReferencedTableName(fk.getPrimaryKeyTable().getName());

The 'change' object is created in that method, so it cannot be null. The 'fk' object mentioned in that line is used in the line before, so it is also not null. That leaves just fk.getPrimaryKeyTable() as the possible null pointer. 

If I had to guess, I would say that somewhere in the database you are trying to generate a changelog for there is a foreign key that refers to a table that is not in the current schema or that the user connecting to the database does not have permissions for. But that is just a guess. 

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

Re : NullPointerException when running generateChangeLog using MySQL and Liquibase 3.2.2

$
0
0
Thanks for the input Steve. I completely agree with what you said, but I'm using the root account, so permissions shouldn't be an issue, and I just checked every restraint found in information_schema.table_constraints for the current schema and it refers to table that does exist (checked using SHOW TABLES)

I'm setting up the liquibase code in Eclipse now so I can step through the code to see exactly which fk object has the null pointer. I'm having a little trouble getting it running, but I'll be sure to report back here with what I find.

-Eddie

Re : NullPointerException when running generateChangeLog using MySQL and Liquibase 3.2.2

$
0
0
Ok, so I was able to track it down. It was a missing table. When I was checking I must have been matching to the wrong column, I thought I was checking the tables the foreign keys were referencing, but it turns out I was just checking the tables the foreign keys were on. 

Thanks again for your help Steve, I really appreciated it.

Liquibase api core log messages not printing

$
0
0

I am working in the liquibase core jar maven for doing the changes in my database. I want to print the Log that was generated in Liquibase core api to my own console.

I am executing the Liquibase as a maven plugin. When i execute it the logs from the maven plugin is displayed, the Plugin inturn calls the main method of the Liquibase API,the logs from that API is not printed to my console.

1.I am running the liquibase from the liquibase core API and executed using below sample for tag.

 baseDir = mavenProjectInfo.getBaseDir(); List<String> liquibaseargs = new ArrayList<String>(); log.info("******* Invoking liquibase Tag command *******"); Map<String, String> configs = MojoUtil.getAllValues(configuration); liquibaseargs.add(LIQUIBASE_DRIVER + getDriverName(configs.get(DBTYPE))); liquibaseargs.add(LIQUIBASE_URL + dbURLConstruction(configs.get(HOST), configs.get(PORT), configs.get(DBNAME), configs.get(DBTYPE))); liquibaseargs.add(LIQUIBASE_USERNAME + configs.get(USERNAME)); liquibaseargs.add(LIQUIBASE_PASSWORD + configs.get(PASSWORD)); liquibaseargs.add(TAG); liquibaseargs.add(configs.get(DBTAG)); String liquibasearguments[] = liquibaseargs .toArray(new String[liquibaseargs.size()]); Main.main(liquibasearguments); when i execute the Above the tag will be put on my database.

2.I am using the seperate console for my application, that will print all the log of the operations performed through the UI.

3.I want to print the sucessful or notsucessful of the tag. But using the above API will print only in the command prompt console.

Viewing all 2993 articles
Browse latest View live