# Schema.yml
propel:
  _attributes:                  { package: plugins.stMediaVersioningPlugin.lib.model }
  
  media_version:
    _attributes:                { phpName: MediaVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    mid:                        { type: integer, size:  11, required: true }
    uid:                        { type: integer, size:  11, required: true }
    mediakey:                   { type: varchar, size:  32, required: true }
    mediahash:                  { type: varchar, size: 128, required: true }
    mediatype:                  { type: integer, size:  11, required: true }
    mediasubtype:               { type: integer, size:  11, required: true }
    spritemap:                  { type: varchar, size: 255, required: true, default: null }
    spritemap_count:            { type: integer, size:  11, required: true, default: 0 }
    first:                      { type: boolean, size:   1, required: true, default: false }
    hidden:                     { type: boolean, size:   1, required: true, default: false }
    secret:                     { type: boolean, size:   1, required: true, default: false }
    status:                     { type: integer, size:  11, required: true, default: 0 }
    featured:                   { type: boolean, size:   1, required: true, default: false }
    culture:                    { type: varchar, size:   7, required: true }
    properties:                 { type: longvarchar, required: true }
    childwelfare:               { type: boolean, size:   1, reuqired: true, default: false }
    title:                      { type: varchar, size: 255, required: true }
    title_clean:                { type: varchar, size: 255, required: true }
    sid:                        { type: integer, size:  11 }
    duration:                   { type: integer, size:  11, required: true, default: 0 }
    filesize:                   { type: integer, size:  11, required: true, default: 0 } # filesize of original media file
    thumbnail_filename:         { type: varchar, size: 255 }
    thumbnail_custom_filename:  { type: varchar, size: 255 }
    source_filename:            { type: varchar, size: 255 }
    original_filename:          { type: varchar, size: 255 }
    scrambled_filename:         { type: varchar, size: 255 }
    server:                     { type: varchar, size: 255 }
    transcoder:                 { type: varchar, size: 255 }
    file_extension:             { type: varchar, size:   4, required: true }
    meta_title:                 { type: varchar, size: 255, required: false }
    meta_description:           { type: longvarchar, required: false }
    meta_keywords:              { type: longvarchar, required: false }
    meta_author:                { type: varchar, size: 255, required: false }
    meta_copyright:             { type: varchar, size: 255, required: false }
    conversion_notice:          { type: varchar, size: 255, required: false }
    sum_rating:                 { type: float,   size:   8, scale: 2, required: true, default: 0.00 }
    sum_likes:                  { type: integer, size:  11, required: true, default: 0 }
    count_views:                { type: integer, size:  11, required: true, default: 0 }
    count_views_embed:          { type: integer, size:  11, required: true, default: 0 }
    count_views_webtv:          { type: integer, size:  11, required: true, default: 0 }
    count_rating:               { type: integer, size:  11, required: true, default: 0 } 
    count_likes:                { type: integer, size:  11, required: true, default: 0 } 
    count_favorites:            { type: integer, size:  11, required: true, default: 0 } 
    count_comments:             { type: integer, size:  11, required: true, default: 0 } 
    count_flags:                { type: integer, size:  11, required: true, default: 0 } 
    accept_comment:             { type: boolean, size:   1, required: true, default: true }
    accept_rating:              { type: boolean, size:   1, required: true, default: true }
<?php if(stToolkit::moduleEnabled("youtubeExportFrontend")): ?>
    exported_to_youtube:        { type: boolean, size:   1, default:  false }
<?php endif; ?>
<?php if(stToolkit::moduleEnabled("paymentFrontend")): ?>
    price:                      { type: float,   size:   8, scale:       2,  required: false, default: 0.00 }
    with_costs:			{ type: boolean, size:   1, required: true,  default: false }
    preview_length:             { type: integer, size:  11, required: false, default: 0 }
<?php endif; ?>
    enable_download:            { type: boolean, size:   1, required: false, default: false }
    enable_download_for_users:  { type: boolean, size:   1, required: false, default: true }
    priority_transcode:         { type: boolean, size:   1, required: false, default: false }
    smil_exists:                { type: boolean, size:   1, required: false, default: false }
<?php if(stToolkit::moduleEnabled("itunesu")): ?>
    itunesu:                    { type: boolean, size:   1, required: false, default: false }
<?php endif; ?>
<?php if(stToolkit::moduleEnabled('cutVideoEditor')): ?>
    cutve_props:		  { type: longvarchar, required: false, before: is_cut }
    is_cut:		        { type: boolean, size:   1, required: false, default: false }
<?php endif; ?>
<?php if(stToolkit::moduleEnabled("mediaTimeBasedRelease")): ?>
    startdate:		        { type: timestamp }
    enddate:                    { type: timestamp } 
<?php endif; ?>  
    created_at:                 { type: timestamp, required: true }
    updated_at:                 { type: timestamp, required: true }
    uploaded_at:                { type: timestamp, required: true }
    converted_at:               { type: timestamp }
    
  media_category_version:
    _attributes:                { phpName: MediaCategoryVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true }
    mid:                        { type: integer, size:  11, required: true, primaryKey: true }
    cid:                        { type: integer, size:  11, required: true, primaryKey: true }
    _foreignKeys:  
      mcv_fk_mvid:              { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }
    
  media_chapter_version:
    _attributes:                { phpName: MediaChapterVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true }
    id:                         { type: integer, size:  11, required: true, primaryKey: true }
    mid:                        { type: integer, size:  11, required: true }
    language:                   { type: varchar, size: 128, required: true }
    title:                      { type: varchar, size: 128, required: true }
    time:                       { type: integer, size:  11, required: true }
    description:                { type: longvarchar }
    created_at:                 { type: timestamp, required: true }
    updated_at:                 { type: timestamp, required: true }
    _foreignKeys:
      mchv_fk_mvid:             { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }
    
  media_field_value_version:
    _attributes:                { phpName: MediaFieldValueVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true }
    mid:                        { type: integer, size:  11, required: true, primaryKey: true }
    mfid:                       { type: integer, size:  11, required: true, primaryKey: true }
    value:                      { type: longvarchar }
    created_at:                 { type: timestamp, required: true }
    updated_at:                 { type: timestamp, required: true }
    _foreignKeys:
      mfvv_fk_mvid:             { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }
    
  media_file_version:
    _attributes:                { phpName: MediaFileVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true }
    mfiid:                      { type: integer, size:  11, required: true, primaryKey: true }
    mid:                        { type: integer, size:  11, required: true }
    filetype:                   { type: varchar, size:  20, required: true }
    mfoid:                      { type: integer, size:  11, required: false, default: null }
    status:                     { type: integer, size:  11, required: true, default: 0 }
<?php if(stToolkit::moduleEnabled("paymentFrontend")): ?>
    preview:                    { type: boolean, size:   1, required: true, default: false }
<?php endif; ?>
    title:                      { type: varchar, size: 255, required: true }
    filename:                   { type: varchar, size: 255, required: true } 
    created_at:                 { type: timestamp, required: true }
    updated_at:                 { type: timestamp, required: true }
    converted_at:               { type: timestamp }
    _foreignKeys:
      mfv_fk_mvid:              { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }

  media_permission_version:
    _attributes:                { phpName: MediaPermissionVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true }
    mid:                        { type: integer, size:  11, required: true, primaryKey: true }
    rid:                        { type: integer, size:  11, required: true, primaryKey: true }
    _foreignKeys:
      mpv_fk_mvid:              { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }

  media_tag_version:
    _attributes:                { phpName: MediaTagVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true }
    mid:                        { 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:
      mtv_fk_mvid:              { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }
      
<?php if(stToolkit::moduleEnabled('youtubeImport')): ?>     
  media_youtube_version:
    _attributes:                { phpName: MediaYoutubeVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:   11, required: true, primaryKey: true }
    mid:                        { type: integer, size:   11, required: true, primaryKey: true }
    youtube:                    { type: varchar, size: 1024, required: true }
    id:                         { type: varchar, size:  255, required: true }
    title:                      { type: varchar, size:  255 }
    description:                { type: longvarchar }
    keywords:                   { type: longvarchar }
    thumbnail:                  { type: varchar, size: 1024 }
    url:                        { type: varchar, size: 1024 }
    duration:                   { type: integer, size:   11 }
    owner:                      { type: varchar, size:  255 }
    created_at:                 { type: timestamp, required: true }
    updated_at:                 { type: timestamp, required: true }
    related:                    { type: boolean, size:    1, required: true, default: false }
    _foreignKeys:
      myv_fk_mvid:              { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }  
<?php endif; ?>
  
<?php if(stToolkit::moduleEnabled('vimeoImport')): ?>    
  media_vimeo_version:
    _attributes:                { phpName: MediaVimeoVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:   11, required: true, primaryKey: true }
    mid:                        { type: integer, size:   11, required: true, primaryKey: true }
    vimeo:                      { type: varchar, size: 1024, required: true }
    id:                         { type: varchar, size:  255, required: true }
    title:                      { type: varchar, size:  255 }
    description:                { type: longvarchar }
    keywords:                   { type: longvarchar }
    thumbnail:                  { type: varchar, size: 1024 }
    url:                        { type: varchar, size: 1024 }
    duration:                   { type: integer, size:   11 }
    owner:                      { type: varchar, size:  255 }
    created_at:                 { type: timestamp, required: true }
    updated_at:                 { type: timestamp, required: true }
    _foreignKeys:
      mvv_fk_mvid:              { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }     
<?php endif; ?>
  
  statictext_version:
    _attributes:                { phpName: StaticTextVersion, allowPkInsert: true }
    mvid:                       { type: integer, size:  11, required: true, primaryKey: true }
    sid:                        { type: integer, size:  11, required: true, primaryKey: true }
    culture:                    { type: varchar, size:   7, required: true }
    title:                      { type: varchar, size: 255 } 
    content:                    { type: longvarchar, required: true } 
    created_at:                 { type: timestamp,   required: true }
    updated_at:                 { type: timestamp,   required: true }
    _foreignKeys:
      sv_fk_mv:                 { foreignTable: media_version, references: [ {local: mvid, foreign: mvid} ] }
