2017-09-20 7 views
0

postgreSQLで作成日と更新日のフィールドを作成する必要があります。以下 は私のYMLコードエラーの下更新時に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を呼び出し/作成し、作成しようとしています変更されたプロパティを更新するための事前更新機能。

私はそれがあなたを助けてくれることを願っています。

関連する問題