# Version SVN: $Id: schema.yml 91 2013-08-11 10:10:26Z sven.poeche $
propel:
  _attributes:              { package: plugins.stNewsletterPlugin.lib.model }

  newsletter:
    _attributes:            { phpName: Newsletter, allowPkInsert: true }
    nlid:                   { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    status:                 { type: integer, size:  11, required: true, default: 0 } # 0=created, 1=active, 2=inactive,3=deleted
    name:                   { type: varchar, size: 255, required: true }
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }

  newsletter_issue:
    _attributes:            { phpName: NewsletterIssue, allowPkInsert: true }
    nliid:                  { type: integer, size:  11, required: true, primaryKey: true, autoIncrement: true }
    nlid:                   { type: integer, size:  11, required: true }
    status:                 { type: integer, size:  11, required: true, default: 0 } # 0=created, 1=in bearbeitung, 2=active, 3=in progress, 4=finished, 5=canceled, 6=deleted
    subject:                { type: varchar, size: 255, required: true }
    message_html:           { type: longvarchar, required: true }
    message_text:           { type: longvarchar, required: true }
    from_email:             { type: varchar, size: 255, required: true }
    from_name:              { type: varchar, size: 255, required: true }
    reply_email:            { type: varchar, size: 255, required: true }
    reply_name:             { type: varchar, size: 255, required: true }
    test_users:             { type: longvarchar, required: true } # Kommaseparierte liste mit Benutzernamen zum Testempfang
    last_receiver_id:       { type: integer, size:  11, required: true, default: 0 } # last user id during task
    count_send:             { type: integer, size:  11, required: true, default: 0 } # Anzahl gesendeter Newsletter
    execute_at:             { type: timestamp, required: true } # Zeitpunkt wann Versand angestossen werden soll
    started_at:             { type: timestamp } # Zeitpunkt wann Newsletterversand startete
    finished_at:            { type: timestamp } # Zeitpunkt wann Newsletterversand endete
    created_at:             { type: timestamp, required: true }
    updated_at:             { type: timestamp, required: true }
    _foreignKeys:
      ncn_fk_nlid:          { foreignTable: newsletter, references: [ {local: nlid, foreign: nlid} ] }

  newsletter_subscription:
    _attributes:            { phpName: NewsletterSubscription, allowPkInsert: true }
    nlid:                   { 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:
      un_fk_nlid:           { foreignTable: newsletter, references: [ {local: nlid, foreign: nlid} ] }
      un_fk_uid:            { foreignTable: user, references: [ {local: uid, foreign: uid} ] }
