<query-mapping package='AWA.Counters.Models'>
    <description>
      Queries to update counters
    </description>

    <class name="AWA.Counters.Models.Stat_Info" bean="yes">
        <comment>The month statistics.</comment>
        <property type='Date' name="date">
            <comment>the counter date.</comment>
        </property>
        <property type='Natural' name="count">
            <comment>the counter value.</comment>
        </property>
    </class>

    <query name='counter-update'>
       <comment>Update counter</comment>
       <sql driver='mysql'>
    INSERT INTO awa_counter (object_id, definition_id, date, counter) VALUES(:id, :definition, :date, :counter)
    ON DUPLICATE KEY UPDATE counter = counter + :counter
       </sql>

       <sql driver='sqlite'>
    INSERT OR REPLACE INTO awa_counter (object_id, definition_id, date, counter)
    VALUES(:id, :definition, :date,
           COALESCE((SELECT counter + :counter FROM awa_counter WHERE object_id = :id AND definition_id = :definition AND date = :date),:counter))
       </sql>
    </query>

    <query name='counter-update-field'>
       <comment>Update a target field counter</comment>
       <sql>
    UPDATE :table SET :field = :field + :counter WHERE id = :id
       </sql>
    </query>

</query-mapping>

<query-mapping package='AWA.Counters.Models'>
    <description>
      Queries to update counters
    </description>

    <class name="AWA.Counters.Models.Stat_Info" bean="yes">
        <comment>The month statistics.</comment>
        <property type='Date' name="date">
            <comment>the counter date.</comment>
        </property>
        <property type='Natural' name="count">
            <comment>the counter value.</comment>
        </property>
    </class>

    <query name='counter-update'>
       <comment>Update counter</comment>
       <sql driver='mysql'>
    INSERT INTO awa_counter (object_id, definition_id, date, counter) VALUES(:id, :definition, :date, :counter)
    ON DUPLICATE KEY UPDATE counter = counter + :counter
       </sql>

       <sql driver='postgresql'>
    INSERT INTO awa_counter (object_id, definition_id, date, counter) VALUES(:id, :definition, :date, :counter)
    ON CONFLICT (object_id, definition_id, date) DO UPDATE
    SET counter = awa_counter.counter + :counter
       </sql>

       <sql driver='sqlite'>
    INSERT OR REPLACE INTO awa_counter (object_id, definition_id, date, counter)
    VALUES(:id, :definition, :date,
           COALESCE((SELECT counter + :counter FROM awa_counter WHERE object_id = :id AND definition_id = :definition AND date = :date),:counter))
       </sql>
    </query>

    <query name='counter-update-field'>
       <comment>Update a target field counter</comment>
       <sql>
    UPDATE :table SET :field = :field + :counter WHERE id = :id
       </sql>
    </query>

</query-mapping>

Add specific query for Postgresql to update the counter
Add specific query for Postgresql to update the counter
