使用 flyway - 如何部署内存优化表
Using flyway - How can memory optimized tables be deployed
我正在使用 Redgate 的 Flyway Community Edition 6.3.2 并尝试部署内存优化 table。
我的版本控制脚本的内容是...
CREATE TABLE temp_memory_optimized.test
(
id INT NOT NULL PRIMARY KEY NONCLUSTERED
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY);
GO
在部署时我看到这个错误...
ERROR: Migration of schema [dbo] to version 1.0.2 - add memory optimized objects failed! Changes successfully rolled back.
ERROR:
Migration v1.0.2__add_memory_optimized_objects.sql failed
---------------------------------------------------------
SQL State : S000109
Error Code : 12331
Message : DDL statements ALTER, DROP and CREATE inside user transactions are not supported with memory optimized tables.
Location : C:\...\v1.0.2__add_memory_optimized_objects.sql (C:\...\v1.0.2__add_memory_optimized_objects.sql)
Line : 1
Statement : CREATE TABLE temp_memory_optimized.test
(
id INT NOT NULL PRIMARY KEY NONCLUSTERED
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY);
MO 文件组配置正确,我可以成功手动部署到我的测试盒上。
我已经在迁移命令上设置了 -mixed=true
。
我知道我不是第一个遇到这个问题的人,但是互联网搜索在试图找到解决方案时被证明是徒劳的。
如 issue 2062 中所述,Flyway 未检测到
CREATE TABLE WITH MEMORY_OPTIMIZED = ON
在交易中自动无效。您将需要在每个脚本的基础上覆盖此行为,如下所述:https://flywaydb.org/documentation/scriptconfigfiles 并且需要对内存中对象上的每个 CREATE/ALTER/DELETE 执行此操作。
我正在使用 Redgate 的 Flyway Community Edition 6.3.2 并尝试部署内存优化 table。
我的版本控制脚本的内容是...
CREATE TABLE temp_memory_optimized.test
(
id INT NOT NULL PRIMARY KEY NONCLUSTERED
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY);
GO
在部署时我看到这个错误...
ERROR: Migration of schema [dbo] to version 1.0.2 - add memory optimized objects failed! Changes successfully rolled back.
ERROR:
Migration v1.0.2__add_memory_optimized_objects.sql failed
---------------------------------------------------------
SQL State : S000109
Error Code : 12331
Message : DDL statements ALTER, DROP and CREATE inside user transactions are not supported with memory optimized tables.
Location : C:\...\v1.0.2__add_memory_optimized_objects.sql (C:\...\v1.0.2__add_memory_optimized_objects.sql)
Line : 1
Statement : CREATE TABLE temp_memory_optimized.test
(
id INT NOT NULL PRIMARY KEY NONCLUSTERED
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY);
MO 文件组配置正确,我可以成功手动部署到我的测试盒上。
我已经在迁移命令上设置了 -mixed=true
。
我知道我不是第一个遇到这个问题的人,但是互联网搜索在试图找到解决方案时被证明是徒劳的。
如 issue 2062 中所述,Flyway 未检测到
CREATE TABLE WITH MEMORY_OPTIMIZED = ON
在交易中自动无效。您将需要在每个脚本的基础上覆盖此行为,如下所述:https://flywaydb.org/documentation/scriptconfigfiles 并且需要对内存中对象上的每个 CREATE/ALTER/DELETE 执行此操作。