# Version SVN: $Id: 50_blogs_schema.yml 2523 2013-10-10 10:46:51Z sven.poeche $
propel:
  blog:
    _attributes:            { phpName: Blog, allowPkInsert: true }
    blogid:                 { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    uid:                    { type: integer, size:  11, required: true }
    status:                 { type: integer, size:  11, required: true, default: 0 } # 0=created, 1=verify, 2=illegal, 3=legal, 4=deleted
    title:                  { type: varchar, size: 255, required: true }
    teaser:                 { type: longvarchar, required: true }
    text:                   { type: longvarchar, required: true }
    sum_rating:             { type: float,   size:   8, scale: 2, required: true, default: 0.00 } # sums up blog_rating table
    sum_likes:              { type: integer, size:  11, required: true, default: 0 } # sums up blog_like table
    count_views:            { type: integer, size:  11, required: true, default: 0 } # sums up blog_view table
    count_rating:           { type: integer, size:  11, required: true, default: 0 } # sums up blog_rating table
    count_likes:            { type: integer, size:  11, required: true, default: 0 } # sums up blog_like table
    count_favorites:        { type: integer, size:  11, required: true, default: 0 } # sums up all user favorites by using blog_favorite table
    count_comments:         { type: integer, size:  11, required: true, default: 0 } # sums up blog_comment table
    updated_by_user:        { type: varchar, size:  40, required: false }
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      blog_fk_uid:          { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      blog_i_uid:           [uid]


  blog_tag:
    _attributes:                { phpName: BlogTag, allowPkInsert: true }
    blogid:                     { type: integer, size:  11, required: true, primaryKey: true }
    tid:                        { type: integer, size:  11, required: true, primaryKey: true }
    pos:                        { type: integer, size:   3, required: true }
    _foreignKeys:
      bt_fk_blogid:             { foreignTable: blog, references: [ {local: blogid, foreign: blogid} ] }
      bt_fk_tid:                { foreignTable: tag, references: [ {local: tid, foreign: tid} ] }
    _indexes:
      bt_i_blogid:              [blogid]
      bt_i_tid:                 [tid]


  blog_rating:
    _attributes:                { phpName: BlogRating, allowPkInsert: true }
    blogid:                     { type: integer, size:  11, required: true, primaryKey: true }
    uid:                        { type: integer, size:  11, required: true, primaryKey: true }
    hostname:                   { type: varchar, size: 255, required: ture, primaryKey: true }
    rating:                     { type: integer, size:   3, required: true }
    created_at:                 { type: timestamp, required: true, primaryKey: true }
    updated_at:                 { type: timestamp, required: true }
    _foreignKeys:
      br_fk_blogid:             { foreignTable: blog, references: [ {local: blogid, foreign: blogid} ] }
      br_fk_uid:                { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      br_i_blogid:              [blogid]
      br_i_uid:                 [uid]


  blog_like:
    _attributes:                { phpName: BlogLike, allowPkInsert: true }
    blogid:                     { type: integer, size:  11, required: true, primaryKey: true }
    uid:                        { type: integer, size:  11, required: true, primaryKey: true }
    hostname:                   { type: varchar, size: 255, required: ture, primaryKey: true }
    like:                       { type: integer, size:   3, required: true }
    created_at:                 { type: timestamp, required: true, primaryKey: true }
    updated_at:                 { type: timestamp, required: true }
    _foreignKeys:
      bl_fk_blogid:             { foreignTable: blog, references: [ {local: blogid, foreign: blogid} ] }
      bl_fk_uid:                { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      bl_i_blogid:              [blogid]
      bl_i_uid:                 [uid]


  blog_comment:
    _attributes:            { phpName: BlogComment, allowPkInsert: true }
    bcid:                   { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    blogid:                 { type: integer, size:  11, required: true }
    pid:                    { type: integer, size:  11, required: true, default: 0 }
    uid:                    { type: integer, size:  11, required: true }
    ano_username:           { type: varchar, size: 255 }
    text:                   { type: longvarchar, required: true }
    status:                 { type: integer, size:  11, required: true, default: 0 } # 0=created, 1=verify, 2=illegal, 3=legal, 4=deleted
    updated_by_user:         { type: varchar, size:  40, required: false }
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      blogc_fk_blogid:      { foreignTable: blog, references: [ {local: blogid, foreign: blogid} ] }
      blogc_fk_uid:         { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      blogc_i_blogid:       [blogid]
      blogc_i_pid:          [pid]
      blogc_i_uid:          [uid]


  blog_view:
    _attributes:            { phpName: BlogView, allowPkInsert: true }
    bvid:                   { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    blogid:                 { type: integer, size:  11, required: true }
    uid:                    { type: integer, size:  11, required: true }
    sessid:                 { type: varchar, size: 128, required: true }
    hostname:               { type: varchar, size: 244, required: true }
    external:               { type: boolean, size:   1, required: true, default: false }
    external_url:           { type: varchar, size: 1024 }
    created_at:             { type: timestamp, required: true }
    _foreignKeys:
      bv_fk_blogid:         { foreignTable: blog, references: [ {local: blogid, foreign: blogid} ] }
      bv_fk_uid:            { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      bv_i_blogid:          [blogid]
      bv_i_uid:             [uid]


  blog_favorite:
    _attributes:            { phpName: BlogFavorite, allowPkInsert: true }
    blogid:                 { type: integer, size:  11, required: true, primaryKey: true }
    uid:                    { type: integer, size:  11, required: true, primaryKey: true }
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      fb_fk_uid:            { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
      fb_fk_blogid:         { foreignTable: blog, references: [ {local: blogid, foreign: blogid} ] }
    _indexes:
      fb_i_uid:             [uid]
      fb_i_blogid:          [blogid]

