最近有客户反应liquibase经过pgoneproxy来管理数据库版本时,发现不能创建数据库表。这让我有点难理解,因而我直接下载了一个liquibase来测试,发现是pgoneproxy的权限管理的问题。如今说说测试的过程。sql
先从http://www.liquibase.org/网站下载对应的liquibase,加压后,在目录下有以下文件:数据库
liquibase.jar README.txt liquibase.spec liquibase.bat liquibase LICENSE.txt sdk lib
为了建立数据库表,先增长建立表的配置文件,配置文件的内容以下所示:安全
<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> <changeSet id="3" author="db_user"> <createTable tableName="bigaaa"> <column name="id" type="int" autoIncrement="true"> <constraints primaryKey="true" nullable="false"/> </column> <column name="firstname" type="varchar(50)"/> <column name="lastname" type="varchar(50)"> <constraints nullable="false"/> </column> <column name="state" type="char(2)"/> </createTable> </changeSet> </databaseChangeLog>
上面配置文件中,要求建立bigaaa表。在使用下面的命令来运行:bash
./liquibase --driver=org.postgresql.Driver --changeLogFile=db.changelog.xml --url=jdbc:postgresql://172.30.12.10:2000/pgbench --username=db_user --password=1234 --logLevel=debug --logFile=log.txt update
测试发现报错了:post
Unexpected error running Liquibase: ERROR: Access denied due to security policy, DDL disabled or DML restricted! [Failed SQL: CREATE TABLE public.databasechangeloglock (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITHOUT TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))]
看见错误后,知道是pgoneproxy的安全策略,致使建立表失败的。测试
在pgoneproxy中有--proxy-group-security=<servergroup:level>,--proxy-security-level=<level> --proxy-table-security=<table:level> 。其中后面两个安全策略都是默认状况下是没有设置的。而proxy_group_security默认状况下是设置为1的。不支持DDL。故须要在配置文件中增长--proxy-group-security=data0:0的配置。其中data0为组名称。网站