#4532·apollo

Apollo 适配 PostgreSQL 数据库

作者: liutao5121创建于 2022年8月23日更新于 2026年8月28日
标签infotips

Apollo uses the following version: 1.5.1. The PostgreSQL driver has the following changes: 1. Modify the initialization SQL script (ApolloConfigDB.sql, ApolloPortalDB.sql). a. Modify the types of three fields as follows: IsDeleted smallint DEFAULT 0, IsAbandoned boolean DEFAULT false NOT NULL, IsPublic boolean DEFAULT false NOT NULL. b. PG indexes are global, and pay attention to index uniqueness (repeated indexes can be used by adding underscores and numbers to solve this problem). c. In SQL statements, table names and field names are not enclosed in double quotes or back quotes. d. Remove the (191) in the statement and replace it with an empty string. 2. The configuration in application-GitHub.propperties is as follows: 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. Add environment variable configuration in the startup script: -Duser.timezone=Asia/Chongqing 4. Modify the type of isDelete in the BaseEntity class to 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. Modify the fields with @lob in Item.java, Release.java, and Commit.java. Add @org.hibernate.annotations.Type(type = "org.hibernate.type.TextType") to the @lob annotation, for example: @Column(name = "value") @org.hibernate.annotations.Type(type = "org.hibernate.type.TextType") @Lob private String value;

内容来源: apolloconfig/apollo