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

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

Viewing all articles
Browse latest Browse all 2993

Trending Articles