我使用liquibase更新数据库。
我的文件changelog-master.xml包含:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<includeAll path="/src/main/resources/DBChangeLog/DDL/"/>
</databaseChangeLog>
在resource / src / main / resources / DBChangeLog / DDL /我有一个带有脚本MS SQL的文件:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CONFIG]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CONFIG](
[ID] [bigint] NOT NULL,
[DESCRIPTION] [varchar](255) NOT NULL,
[OPERATOR] [XML] NOT NULL
CONSTRAINT [PK_CONFIG] 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 [DATA]
) ON [DATA]
END
GO
SET ANSI_PADDING OFF
GO
当我运行maven命令时收到错误:mvn liquibase:update
ERROR:
src\main\resources\DBChangeLog\DDL\V2_20_0_0008__test.sql::raw::includeAll failed. Error: Incorrect syntax near 'GO'. [Failed SQL: SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CONFIG]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[CONFIG](
[ID] [bigint] NOT NULL,
[DESCRIPTION] [varchar](255) NOT NULL,
[OPERATOR] [XML] NOT NULL
CONSTRAINT [PK_CONFIG] 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 [DATA]
) ON [DATA]
END
GO
SET ANSI_PADDING OFF
GO]
是否可以运行典型的MS SQL脚本或liquibase会有问题吗?
答案 0 :(得分:2)
查看此页面:http://www.liquibase.org/documentation/changes/sql.html for endDelimiter和splitStatements参数。