Open liutao5121 opened 2 years ago
Thanks for the information!
1、修改初始化sql脚本(ApolloConfigDB.sql、ApolloPortalDB.sql), a、修改3个字段的类型,如下: IsDeleted smallint DEFAULT 0 , IsAbandoned boolean DEFAULT false NOT NULL, IsPublic boolean DEFAULT false NOT NULL, b、pg索引是全局的,注意索引唯一性(重复的可以使用,下划线+数字 解决此问题) c、sql语句中表名和字段名全部不加双引号、反引号 d、去掉语句中的(191),直接替换为空
Is this change compatible with MySQL?
no, it's not mysql compatible, It's just for adapting to pgsql.Generally speaking,one application corresponds to one database. We only need to execute the corresponding initialization sql script.
apollo使用版本:1.5.1 postgreSQL驱动: `
适配改动主要有4个要点,描述如下: 1、修改初始化sql脚本(ApolloConfigDB.sql、ApolloPortalDB.sql), a、修改3个字段的类型,如下: IsDeleted smallint DEFAULT 0 , IsAbandoned boolean DEFAULT false NOT NULL, IsPublic boolean DEFAULT false NOT NULL, b、pg索引是全局的,注意索引唯一性(重复的可以使用,下划线+数字 解决此问题) c、sql语句中表名和字段名全部不加双引号、反引号 d、去掉语句中的(191),直接替换为空
2、application-github.propperties中的配置如下: spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect spring.datasource.driver-class-name = org.postgresql.Driver spring.jpa.properties.hibernate.globally_quoted_identifiers=false spring.jpa.hibernate.globally_quoted_identifiers=false spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false spring.datasource.hikari.connectionInitSql=
3、启动脚本中增加环境变量配置: -Duser.timezone=Asia/Chongqing
4、修改BaseEntity类里的isDelete的类型为int @Column(name = "IsDeleted", columnDefinition = "Bit default '0'") protected int deleted = 0; public int getDeleted() { return deleted; } public void setDeleted(boolean isDeleted) { deleted = (!isDeleted ? 0 : 1); }
5、修改Item.java 、Release.java、Commit.java 三个类中带有@lob的字段,在@lob注解处增加:@org.hibernate.annotations.Type(type = "org.hibernate.type.TextType"),例如: @Column(name = "value") @org.hibernate.annotations.Type(type = "org.hibernate.type.TextType") @Lob private String value;
完结。