<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<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-3.1.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

	<changeSet author="wim" id="createtable_promotioncodes">
		<createTable tableName="promotioncodes">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_promotioncodes" />
			</column>
			<column name="code" type="varchar(32)">
				<constraints nullable="false" />
			</column>
			<column name="username" type="varchar(64)">
				<constraints nullable="true" />
			</column>
			<column name="handedout" type="datetime(0)">
				<constraints nullable="true" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="index_promotioncodes_username">
		<createIndex indexName="idx_promotioncodes_username" tableName="promotioncodes" unique="false">
        	<column name="username" />
        </createIndex>
	</changeSet>

	<changeSet author="wim" id="createtable_logins">
		<createTable tableName="logins">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_logins" />
			</column>
			<column name="username" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="remoteaddress" type="varchar(46)">
				<constraints nullable="false" />
			</column>
			<column name="success" type="boolean">
				<constraints nullable="false" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
		</createTable>		
	</changeSet>
	<changeSet author="wim" id="index_logins_username">
		<createIndex indexName="idx_logins_username" tableName="logins" unique="false">
        	<column name="username" />
        </createIndex>
	</changeSet>
	<changeSet author="wim" id="index_logins_remoteaddress">
		<createIndex indexName="idx_logins_remoteaddress" tableName="logins" unique="false">
        	<column name="remoteaddress" />
        </createIndex>
	</changeSet>
	<changeSet author="wim" id="logins_add_column_result">
		<addColumn tableName="logins">
			<column name="result" type="enum('success', 'failed', 'blocked')">
				<constraints nullable="false" />
			</column>
		</addColumn>
	</changeSet>
	<changeSet author="wim" id="logins_drop_column_success">
		<dropColumn tableName="logins" columnName="success" />
	</changeSet>
</databaseChangeLog>
