Symfony 1.4 Doctrine 1 Yaml,无法定义默认的Timestamp值

时间:2013-06-20 08:05:12

标签: doctrine timestamp symfony-1.4 yaml doctrine-1.2

我一直在尝试为表格列 TIMESTAMP DEFAULT CURRENT_TIMESTAMP created_at设置 updated_at 默认值在我的 schema.yml 中,如post中所述。

系统信息:

  • Symfony 1.4.17 Doctrine 1
  • MySQL 5.6.10
  • PHP 5.4

仔细阅读columnDefinition documentation,但无法让它发挥作用。如文档中所述,应在列名称后面设置columnDefinition属性。在迁移数据库之后,columnDefinition中为这些列设置的默认值不会添加到MySQL数据库中。

经过测试,从type: timestamp更改为type: datetime,但 datetime 无法识别并运行迁移,显示错误消息。在文档中,有关时间戳类型的所有引用都显示它应声明为:timestamp

还测试了为这些列添加default值属性,但它仍未在MySQL中设置。

的schema.yml:

Tbmdtest005:
  connection: md_test
  columns:
    id:
      type: integer(8)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
  actAs:
    Timestampable:
      created:
        name: created_at
        columnDefinition: TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        default: CURRENT_TIMESTAMP
        type: timestamp
        format: Y-m-d H:i:s
        options:
          notnull: false
          required: false
      updated:
        name: updated_at
        columnDefinition: TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
        default: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
        type: timestamp
        format: Y-m-d H:i:s
        options:
          notnull: false
          required: false
迁移后在数据库中创建的

MySQL表: tbmdtest005

CREATE TABLE `tbmdtest005` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci

问题:

  • 我的schema.yml出了什么问题?
  • 请你提供一个有效的例子吗?

0 个答案:

没有答案