问题描述
我使用liquibase,并且想在我的xml文件(PostgreSQL)中创建枚举。
下面以创建新表的变更日志文件(仅文件的一部分)为例:
<?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-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="r3.3.0_table_creation_research_document "
author="anonim">
<createTable tableName="research_document">
<column name="id" type="bigint">
<constraints primaryKey="true"
primaryKeyName="research_document_pkey" nullable="false" />
</column>
我在Internet上找不到任何信息/示例!
解决方法
我认为liquibase本身不支持xml格式的postgres枚举。但是,由于在postgres中是可能的,因此您始终可以使用liquibase's formatted sql代替xml:
--liquibase formatted sql
--changeset ronak:1
CREATE TYPE mood AS ENUM ('sad','ok','happy');
CREATE TABLE person (
name text,current_mood mood
);
--rollback drop table person;