2017-09-20 26 views
0

我需要在postgreSQL中爲創建日期和更新日期創建一個字段。下面 是我的陽明代碼關於更新不能在symfony yml中使用postgresql

table: test 
id: 
    testId: 
     type: test_id 
     column: test_id 

    fields: 
    name: 
     type: string 
     unique: true 
    active: 
     type: boolean 
     column: is_active 
     options: 
     default: 1 
    created: 
     type: datetime 
     column: created_at 
     notnull: true 
     columnDefinition: TIMESTAMP DEFAULT CURRENT_TIMESTAMP 
    modified: 
     type: datetime 
     column: modified_at 
     notnull: true 
     columnDefinition: TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 

以下錯誤更新架構

[Doctrine\DBAL\Exception\SyntaxErrorException]

An exception occurred while executing 'ALTER TABLE test ADD modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP':
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "ON"

LINE 1: ...D modified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE ...

回答

1

當我想你的問題是你的屬性的定義,嘗試創建/調用的symfony的lifeCycleCallback營造發生預更新功能來更新您的修改後的屬性。

我希望它能幫助你。