<?php
   /*
     * $Id: schema.php 1004 2006-04-11 01:05:28Z rjl $
     *
     * MAIA MAILGUARD LICENSE v.1.0
     *
     * Copyright 2004 by Robert LeBlanc <rjl@renaissoft.com>
     *                   David Morton <mortonda@dgrmm.net>
     * All rights reserved.
     *
     * PREAMBLE
     *
     * This License is designed for users of Maia Mailguard
     * ("the Software") who wish to support the Maia Mailguard project by
     * leaving "Maia Mailguard" branding information in the HTML output
     * of the pages generated by the Software, and providing links back
     * to the Maia Mailguard home page.  Users who wish to remove this
     * branding information should contact the copyright owner to obtain
     * a Rebranding License.
     *
     * DEFINITION OF TERMS
     *
     * The "Software" refers to Maia Mailguard, including all of the
     * associated PHP, Perl, and SQL scripts, documentation files, graphic
     * icons and logo images.
     *
     * GRANT OF LICENSE
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * 1. Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * 3. The end-user documentation included with the redistribution, if
     *    any, must include the following acknowledgment:
     *
     *    "This product includes software developed by Robert LeBlanc
     *    <rjl@renaissoft.com>."
     *
     *    Alternately, this acknowledgment may appear in the software itself,
     *    if and wherever such third-party acknowledgments normally appear.
     *
     * 4. At least one of the following branding conventions must be used:
     *
     *    a. The Maia Mailguard logo appears in the page-top banner of
     *       all HTML output pages in an unmodified form, and links
     *       directly to the Maia Mailguard home page; or
     *
     *    b. The "Powered by Maia Mailguard" graphic appears in the HTML
     *       output of all gateway pages that lead to this software,
     *       linking directly to the Maia Mailguard home page; or
     *
     *    c. A separate Rebranding License is obtained from the copyright
     *       owner, exempting the Licensee from 4(a) and 4(b), subject to
     *       the additional conditions laid out in that license document.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
     * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
     * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */

