# Version SVN: $Id: schema.yml 192 2014-02-19 17:05:36Z sven.poeche $
propel:
  _attributes:              { package: plugins.stAlbumPlugin.lib.model }

  album:
    _attributes:            { phpName: Album, allowPkInsert: true }
    aid:                    { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    albumtype:              { type: integer, size:  11, required: true } # 0=user, 1=group, 2=channel
    objectid:               { type: integer, size:  11, required: true }
    visibility:             { type: integer, size:  11, required: true, default: 0 } # 0=private, 1=friends, 2=all
    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 }
    description:            { type: longvarchar }
    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 }
    _indexes:
      a_i_album:            [albumtype, objectid]
      a_i_album_visibility: [albumtype, objectid, visibility]
      a_i_albumtype:        [albumtype]
      a_i_objectid:         [objectid]

  album_media:
    _attributes:            { phpName: AlbumMedia, allowPkInsert: true }
    aid:                    { type: integer, size:  11, required: true, primaryKey: true }
    mid:                    { type: integer, size:  11, required: true, primaryKey: true }
    weight:                 { type: integer, size:  11, required: true, default: 0 }
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      am_fk_aid:            { foreignTable: album, references: [ {local: aid, foreign: aid} ] }
      am_fk_mid:            { foreignTable: media, references: [ {local: mid, foreign: mid} ] }
    _indexes:
      am_i_aid:             [aid]
      am_i_mid:             [mid]
