mengweijin / db-migration

Flyway、Liquibase 扩展支持达梦(DM)数据库、南大通用(GBase 8s)数据库,并支持 Flowable 工作流。
https://home.aday.fun
Apache License 2.0
21 stars 4 forks source link

使用flyway时,遇到权限问题,请问是不是不支持达梦数据库的普通用户? #5

Closed extendswind closed 5 months ago

extendswind commented 5 months ago

版本:

使用非管理员用户,报错 Caused by: dm.jdbc.driver.DMException: No select privilege on object [SYS.DBA_SEGMENTS]

具体错误信息如下:


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException: Unable to check whether schema "TTH" is empty
---------------------------------------------
SQL State  : 28000
Error Code : -5504
Message    : No select privilege on object [SYS.DBA_SEGMENTS]

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
    at dataExtraction.TTHWebApplication.main(TTHWebApplication.java:21) ~[classes/:na]
Caused by: org.flywaydb.core.internal.exception.FlywaySqlException: Unable to check whether schema "TTH" is empty
---------------------------------------------
SQL State  : 28000
Error Code : -5504
Message    : No select privilege on object [SYS.DBA_SEGMENTS]

    at org.flywaydb.core.internal.database.base.Schema.empty(Schema.java:68) ~[flyway-core-8.0.5.jar:na]
    at org.flywaydb.core.Flyway$1.execute(Flyway.java:138) ~[flyway-core-8.0.5.jar:na]
    at org.flywaydb.core.Flyway$1.execute(Flyway.java:124) ~[flyway-core-8.0.5.jar:na]
    at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:214) ~[flyway-core-8.0.5.jar:na]
    at org.flywaydb.core.Flyway.migrate(Flyway.java:124) ~[flyway-core-8.0.5.jar:na]
    at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66) ~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 18 common frames omitted
Caused by: dm.jdbc.driver.DMException: No select privilege on object [SYS.DBA_SEGMENTS]
    at dm.jdbc.driver.DBError.throwException(DBError.java:711) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.a.b.o.x(MSG.java:591) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.a.b.o.C(MSG.java:526) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.a.b.o.B(MSG.java:507) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.a.a.a(DBAccess.java:245) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.a.a.a(DBAccess.java:944) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.a.a.a(DBAccess.java:813) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.driver.DmdbPreparedStatement.executeInner(DmdbPreparedStatement.java:463) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.driver.DmdbPreparedStatement.do_executeQuery(DmdbPreparedStatement.java:568) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at dm.jdbc.driver.DmdbPreparedStatement.executeQuery(DmdbPreparedStatement.java:1587) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-4.0.3.jar:na]
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) ~[HikariCP-4.0.3.jar:na]
    at org.flywaydb.core.internal.jdbc.JdbcTemplate.queryForStringList(JdbcTemplate.java:83) ~[flyway-core-8.0.5.jar:na]
    at com.github.mengweijin.flyway.database.dm.DmSchema$ObjectType.getObjectTypeNames(DmSchema.java:724) ~[db-migration-dm-1.1.4.jar:na]
    at com.github.mengweijin.flyway.database.dm.DmSchema$ObjectType.supportedTypesExist(DmSchema.java:735) ~[db-migration-dm-1.1.4.jar:na]
    at com.github.mengweijin.flyway.database.dm.DmSchema.doEmpty(DmSchema.java:60) ~[db-migration-dm-1.1.4.jar:na]
    at org.flywaydb.core.internal.database.base.Schema.empty(Schema.java:66) ~[flyway-core-8.0.5.jar:na]
    ... 25 common frames omitted
mengweijin commented 5 months ago

@extendswind 目前的实现逻辑是这样的,需要有 DBA 权限才行。我闲了瞅瞅 Oracle 是怎么做的。

mengweijin commented 5 months ago

@extendswind 试试 1.1.5 版本。

extendswind commented 5 months ago

666,测试可以了,感谢~

mengweijin commented 5 months ago

@extendswind 又发了一版 1.1.6。1.1.5 Liquibase 有点小问题,flyway 不受影响。