# Version SVN: $Id: 70_channels_schema.yml 5239 2017-05-17 13:18:18Z zoran.zatezalo $
propel:
  channel:
    _attributes:            { phpName: Channel, allowPkInsert: true, isI18N: true, i18nTable: channel_i18n }
    chid:                   { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    hidden:                 { type: boolean, size:   1, required: true, default: false } # channel is private, only channel users can see it
    verify:                 { type: boolean, size:   1, required: true, default: false } # channels users must verify by channel administrator
    upload:                 { type: boolean, size:   1, required: true, default: false }
    status:                 { type: integer, size:  11, required: true, default: 0 } # 0=created, 1=verify, 2=illegal, 3=legal, 4=deleted
    uid:                    { type: integer, size: 11, required: true }
    picture_filename:       { type: varchar, size: 255 }
    picture_menu_filename:  { type: varchar, size: 255 }
    font_color_title:       { type: varchar, size: 16, default '#000000' }
    font_color_content:     { type: varchar, size: 16, default '#000000' }
    notify_member:          { type: boolean, size:   1, required: true,  default: false }
    weight:                 { type: integer, size:  11, required: true, default: 0 }
    count_users:            { type: integer, size:  11, required: true, default: 0 }
    count_media:            { type: integer, size:  11, required: true, default: 0 }
    count_media_videos:     { type: integer, size:  11, required: true, default: 0 }
    count_media_photos:     { type: integer, size:  11, required: true, default: 0 }
    count_media_audios:     { type: integer, size:  11, required: true, default: 0 }
    count_media_documents:  { type: integer, size:  11, required: true, default: 0 }
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      ch_fk_uid:            { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      ch_i_uid:             [uid]
      ch_i_created_at:      [created_at]
      ch_i_status:          [status]
      ch_i_status_created:  [status, created_at]


  channel_i18n:
    _attributes:            { phpName: ChannelI18n, allowPkInsert: true }
    chid:                   { type: integer, size:  11, required: true, primaryKey: true }
    culture:                { type: varchar, size:   7, required: true, primaryKey: true, isCulture: true }
    name:                   { type: varchar, size: 255, required: true }
    description:            { type: longvarchar }
    _foreignKeys:
      chi_fk_chid:          { foreignTable: channel, references: [ {local: chid, foreign: chid} ] }
    _indexes:
      chi_i_chid:           [chid]
      chi_i_culture:        [culture]


  channel_user:
    _attributes:            { phpName: ChannelUser, allowPkInsert: true }
    chid:                   { type: integer, size: 11, required: true, primaryKey: true }
    uid:                    { type: integer, size: 11, required: true, primaryKey: true }
    rid:                    { 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
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      chu_fk_chid:          { foreignTable: channel, references: [ {local: chid, foreign: chid} ] }
      chu_fk_uid:           { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
      chu_fk_rid:           { foreignTable: role, references: [ {local: rid, foreign: rid} ] }
    _indexes:
      chu_i_chid:           [chid]
      chu_i_uid:            [uid]


  channel_media:
    _attributes:            { phpName: ChannelMedia, allowPkInsert: true }
    chid:                   { type: integer, size: 11, required: true, primaryKey: true }
    mid:                    { type: integer, size: 11, required: true, primaryKey: true }
    status:                 { type: integer, size:  11, required: true, default: 0 } # 0=created, 1=verify, 2=illegal, 3=legal, 4=deleted
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      chm_fk_chid:          { foreignTable: channel, references: [ {local: chid, foreign: chid} ] }
      chm_fk_mid:           { foreignTable: media, references: [ {local: mid, foreign: mid} ] }
    _indexes:
      chm_i_chid:           [chid]
      chm_i_mid:            [mid]


  channel_category:
    _attributes:            { phpName: ChannelCategory, allowPkInsert: true }
    chid:                   { type: integer, size:  11, required: true, primaryKey: true }
    cid:                    { type: integer, size:  11, required: true, primaryKey: true }
    _foreignKeys:
      chc_fk_chid:          { foreignTable: channel, references: [ {local: chid, foreign: chid} ] }
      chc_fk_cid:           { foreignTable: category, references: [ {local: cid, foreign: cid} ] }
    _indexes:
      chc_i_chid:           [chid]
      chc_i_cid:            [cid]


  channel_view:
    _attributes:            { phpName: ChannelView, allowPkInsert: true }
    chvid:                  { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    chid:                   { 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:
      chv_fk_chid:          { foreignTable: channel, references: [ {local: chid, foreign: chid} ] }
      chv_fk_uid:           { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      chv_i_chid:           [chid]
      chv_i_uid:            [uid]


