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

<TableAlter Name="dynamic_field_value">

    <!-- improve index -->
    <IndexDrop Name="dynamic_field_value_field_values"/>
    <IndexCreate Name="dynamic_field_value_field_values">
        <IndexColumn Name="object_id"/>
        <IndexColumn Name="field_id"/>
    </IndexCreate>

</TableAlter>

<TableAlter Name="web_upload_cache">
    <ColumnAdd Name="disposition" Required="false" Size="15" Type="VARCHAR"/>
</TableAlter>

<TableAlter Name="article_attachment">
    <ColumnAdd Name="disposition" Required="false" Size="15" Type="VARCHAR"/>
</TableAlter>

<TableAlter Name="ticket">
    <ForeignKeyDrop ForeignTable="valid">
        <Reference Local="valid_id" Foreign="id"/>
    </ForeignKeyDrop>
    <ColumnDrop Name="valid_id"/>
</TableAlter>

<TableAlter Name="ticket_history">
    <ForeignKeyDrop ForeignTable="valid">
        <Reference Local="valid_id" Foreign="id"/>
    </ForeignKeyDrop>
    <ColumnDrop Name="valid_id"/>
</TableAlter>

<!-- remove pm_entity table as it is not longer needed with use of GUIDs -->
<TableDrop Name="pm_entity"/>

<!-- personal_services - stores all "my services" -->
<TableCreate Name="personal_services">
    <Column Name="user_id" Required="true" Type="INTEGER"/>
    <Column Name="service_id" Required="true" Type="INTEGER"/>
    <Index Name="personal_services_user_id">
        <IndexColumn Name="user_id"/>
    </Index>
    <Index Name="personal_services_service_id">
        <IndexColumn Name="service_id"/>
    </Index>
    <ForeignKey ForeignTable="users">
        <Reference Local="user_id" Foreign="id"/>
    </ForeignKey>
    <ForeignKey ForeignTable="service">
        <Reference Local="service_id" Foreign="id"/>
    </ForeignKey>
</TableCreate>

<!-- package_repository column table remove  -->
<TableAlter Name="package_repository">
    <ColumnDrop Name="content_size"/>
</TableAlter>

<!-- system_maintenance - an scheduled system maintenance -->
<Table Name="system_maintenance">
    <Column Name="id" Required="true" PrimaryKey="true" AutoIncrement="true" Type="INTEGER"/>
    <Column Name="start_date" Required="true" Type="INTEGER"/>
    <Column Name="stop_date" Required="true" Type="INTEGER"/>
    <Column Name="comments" Required="true" Size="250" Type="VARCHAR"/>
    <Column Name="login_message" Required="false" Size="250" Type="VARCHAR"/>
    <Column Name="show_login_message" Required="false" Type="SMALLINT"/>
    <Column Name="notify_message" Required="false" Size="250" Type="VARCHAR"/>
    <Column Name="valid_id" Required="true" Type="SMALLINT"/>
    <Column Name="create_time" Required="true" Type="DATE"/>
    <Column Name="create_by" Required="true" Type="INTEGER"/>
    <Column Name="change_time" Required="true" Type="DATE"/>
    <Column Name="change_by" Required="true" Type="INTEGER"/>
    <ForeignKey ForeignTable="valid">
        <Reference Local="valid_id" Foreign="id"/>
    </ForeignKey>
    <ForeignKey ForeignTable="users">
        <Reference Local="create_by" Foreign="id"/>
        <Reference Local="change_by" Foreign="id"/>
    </ForeignKey>
</Table>

</database>
