2017-02-23 83 views
0

我正在使用liquibase爲postgressql數據庫創建觸發器。下面是一個在此過程中詹金斯工作執行我使用liquibaseliquibase 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" 
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog 
     http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> 

    <changeSet id="1" author="yc14ik1"> 

     <createProcedure catalogName="cat" dbms="postgresql" 
      encoding="utf8" procedureName="UPDATE_LAST_ROW_CHG_TS()" relativeToChangelogFile="true" schemaName="sub"> 

      CREATE OR REPLACE FUNCTION UPDATE_LAST_ROW_CHG_TS() RETURNS trigger 
      LANGUAGE plpgsql 
      AS $$ 
      BEGIN 
       NEW.LAST_ROW_CHG_TS = NOW(); 
       RETURN NEW; 
      END; 
      $$; 

     </createProcedure> 


     <sql></sql> 
</changeSet> 

語法,我得到這個錯誤

Unexpected error running Liquibase: ERROR: language "plpgsql" does not exist 
    Hint: Use CREATE LANGUAGE to load the language into the database. [Failed SQL: CREATE OR REPLACE FUNCTION UPDATE_LAST_ROW_CHG_TS() RETURNS trigger 
      LANGUAGE plpgsql 
      AS $$ 
      BEGIN 
       NEW.LAST_ROW_CHG_TS = NOW(); 
       RETURN NEW; 
      END; 
      $$;] 


Build step 'Execute shell' marked build as failure 
Notifying upstream projects of job completion 
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered 

有一個人幫我,我怎麼能解決這個問題?

回答

0

我設置了我的不同,它工作得很好。

<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.1.xsd 
     http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> 
     <changeSet author="l" id="UPDATE_LAST_ROW_CHG_TS" runOnChange="true"> 
       <createProcedure catalogName="UPDATE_LAST_ROW_CHG_TS" 
         dbms="postgresql" 
         encoding="utf8" 
         path="../files/UPDATE_LAST_ROW_CHG_TS.sql" 
         procedureName="UPDATE_LAST_ROW_CHG_TS" 
         relativeToChangelogFile="true" 
         schemaName="public"></createProcedure> 
     </changeSet> 
</databaseChangeLog> 

從那裏你把所有的sql裏面的一個.sql文件中引用的路徑屬性。

我不知道你的方式不會工作,但對我來說,你有空的標籤底部似乎很奇怪。也許你的意思是爲了包裝你的sql函數?

反正我知道上面的例子將工作,如果liquibase配置和正常運行。