somemo programming etc.

プログラマ、雑記、プログラミング関係はLinkから、数式はこっちでまとめていることが多い

【symfony】DBカラムとschema.ymlの対応【MySQL】

タイトル通りです。以下、テーブル作成文と、DBから作成したschema.ymlです。

対象外カラム

カラムはphpMyAdminにあるカラムを使用しましたが、以下のカラム(SPATIALグループ)は対象外です。

  • GEOMETRY
  • POINT
  • LINESTRING
  • POLYGON
  • MULTIPOINT
  • MULTILINESTRING
  • MULTIPOLYGON
  • GEOMETRYCOLLECTION

テーブル作成文

CREATE TABLE IF NOT EXISTS `test_table` (
  `tyny_int_test` tinyint(1) NOT NULL,
  `smallint_test` smallint(2) NOT NULL,
  `mediumint_test` mediumint(3) NOT NULL,
  `int_test` int(4) NOT NULL,
  `bigint_test` bigint(5) NOT NULL,
  `decimal_test` decimal(6,0) NOT NULL,
  `float` float NOT NULL,
  `double` int(8) NOT NULL,
  `real_test` double(1,0) NOT NULL,
  `bit_test` bit(1) NOT NULL,
  `boolean_test` tinyint(1) NOT NULL,
  `serial_test` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `date_test` date NOT NULL,
  `datetime_test` datetime NOT NULL,
  `timestamp_test` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `time_test` time NOT NULL,
  `year_test` year(4) NOT NULL,
  `char_test` char(5) NOT NULL,
  `varchar_test` varchar(10) NOT NULL,
  `tinytext_test` tinytext NOT NULL,
  `text_test` text NOT NULL,
  `mediumtext_test` mediumtext NOT NULL,
  `longtext_test` longtext NOT NULL,
  `binary_test` binary(25) NOT NULL,
  `varbinary_test` varbinary(30) NOT NULL,
  `tinyblob_test` tinyblob NOT NULL,
  `mediumblob_test` mediumblob NOT NULL,
  `blob_test` blob NOT NULL,
  `longblob_test` longblob NOT NULL,
  `enum_test` enum('1','2') NOT NULL,
  `set_test` set('one','two') NOT NULL,
  UNIQUE KEY `serial_test` (`serial_test`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

schema.yml

---
propel: 
  _attributes: 
    package: lib.model
  test_table: 
    _attributes: 
      idMethod: native
    tyny_int_test: 
      type: TINYINT
      required: true
    smallint_test: 
      type: SMALLINT
      required: true
    mediumint_test: 
      type: SMALLINT
      required: true
    int_test: 
      type: INTEGER
      required: true
    bigint_test: 
      type: BIGINT
      required: true
    decimal_test: 
      type: DECIMAL
      size: 6
      required: true
    float: 
      type: FLOAT
      required: true
    double: 
      type: INTEGER
      required: true
    real_test: 
      type: DOUBLE
      required: true
#    bit_test: 
#      type: 
#      required: true
    boolean_test: 
      type: TINYINT
      required: true
    serial_test: 
      type: BIGINT
      required: true
      autoIncrement: true
    date_test: 
      type: DATE
      required: true
    datetime_test: 
      type: TIMESTAMP
      required: true
    timestamp_test: 
      type: TIMESTAMP
      required: true
#      default: CURRENT_TIMESTAMP
    time_test: 
      type: TIME
      required: true
    year_test: 
      type: INTEGER
      required: true
    char_test: 
      type: CHAR
      size: 5
      required: true
    varchar_test: 
      type: VARCHAR
      size: 10
      required: true
    tinytext_test: 
      type: VARCHAR
      required: true
    text_test: 
      type: LONGVARCHAR
      required: true
    mediumtext_test: 
      type: LONGVARCHAR
      required: true
    longtext_test: 
      type: LONGVARCHAR
      required: true
#    binary_test: 
#      type: 
#      required: true
#    varbinary_test: 
#      type: 
#      required: true
    tinyblob_test: 
      type: BINARY
      required: true
    mediumblob_test: 
      type: VARBINARY
      required: true
    blob_test: 
      type: VARBINARY
      required: true
    longblob_test: 
      type: VARBINARY
      required: true
    enum_test: 
      type: CHAR
      required: true
    set_test: 
      type: CHAR
      required: true
    _uniques: 
      serial_test: 
        - serial_test

結果

bit、binary、varbinaryがタイプ無になりました。timestampのデフォルト値は、このままだとモデルが作成できませんでした。他のカラムはidMethodによると思いますが、このままつかえるのではないでしょうか。