<?xml version="1.0" encoding="UTF-8"?>
 
<databaseChangeLog
	xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
		http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

	<changeSet author="rssntn67" id="1.7.0-ifindex-persistence">
		<preConditions onFail="MARK_RAN">
			<and>
				<not><columnExists tableName="alarms" columnName="ifindex" /></not>
				<not><columnExists tableName="events" columnName="ifindex" /></not>
			</and>
		</preConditions>

		<addColumn tableName="alarms">
			<column name="ifindex" type="integer" />
			<column name="eventparms" type="text" />
		</addColumn>
		<addColumn tableName="events">
			<column name="ifindex" type="integer" />
		</addColumn>

		<createIndex tableName="alarms" indexName="alarm_lasteventtime_idx">
			<column name="lasteventtime" />
		</createIndex>

		<rollback>
			<dropIndex tableName="alarms" indexName="alarm_lasteventtime_idx" />
			<dropColumn tableName="alarms" columnName="ifindex" />
			<dropColumn tableName="events" columnName="ifindex" />
		</rollback>
	</changeSet>

</databaseChangeLog>