数据库迁移导致H2数据库错误

发布于 2025-02-09 02:48:36 字数 845 浏览 0 评论 0原文

当我运行测试时,以下迁移文件会导致

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "ALTER TABLE ACCOUNT
 ADD IS_PROVIDER_ROOT_ACCOUNT VARCHAR(1) NOT NULL,[*]
 ADD PROVIDER_ORGANISATION_ID VARCHAR(255) NULL"; SQL statement:
alter table account
 add is_provider_root_account varchar(1) not null,
 add provider_organisation_id varchar(255) null [42000-200]

错误

alter table account
 add is_provider_root_account varchar(1) not null,
 add provider_organisation_id varchar(255) null;

,如果我删除了任何一个添加,则没有错误。那我在这里该怎么办?

我的测试配置文件:

spring.datasource.url=jdbc:h2:mem:testdb:MODE=MYSQL
spring.datasource.username=sa
spring.datasource.password=secret
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true

When i run tests the following migration file causes an

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "ALTER TABLE ACCOUNT
 ADD IS_PROVIDER_ROOT_ACCOUNT VARCHAR(1) NOT NULL,[*]
 ADD PROVIDER_ORGANISATION_ID VARCHAR(255) NULL"; SQL statement:
alter table account
 add is_provider_root_account varchar(1) not null,
 add provider_organisation_id varchar(255) null [42000-200]

error

alter table account
 add is_provider_root_account varchar(1) not null,
 add provider_organisation_id varchar(255) null;

The thing is, if I remove any one of the adds there are no errors. So what can I do here?

My testing configuration file:

spring.datasource.url=jdbc:h2:mem:testdb:MODE=MYSQL
spring.datasource.username=sa
spring.datasource.password=secret
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑忘罢 2025-02-16 02:48:36

查看 h2 syntax (note parenthes)应该这样做:

alter table account
add (
    is_provider_root_account varchar(1) not null,
    provider_organisation_id varchar(255) null
);

Looking at the H2 syntax (note parentheses), when adding multiple columns, one should do:

alter table account
add (
    is_provider_root_account varchar(1) not null,
    provider_organisation_id varchar(255) null
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文