# Version SVN: $Id: 60_messsages_schema.yml 5876 2018-05-23 12:49:23Z boris.pupavac $
propel:
  message:
    _attributes:            { phpName: Message, allowPkInsert: true }
    meid:                   { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    uid:                    { type: integer, size:  11, required: true }
    recipient_uid:          { type: integer, size:  11, required: true }
    sender_uid:             { type: integer, size:  11, required: true }
    meaid:                  { type: integer, size:  11, required: false, default: null, onDelete: set null }
    read:                   { 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
    subject:                { type: varchar, size: 255, required: true }
    message:                { type: longvarchar, required: true }
    created_at:             { type: timestamp, required: true }
    _foreignKeys:
      me_fk_uid:            { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
      me_fk_recipient:      { foreignTable: user, references: [ {local: recipient_uid, foreign: uid} ] }
      me_fk_sender:         { foreignTable: user, references: [ {local: sender_uid, foreign: uid} ] }
      me_fk_meaid:          { foreignTable: message_attachment, references: [ {local: meaid, foreign: meaid} ] }
    _indexes:
      me_uid:               [uid]
      me_recipient:         [recipient_uid]
      me_sender:            [sender_uid]
      me_meaid:             [meaid]


  notification:
    _attributes:            { phpName: Notification, allowPkInsert: true }
    nid:                    { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    uid:                    { type: integer, size:  11, required: true }
    read:                   { 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
    subject:                { type: varchar, size: 255, required: true }
    message:                { type: longvarchar, required: true }
    created_at:             { type: timestamp, required: true }
    _foreignKeys:
      no_fk_uid:            { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
    _indexes:
      no_uid:               [uid]


  mail_template:
    _attributes:            { phpName: MailTemplate, allowPkInsert: true }
    mtid:                   { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    culture:                { type: varchar, size:   7, required: true }
    type:                   { type: varchar, size:  50, required: true }
    subject:                { type: varchar, size: 255, required: true }
    text:                   { type: longvarchar, required: true }
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _indexes:
      mt_i_culture:         [culture]
    _uniques:
      mt_u_template:        [type, culture]


  message_attachment:
    _attributes:            { phpName: MessageAttachment, allowPkInsert: true }
    meaid:                  { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    meid:                   { type: integer, size:  11, required: true }
    filename:               { type: varchar, size: 255, required: true }
    filesize:               { type: varchar, size: 255, required: true }
    created_at:             { type: timestamp, required: true }
    _foreignKeys:
      ma_fk_meid:           { foreignTable: message, references: [ {local: meid, foreign: meid} ] }
    _indexes:
      ma_meid:              [meid]
