<?xml version="1.0" encoding="utf-8" ?>
<database Name="otrs">

    <TableAlter Name="ticket">
        <ColumnAdd Name="archive_flag" Required="true" Default="0" Type="SMALLINT"/>
        <IndexCreate Name="ticket_create_time_unix">
            <IndexColumn Name="create_time_unix"/>
        </IndexCreate>
        <IndexCreate Name="ticket_create_time">
            <IndexColumn Name="create_time"/>
        </IndexCreate>
        <IndexCreate Name="ticket_archive_flag">
            <IndexColumn Name="archive_flag"/>
        </IndexCreate>
    </TableAlter>

    <Insert Table="ticket_history_type">
        <Data Key="name" Type="Quote">ArchiveFlagUpdate</Data>
        <Data Key="valid_id">1</Data>
        <Data Key="create_by">1</Data>
        <Data Key="create_time">current_timestamp</Data>
        <Data Key="change_by">1</Data>
        <Data Key="change_time">current_timestamp</Data>
    </Insert>

    <TableCreate Name="ticket_flag">
        <Column Name="ticket_id" Required="true" Type="BIGINT"/>
        <Column Name="ticket_key" Required="true" Size="50" Type="VARCHAR"/>
        <Column Name="ticket_value" Required="false" Size="50" Type="VARCHAR"/>
        <Column Name="create_time" Required="true" Type="DATE"/>
        <Column Name="create_by" Required="true" Type="INTEGER"/>
        <Index Name="ticket_flag_ticket_id_create_by">
            <IndexColumn Name="ticket_id"/>
            <IndexColumn Name="create_by"/>
        </Index>
        <Index Name="ticket_flag_ticket_id_ticket_key">
            <IndexColumn Name="ticket_id"/>
            <IndexColumn Name="ticket_key"/>
        </Index>
        <Index Name="ticket_flag_ticket_id">
            <IndexColumn Name="ticket_id"/>
        </Index>
        <ForeignKey ForeignTable="ticket">
            <Reference Local="ticket_id" Foreign="id"/>
        </ForeignKey>
        <ForeignKey ForeignTable="users">
            <Reference Local="create_by" Foreign="id"/>
        </ForeignKey>
    </TableCreate>

    <TableAlter Name="article_flag">
        <ColumnChange NameOld="article_flag" NameNew="article_key" Required="true" Size="50" Type="VARCHAR"/>
        <ColumnAdd Name="article_value" Required="false" Size="50" Type="VARCHAR"/>
        <IndexCreate Name="article_flag_article_id_create_by">
            <IndexColumn Name="article_id"/>
            <IndexColumn Name="create_by"/>
        </IndexCreate>
        <IndexCreate Name="article_flag_article_id_article_key">
            <IndexColumn Name="article_id"/>
            <IndexColumn Name="article_key"/>
        </IndexCreate>
        <IndexDrop Name="article_flag_create_by"/>
        <ForeignKey ForeignTable="article">
            <Reference Local="article_id" Foreign="id"/>
        </ForeignKey>
    </TableAlter>

    <TableAlter Name="customer_user">
        <ColumnChange NameOld="salutation" NameNew="title" Required="false" Size="50" Type="VARCHAR"/>
        <ColumnChange NameOld="login" NameNew="login" Required="true" Size="200" Type="VARCHAR"/>
        <ColumnChange NameOld="customer_id" NameNew="customer_id" Required="true" Size="150" Type="VARCHAR"/>
        <ColumnChange NameOld="zip" NameNew="zip" Required="false" Size="200" Type="VARCHAR"/>
        <ColumnChange NameOld="city" NameNew="city" Required="false" Size="200" Type="VARCHAR"/>
        <ColumnChange NameOld="country" NameNew="country" Required="false" Size="200" Type="VARCHAR"/>
        <ColumnChange NameOld="pw" NameNew="pw" Required="false" Size="64" Type="VARCHAR"/>
    </TableAlter>

    <TableAlter Name="users">
        <ColumnChange NameOld="salutation" NameNew="title" Required="false" Size="50" Type="VARCHAR"/>
        <ColumnChange NameOld="login" NameNew="login" Required="true" Size="200" Type="VARCHAR"/>
        <ColumnChange NameOld="pw" NameNew="pw" Required="false" Size="64" Type="VARCHAR"/>
    </TableAlter>

    <TableAlter Name="valid">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="ticket_priority">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="ticket_type">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="ticket_lock_type">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="groups">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="roles">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="ticket_state">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="ticket_state_type">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="salutation">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="signature">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="system_address">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="follow_up_possible">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="queue">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="ticket_history_type">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="article_type">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="article_sender_type">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="standard_response">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="standard_attachment">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
        <ColumnChange NameOld="content_type" NameNew="content_type" Required="true" Size="250" Type="VARCHAR"/>
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="auto_response_type">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="auto_response">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="service">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="service_customer_user">
        <ColumnChange NameOld="customer_user_login" NameNew="customer_user_login" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="sla">
        <ColumnChange NameOld="comments" NameNew="comments" Required="false" Size="250" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="customer_company">
        <ColumnChange NameOld="customer_id" NameNew="customer_id" Required="true" Size="150" Type="VARCHAR"/>
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="notification_event">
        <ColumnChange NameOld="content_type" NameNew="content_type" Required="true" Size="250" Type="VARCHAR"/>
        <ColumnAdd Name="comments" Required="false" Size="250" Type="VARCHAR"/>
    </TableAlter>
    <TableAlter Name="package_repository">
        <ColumnChange NameOld="name" NameNew="name" Required="true" Size="200" Type="VARCHAR"/>
    </TableAlter>

    <TableAlter Name="article_attachment">
        <ColumnChange NameOld="content_type" NameNew="content_type" Required="false" Size="450" Type="VARCHAR"/>
    </TableAlter>

</database>