$schema = array(
  'tables' => array(
        // users table
        'users' => array(
            'revision' => 1, // not used yet, but here's where it goes.
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "priority"          => array('type' => 'int','size' => '0', 'default' => '7', 'null' => false ),
                "policy_id"         => array('type' => 'uint','size' => '0','default' => '1', 'null' => false ),
                "email"             => array('type' => 'varchar', 'size' => '255','default' => '', 'null' => false ),
                "maia_user_id"      => array('type' => 'uint','size' => '0','default' => '','null' => false ),
                "maia_domain_id"    => array('type' => 'uint', 'size' => '0', 'default' => '', 'null' => false ),
            ),
            'indexes' => array(
                'PRIMARY'           => array( 'rows' => array( 'id' ), 'type' => 'primary'),
                'email'             => array( 'rows' => array( 'email' ), 'type' => 'unique'),
            ),
        ),
        // mailadddr table
        'mailaddr' => array(
            'revision' => 1,
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "priority"          => array('type'  =>  'int', 'size'  =>  '0','default' => '7','null'  =>  false),
                "email"             => array('type'  =>  'varchar', 'size'  =>  '255', 'default' => '','null'  =>  false),
            ),  
            'indexes' => array(
                'PRIMARY'                => array( 'rows' => array( 'id' ), 'type' => 'primary'),
                'email'             => array( 'rows' => array( 'email' ), 'type' => 'unique'),
            ),
        ),
        // wblist table 
        'wblist' => array(
            'tabledef' => array(
                'rid'               => array('type'  => 'uint', 'size' => '0', 'default' => '', 'null'  =>  false),
                'sid'               => array('type'  => 'uint', 'size' => '0', 'default' => '', 'null'  =>  false),
                'wb'                => array('type'  => 'char', 'size' => '1', 'default' => '', 'null'  =>  false),
            ),
            'indexes' => array(
                'PRIMARY'           => array('rows' => array('rid', 'sid'), 'type' => 'primary'),
            ),
        ),
        // policy table
        'policy' => array( 
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "policy_name"       => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => true),
                "virus_lover"       => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "spam_lover"        => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "banned_files_lover"    => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "bad_header_lover"  => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "bypass_virus_checks"   => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "bypass_spam_checks"    => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "bypass_banned_checks"  => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "bypass_header_checks"  => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => true),
                "discard_viruses"   => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => true),
                "discard_spam"      => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => true),
                "discard_banned_files"  => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => true),
                "discard_bad_headers"   => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => true),
                "spam_modifies_subj"    => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => true),
                "spam_quarantine_to"    => array('type' => 'varchar', 'size' =>'64', 'default' => '', 'null' => true),
                "spam_tag_level"    => array('type' => 'float', 'size' =>'7,3"', 'default' => '999', 'null' => true),
                "spam_tag2_level"   => array('type' => 'float', 'size' =>'7,3"', 'default' => '999', 'null' => true),
                "spam_kill_level"   => array('type' => 'float', 'size' =>'7,3"', 'default' => '999', 'null' => true),
            ),
            'indexes' => array(
                'PRIMARY'                => array( 'rows' => array( 'id' ), 'type' => 'primary'),
            
            ),
        ),
        
        //maia_config table
        'maia_config' => array(
            'revision' => 1,
            'tabledef' => array(
                "id"                                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "enable_user_autocreation"          => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "enable_false_negative_management"  => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "enable_stats_tracking"             => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "enable_virus_scanning"             => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "enable_spam_filtering"             => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "enable_banned_files_checking"      => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "enable_bad_header_checking"        => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "enable_charts"                     => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "enable_spamtraps"                  => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "enable_stats_reporting"            => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "enable_address_linking"            => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "enable_privacy_invasion"           => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "enable_username_changes"           => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "internal_auth"                     => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "system_default_user_is_local"      => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "user_virus_scanning"               => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "user_spam_filtering"               => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "user_banned_files_checking"        => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "user_bad_header_checking"          => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "admin_email"                       => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => true),
                "expiry_period"                     => array('type' => 'uint', 'size' =>'0', 'default' => '30', 'null' => true),
                "ham_cache_expiry_period"           => array('type' => 'uint', 'size' =>'0', 'default' => '5', 'null' => true),
                "reminder_threshold_count"          => array('type' => 'uint', 'size' =>'0', 'default' => '100', 'null' => true),
                "reminder_threshold_size"           => array('type' => 'uint', 'size' =>'0', 'default' => '500000', 'null' => true),
                "reminder_template_file"            => array('type' => 'varchar', 'size' =>'255', 'default' => 'reminder.tpl', 'null' => true),
                "reminder_login_url"                => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => true),
                "newuser_template_file"             => array('type' => 'varchar', 'size' =>'255', 'default' => 'newuser.tpl', 'null' => true),
                "smtp_server"                       => array('type' => 'varchar', 'size' =>'255', 'default' => 'localhost', 'null' => true),
                "smtp_port"                         => array('type' => 'uint', 'size' =>'0', 'default' => '10025', 'null' => true),
                "currency_label"                    => array('type' => 'varchar', 'size' =>'15', 'default' => '$', 'null' => true),
                "bandwidth_cost"                    => array('type' => 'float', 'size' =>'14,2"', 'default' => '0.00', 'null' => false),
                "chart_ham_colour"                  => array('type' => 'varchar', 'size' =>'32', 'default' => '#DDDDB7', 'null' => true),
                "chart_spam_colour"                 => array('type' => 'varchar', 'size' =>'32', 'default' => '#FFAAAA', 'null' => true),
                "chart_ham_colour"                  => array('type' => 'varchar', 'size' =>'32', 'default' => '#DDDDB7', 'null' => true),
                "chart_virus_colour"                => array('type' => 'varchar', 'size' =>'32', 'default' => '#CCFFCC', 'null' => true),
                "chart_fp_colour"                   => array('type' => 'varchar', 'size' =>'32', 'default' => '#C4CA73', 'null' => true),
                "chart_fn_colour"                   => array('type' => 'varchar', 'size' =>'32', 'default' => '#FF7575', 'null' => true),
                "chart_suspected_ham_colour"        => array('type' => 'varchar', 'size' =>'32', 'default' => '#FFFFB7', 'null' => true),
                "chart_suspected_spam_colour"       => array('type' => 'varchar', 'size' =>'32', 'default' => '#FFCCCC', 'null' => true),
                "chart_wl_colour"                   => array('type' => 'varchar', 'size' =>'32', 'default' => '#EEEEEE', 'null' => true),
                "chart_bl_colour"                   => array('type' => 'varchar', 'size' =>'32', 'default' => '#888888', 'null' => true),
                "chart_background_colour"           => array('type' => 'varchar', 'size' =>'32', 'default' => '#B0ECFF', 'null' => true),
                "chart_font_colour"                 => array('type' => 'varchar', 'size' =>'32', 'default' => '#3D3D50', 'null' => true),
                "chart_autogeneration_interval"     => array('type' => 'uint', 'size' =>'0', 'default' => '60', 'null' => true),
                "banner_title"                      => array('type' => 'varchar', 'size' =>'255', 'default' => 'Maia Mailguard', 'null' => true),
                "use_icons"                         => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "use_logo"                          => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "logo_url"                          => array('type' => 'varchar', 'size' =>'255', 'default' => 'http://www.renaissoft.com/maia/', 'null' => true),
                "logo_file"                         => array('type' => 'varchar', 'size' =>'255', 'default' => 'images/maia-logotoolbar.gif', 'null' => true),
                "logo_alt_text"                     => array('type' => 'varchar', 'size' =>'255', 'default' => 'Maia Mailguard Home Page', 'null' => true),
                "virus_info_url"                    => array('type' => 'varchar', 'size' =>'255', 'default' => 'http://www.google.com/search?q=%%VIRUSNAME%%+virus+information', 'null' => true),
                "virus_lookup"                      => array('type' => 'varchar', 'size' =>'20', 'default' => 'google', 'null' => true),
                "primary_report_server"             => array('type' => 'varchar', 'size' =>'255', 'default' => 'maia.renaissoft.com', 'null' => true),
                "primary_report_port"               => array('type' => 'uint', 'size' =>'0', 'default' => '443', 'null' => true),
                "primary_report_server"             => array('type' => 'varchar', 'size' =>'255', 'default' => 'maia.renaissoft.com', 'null' => true),
                "secondary_report_server"           => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => true),
                "secondary_report_port"             => array('type' => 'uint', 'size' =>'0', 'default' => '443', 'null' => true),
                "reporter_sitename"                 => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => true),
                "reporter_username"                 => array('type' => 'varchar', 'size' =>'50', 'default' => '', 'null' => true),
                "reporter_password"                 => array('type' => 'varchar', 'size' =>'50', 'default' => '', 'null' => true),
                "size_limit"                        => array('type' => 'uint', 'size' =>'0', 'default' => '1000000', 'null' => true),
                "oversize_policy"                   => array('type' => 'char', 'size' =>'1', 'default' => 'B', 'null' => false),
                "sa_score_set"                      => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "key_file"                          => array('type' => 'varchar', 'size' =>'255', 'default' => 'blowfish.key', 'null' => true),
            ),
            'indexes' => array(
                'PRIMARY'                => array( 'rows' => array( 'id' ), 'type' => 'primary'),
            ),
            'alterations' => array(
                //drop_column($test_dbh, "maia_config", "amavisd_conf");
                //drop_column($test_dbh, "maia_config", "newuser2_template_file");
                //drop_column($test_dbh, "maia_config", "installation_directory");
                '2' => array( 
                    array( 'action' => 'drop_column', 'params' => array('table' => 'maia_config', 'column' => 'amavisd_conf')),
                    array( 'action' => 'drop_column', 'params' => array('table' => 'maia_config', 'column' => 'newuser2_template_file')),
                    array( 'action' => 'drop_column', 'params' => array('table' => 'maia_config', 'column' => 'installation_directory')),
                ),    
            ),
 
        ),
        // maia_languages table
        "maia_languages" => array(
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "language_name" => array('type' => 'varchar', 'size' =>'100', 'default' => '', 'null' => false),
                "abbreviation" => array('type' => 'char', 'size' =>'2', 'default' => '', 'null' => false),
                "installed" => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'id' ), 'type' => 'primary'),
                'abbreviation'          => array( 'rows' => array( 'abbreviation' ), 'type' => 'index'),
            ),
        ),
        // maia_users table
        "maia_users" => array(
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "user_name" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "user_level" => array('type' => 'char', 'size' =>'1', 'default' => 'U', 'null' => false),
                "reminders" => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "charts" => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "primary_email_id" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "language" => array('type' => 'varchar', 'size' =>'10', 'default' => 'en', 'null' => false),
                "charset" => array('type' => 'varchar', 'size' =>'20', 'default' => 'ISO-8859-1', 'null' => false),
                "spamtrap" => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "password" => array('type' => 'varchar', 'size' =>'32', 'default' => '', 'null' => true),
                "auto_whitelist" => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "items_per_page" => array('type' => 'uint', 'size' =>'0', 'default' => '50', 'null' => false),
                "spam_quarantine_sort" => array('type' => 'char', 'size' =>'2', 'default' => 'XA', 'null' => false),
                "virus_quarantine_sort" => array('type' => 'char', 'size' =>'2', 'default' => 'DA', 'null' => false),
                "header_quarantine_sort" => array('type' => 'char', 'size' =>'2', 'default' => 'DA', 'null' => false),
                "attachment_quarantine_sort" => array('type' => 'char', 'size' =>'2', 'default' => 'DA', 'null' => false),
                "ham_cache_sort" => array('type' => 'char', 'size' =>'2', 'default' => 'XD', 'null' => false),
                "discard_ham" => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "theme_id" => array('type' => 'int', 'size' =>'10', 'default' => '1', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'id' ), 'type' => 'primary'),
                'user_name'          => array( 'rows' => array('user_name'), 'type' => 'unique'),
                'theme_id'          => array( 'rows' => array('theme_id'), 'type' => 'index'),
            ),
        ),
        
        // maia_themes
        "maia_themes" => array(
            'revision' => 3,
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "name" => array('type' => 'varchar', 'size' =>'30', 'default' => '', 'null' => false),
                "path" => array('type' => 'varchar', 'size' =>'30', 'default' => '', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'id' ), 'type' => 'primary'),
            ),
            'alterations' => array(
                '3' => array( 
                    array( 'action' => 'add_data', 'params' => array('table' => 'maia_themes', 'params' => array('id' => 1, "name" => "Maia Blue", "path" => "default"))),
                    array( 'action' => 'add_data', 'params' => array('table' => 'maia_themes', 'params' => array('id' => 2, "name" => "Mild Brown", "path" => "test1"))),
                    array( 'action' => 'add_data', 'params' => array('table' => 'maia_themes', 'params' => array('id' => 3, "name" => "DGM", "path" => "dgm"))),
                ),
            ),
        ),                
        // maia_domains table
        "maia_domains" => array(
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "domain" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "reminders" => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "charts" => array('type' => 'char', 'size' =>'1', 'default' => 'N', 'null' => false),
                "enable_user_autocreation" => array('type' => 'char', 'size' =>'1', 'default' => 'Y', 'null' => false),
                "language" => array('type' => 'varchar', 'size' =>'10', 'default' => 'en', 'null' => false),
                "charset" => array('type' => 'varchar', 'size' =>'20', 'default' => 'ISO-8859-1', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'id' ), 'type' => 'primary'),
                'domain'                => array( 'rows' => array( 'domain' ), 'type' => 'index'),
            ),
        ),
        //maia_domain_admins table
        "maia_domain_admins" => array(
            'tabledef' => array(
                "domain_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "admin_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
             ),
             'indexes' => array(
                'PRIMARY' => array( 'rows' => array( 'domain_id', 'admin_id' ), 'type' => 'primary'),
             ),
         ),
        //maia_stats table
        "maia_stats" => array(
            'tabledef' => array(
                "user_id" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => true),
                "oldest_suspected_ham_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_suspected_ham_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_suspected_ham_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_suspected_ham_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_suspected_ham_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "lowest_suspected_ham_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "highest_suspected_ham_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "total_suspected_ham_score" => array('type' => 'float', 'size' =>'14,3"', 'default' => '0.0', 'null' => false),
                "total_suspected_ham_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_ham_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_ham_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_ham_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_ham_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_ham_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "lowest_ham_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "highest_ham_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "total_ham_score" => array('type' => 'float', 'size' =>'14,3"', 'default' => '0.0', 'null' => false),
                "total_ham_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_wl_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_wl_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_wl_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_wl_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_wl_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_wl_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_bl_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_bl_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_bl_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_bl_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bl_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bl_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_suspected_spam_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_suspected_spam_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_suspected_spam_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_suspected_spam_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_suspected_spam_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "lowest_suspected_spam_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "highest_suspected_spam_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "total_suspected_spam_score" => array('type' => 'float', 'size' =>'14,3"', 'default' => '0.0', 'null' => false),
                "total_suspected_spam_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_fp_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_fp_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_fp_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_fp_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_fp_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "lowest_fp_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "highest_fp_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "total_fp_score" => array('type' => 'float', 'size' =>'14,3"', 'default' => '0.0', 'null' => false),
                "total_fp_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_fn_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_fn_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_fn_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_fn_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_fn_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "lowest_fn_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "highest_fn_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "total_fn_score" => array('type' => 'float', 'size' =>'14,3"', 'default' => '0.0', 'null' => false),
                "total_fn_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_spam_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_spam_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_spam_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_spam_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_spam_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "lowest_spam_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "highest_spam_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
                "total_spam_score" => array('type' => 'float', 'size' =>'14,3"', 'default' => '0.0', 'null' => false),
                "total_spam_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_virus_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_virus_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_virus_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_virus_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_virus_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_virus_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_bad_header_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_bad_header_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_bad_header_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_bad_header_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bad_header_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bad_header_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_banned_file_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_banned_file_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_banned_file_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_banned_file_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_banned_file_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_banned_file_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "oldest_oversized_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "newest_oversized_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => true),
                "smallest_oversized_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "largest_oversized_size" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_oversized_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_oversized_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY' => array( 'rows' => array( 'user_id' ), 'type' => 'primary'),
            ),
        ),
        // maia_mail table
        "maia_mail" => array(
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "received_date" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => false),
                "size" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "sender_email" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "envelope_to" => array('type' => 'text', 'size' =>'0', 'default' => '', 'null' => false),
                "subject" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "contents" => array('type' => 'ltext', 'size' =>'0', 'default' => '', 'null' => false),
                "score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '', 'null' => true),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'id' ), 'type' => 'primary'),
                'maia_mail_idx_received_date' => array( 'rows' => array ('received_date'), 'type' => 'index'),
            ),
        ),
        // maia_virus_aliases
        "maia_virus_aliases" => array(
            'tabledef' => array(
                "virus_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "virus_alias" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'virus_id', 'virus_alias' ), 'type' => 'primary'),
            ),
        ),
        // maia_mail_recipients
        "maia_mail_recipients" => array(
            'tabledef' => array(
                "mail_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "recipient_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "type" => array('type' => 'char', 'size' =>'1', 'default' => '', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'mail_id', 'recipient_id' ), 'type' => 'primary'),
                'maia_mail_recipients_idx_type' => array( 'rows' => array( 'type'), 'type' => 'index'),
                'maia_mail_recipients_idx_mail_id' => array( 'rows' => array( 'il_id'), 'type' => 'index'),
            ),
        ),
        // maia_viruses
        "maia_viruses" => array(
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "virus_name" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "count" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'mail_id', 'recipient_id' ), 'type' => 'primary'),
                'virus_name' => array( 'rows' => array( 'virus_name' ), 'type' => 'index'),
            ),
        ),
        // maia_viruses_detected
        "maia_viruses_detected" => array(
            'tabledef' => array(
                "mail_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "virus_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'mail_id', 'virus_id' ), 'type' => 'primary'),
            ),
        ),
        // maia_sa_rules table
        "maia_sa_rules" => array(
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "rule_name" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "rule_description" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "rule_score_0" => array('type' => 'float', 'size' =>'7,3"', 'default' => '1.0', 'null' => false),
                "rule_score_1" => array('type' => 'float', 'size' =>'7,3"', 'default' => '1.0', 'null' => false),
                "rule_score_2" => array('type' => 'float', 'size' =>'7,3"', 'default' => '1.0', 'null' => false),
                "rule_score_3" => array('type' => 'float', 'size' =>'7,3"', 'default' => '1.0', 'null' => false),
                "rule_count" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'id' ), 'type' => 'primary'),
                'rule_name'             => array( 'rows' => array( 'rule_name' ), 'type' => 'index'),
            ),
        ),
        // maia_sa_rules_triggered table
        "maia_sa_rules_triggered" => array(
            'tabledef' => array(
                "mail_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "rule_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "rule_score" => array('type' => 'float', 'size' =>'7,3"', 'default' => '0.0', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'mail_id', 'rule_id' ), 'type' => 'primary'),
            ),
        ),
        //maia_banned_attachments_found table
        "maia_banned_attachments_found" => array(
            'tabledef' => array(
                "mail_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "file_name" => array('type' => 'varchar', 'size' =>'255', 'default' => '', 'null' => false),
                "file_type" => array('type' => 'varchar', 'size' =>'20', 'default' => 'Unknown', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'mail_id', 'file_name' ), 'type' => 'primary'),
            ),
        ),
        // maia_stats_history
        "maia_stats_history" => array(
            'tabledef' => array(
                "id"                => array('type' => 'uint', 'size' => '0', 'default'=> '0', 'null' => false, 'inc' => true),
                "user_id" => array('type' => 'uint', 'size' =>'0', 'default' => '', 'null' => false),
                "type" => array('type' => 'char', 'size' =>'1', 'default' => 'H', 'null' => false),
                "taken_at" => array('type' => 'timestamp', 'size' =>'0', 'default' => '', 'null' => false),
                "total_ham_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_ham_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_spam_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_spam_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_virus_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_virus_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_fp_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_fp_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_fn_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_fn_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_banned_file_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_banned_file_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bad_header_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bad_header_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_wl_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_wl_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bl_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_bl_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_oversized_items" => array('type' => 'uint', 'size' =>'0', 'default' => '0', 'null' => false),
                "total_oversized_size" => array('type' => 'ubigint', 'size' =>'0', 'default' => '0', 'null' => false),
            ),
            'indexes' => array(
                'PRIMARY'               => array( 'rows' => array( 'id', 'user_id' ), 'type' => 'primary'),
            ),
        ),
    ),
);
?>
