<?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_countrycodes_mysql" dbms="mysql">
		<createTable tableName="countrycodes">
			<column name="code" type="int">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_countrycodes" />
			</column>
			<column name="name" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="iso_2" type="varchar(2)">
				<constraints nullable="false" />
			</column>
			<column name="iso_3" type="varchar(3)">
				<constraints nullable="false" />
			</column>
			<column name="postal" type="varchar(3)" />
			<column name="continent" type="enum('EU', 'AF', 'AS', 'AU', 'NA', 'SA', '')" />
			<column name="fee" type="enum('low', 'high', 'unknown')" defaultValue="unknown">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_countrycodes_pg" dbms="postgresql">
		<createTable tableName="countrycodes">
			<column name="code" type="int">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_countrycodes" />
			</column>
			<column name="name" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="iso_2" type="varchar(2)">
				<constraints nullable="false" />
			</column>
			<column name="iso_3" type="varchar(3)">
				<constraints nullable="false" />
			</column>
			<column name="postal" type="varchar(3)" />
			<column name="continent" type="varchar(2)" />
			<column name="fee" type="varchar(8)" defaultValue="unknown">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="continent VARCHAR(2)" 
				with="continent VARCHAR(2) CHECK (continent IN ('EU', 'AF', 'AS', 'AU', 'NA', 'SA', null))" />
		</modifySql>
		<modifySql>
			<replace replace="fee VARCHAR(8) DEFAULT 'unknown' NOT NULL" 
				with="fee VARCHAR(8) DEFAULT 'unknown' NOT NULL CHECK (fee IN ('low', 'high', 'unknown'))" />
		</modifySql>
	</changeSet>
	<changeSet author="wim" id="uniq_countrycodes_iso2">
		<addUniqueConstraint tableName="countrycodes" columnNames="iso_2" constraintName="uniq_countrycodes_iso2" />
	</changeSet>
	<changeSet author="wim" id="uniq_countrycodes_iso3">
		<addUniqueConstraint tableName="countrycodes" columnNames="iso_3" constraintName="uniq_countrycodes_iso3" />
	</changeSet>
	<changeSet author="wim" id="uniq_countrycodes_postal">
		<addUniqueConstraint tableName="countrycodes" columnNames="postal" constraintName="uniq_countrycodes_postal" />
	</changeSet>

	<changeSet author="wim" id="createtable_bodies">
		<createTable tableName="ab_bodies">
			<column name="bodycode" type="varchar(3)">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_ab_bodies" />
			</column>
			<column name="bodyname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="email" type="varchar(70)" />
			<column name="bodystatus" type="varchar(2)" />
			<column name="bodycategory" type="varchar(25)">
				<constraints nullable="false" />
			</column>
			<column name="bodycategoryorder" type="int">
				<constraints nullable="false" />
			</column>
			<column name="memberno" type="int" />
			<column name="memberfeecurrencyid" type="int" />
			<column name="membersource" type="varchar(9)" />
			<column name="memberclaimed" type="int" />
			<column name="memberclaimedby" type="varchar(64)" />
			<column name="memberlastupdate" type="datetime(0)" />
			<column name="bodynameascii" type="varchar(50)" />
			<column name="netcomcode" type="char(1)" />
			<column name="countrycode" type="varchar(3)" />
			<column name="password" type="varchar(32)" />
			<column name="nodelegates" type="int" defaultValueNumeric="-1">
				<constraints nullable="false" />
			</column>
			<column name="noenvoys" type="int" defaultValueNumeric="-1">
				<constraints nullable="false" />
			</column>
			<column name="novisitors" type="int" defaultValueNumeric="-1">
				<constraints nullable="false" />
			</column>
			<column name="noobservers" type="int" defaultValueNumeric="-1">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_appl_extraanswers">
		<createTable tableName="appl_extraanswers">
			<column name="appl_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="question_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="answer" type="text">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="pk_applextraanswers">
		<addPrimaryKey tableName="appl_extraanswers" columnNames="appl_id, question_id" constraintName="pk_appl_extraanswers" />
	</changeSet>

	<changeSet author="wim" id="createtable_appl_extraquestions">
		<createTable tableName="appl_extraquestions">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_appl_extraquestions" />
			</column>
			<column name="question" type="varchar(255)">
				<constraints nullable="false" />
			</column>
			<column name="maxlength" type="int">
				<constraints nullable="false" />
			</column>
			<column name="order" type="int">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_cand_extraanswers">
		<createTable tableName="cand_extraanswers">
			<column name="cand_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="question_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="answer" type="text">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="pk_cand_extraanswers">
		<addUniqueConstraint tableName="cand_extraanswers" columnNames="cand_id, question_id" constraintName="pk_cand_extraanswers" />
	</changeSet>

	<changeSet author="wim" id="createtable_cand_extraquestions">
		<createTable tableName="cand_extraquestions">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_cand_extraquestions" />
			</column>
			<column name="candidatepost_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="question" type="varchar(255)">
				<constraints nullable="false" />
			</column>
			<column name="maxlength" type="int">
				<constraints nullable="false" />
			</column>
			<column name="order" type="int">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_candidatepost_mysql" dbms="mysql">
		<createTable tableName="candidatepost">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_candidatepost" />
			</column>
			<column name="position" type="varchar(48)">
				<constraints nullable="false" />
			</column>
			<column name="places" type="int">
				<constraints nullable="false" />
			</column>
			<column name="deadline" type="enum('auto', 'open', 'closed')" defaultValue="auto">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_candidatepost_pg" dbms="postgresql">
		<createTable tableName="candidatepost">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_candidatepost" />
			</column>
			<column name="position" type="varchar(48)">
				<constraints nullable="false" />
			</column>
			<column name="places" type="int">
				<constraints nullable="false" />
			</column>
			<column name="deadline" type="varchar(8)" defaultValue="auto">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="deadline VARCHAR(8)"
				with="deadline VARCHAR(8) CHECK (deadline IN ('auto', 'open', 'closed'))"/>
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_candidates_mysql" dbms="mysql">
		<createTable tableName="candidates">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_candidates" />
			</column>
			<column name="username" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="firstname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="lastname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="datebirth" type="date">
				<constraints nullable="false" />
			</column>
			<column name="sex" type="enum('male', 'female')">
				<constraints nullable="false" />
			</column>
			<column name="email" type="varchar(70)">
				<constraints nullable="false" />
			</column>
			<column name="nationality" type="int">
				<constraints nullable="false" />
			</column>
			<column name="photo" type="mediumblob">
				<constraints nullable="false" />
			</column>
			<column name="street" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="zip" type="varchar(8)">
				<constraints nullable="false" />
			</column>
			<column name="city" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="countrycode" type="int">
				<constraints nullable="false" />
			</column>
			<column name="phone" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="mobile" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="fax" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="bodycode" type="varchar(3)">
				<constraints nullable="false" />
			</column>
			<column name="studies" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="languages" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="position" type="int">
				<constraints nullable="false" />
			</column>
			<column name="membersince" type="date">
				<constraints nullable="false" />
			</column>
			<column name="euexperience" type="text">
				<constraints nullable="false" />
			</column>
			<column name="agoras" type="text">
				<constraints nullable="false" />
			</column>
			<column name="ebms" type="text">
				<constraints nullable="false" />
			</column>
			<column name="aegeeconferences" type="text">
				<constraints nullable="false" />
			</column>
			<column name="localboardposition" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="localactivity" type="text">
				<constraints nullable="false" />
			</column>
			<column name="nonaegee" type="text">
				<constraints nullable="false" />
			</column>
			<column name="cdtasks" type="text">
				<constraints nullable="false" />
			</column>
			<column name="motivation" type="text">
				<constraints nullable="false" />
			</column>
			<column name="taskexperience" type="text">
				<constraints nullable="false" />
			</column>
			<column name="program" type="text">
				<constraints nullable="false" />
			</column>
			<column name="approved" type="enum('pending', 'yes', 'no')" defaultValue="pending">
				<constraints nullable="false" />
			</column>
			<column name="created" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="modified" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="log" type="text">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_candidates_pg" dbms="postgresql">
		<createTable tableName="candidates">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_candidates" />
			</column>
			<column name="username" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="firstname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="lastname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="datebirth" type="date">
				<constraints nullable="false" />
			</column>
			<column name="sex" type="varchar(8)">
				<constraints nullable="false" />
			</column>
			<column name="email" type="varchar(70)">
				<constraints nullable="false" />
			</column>
			<column name="nationality" type="int">
				<constraints nullable="false" />
			</column>
			<column name="photo" type="mediumblob">
				<constraints nullable="false" />
			</column>
			<column name="street" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="zip" type="varchar(8)">
				<constraints nullable="false" />
			</column>
			<column name="city" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="countrycode" type="int">
				<constraints nullable="false" />
			</column>
			<column name="phone" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="mobile" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="fax" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="bodycode" type="varchar(3)">
				<constraints nullable="false" />
			</column>
			<column name="studies" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="languages" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="position" type="int">
				<constraints nullable="false" />
			</column>
			<column name="membersince" type="date">
				<constraints nullable="false" />
			</column>
			<column name="euexperience" type="text">
				<constraints nullable="false" />
			</column>
			<column name="agoras" type="text">
				<constraints nullable="false" />
			</column>
			<column name="ebms" type="text">
				<constraints nullable="false" />
			</column>
			<column name="aegeeconferences" type="text">
				<constraints nullable="false" />
			</column>
			<column name="localboardposition" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="localactivity" type="text">
				<constraints nullable="false" />
			</column>
			<column name="nonaegee" type="text">
				<constraints nullable="false" />
			</column>
			<column name="cdtasks" type="text">
				<constraints nullable="false" />
			</column>
			<column name="motivation" type="text">
				<constraints nullable="false" />
			</column>
			<column name="taskexperience" type="text">
				<constraints nullable="false" />
			</column>
			<column name="program" type="text">
				<constraints nullable="false" />
			</column>
			<column name="approved" type="varchar(8)" defaultValue="pending">
				<constraints nullable="false" />
			</column>
			<column name="created" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="modified" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="log" type="text">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="sex VARCHAR(8)"
				with="sex VARCHAR(8) CHECK (sex IN ('male', 'female'))" />
		</modifySql>
		<modifySql>
			<replace replace="approved VARCHAR(8) DEFAULT 'pending' NOT NULL"
				with="approved VARCHAR(8) DEFAULT 'pending' NOT NULL CHECK (approved IN ('pending', 'yes', 'no'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_currencies">
		<createTable tableName="currencies">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_currencies" />
			</column>
			<column name="iso_2" type="varchar(2)">
				<constraints nullable="false" />
			</column>
			<column name="name" type="varchar(24)">
				<constraints nullable="false" />
			</column>
			<column name="short" type="varchar(12)">
				<constraints nullable="false" />
			</column>
			<column name="rate" type="decimal(12, 10)">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_embassies">
		<createTable tableName="embassies">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_embassies" />
			</column>
			<column name="countrycode" type="int">
				<constraints nullable="false" />
			</column>
			<column name="name" type="varchar(128)">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_files">
		<createTable tableName="files">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_files" />
			</column>
			<column name="info_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="subject" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="filename" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="filetype" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="data" type="mediumblob">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_function_roles">
		<createTable tableName="function_roles">
			<column name="role_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="function_id" type="int">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="pk_functionroles">
		<addPrimaryKey tableName="function_roles" columnNames="role_id, function_id" constraintName="pk_functionroles" />
	</changeSet>

	<changeSet author="wim" id="createtable_functions">
		<createTable tableName="functions">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_functions" />
			</column>
			<column name="name" type="varchar(32)">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_info_mysql" dbms="mysql">
		<createTable tableName="info">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_info" />
			</column>
			<column name="subject" type="varchar(128)">
				<constraints nullable="false" />
			</column>
			<column name="message" type="text">
				<constraints nullable="false" />
			</column>
			<column name="access" type="enum('public', 'aegee', 'draft')" defaultValue="public">
				<constraints nullable="false" />
			</column>
			<column name="dateadd" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="datemodify" type="datetime(0)">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_info_pg" dbms="postgresql">
		<createTable tableName="info">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_info" />
			</column>
			<column name="subject" type="varchar(128)">
				<constraints nullable="false" />
			</column>
			<column name="message" type="text">
				<constraints nullable="false" />
			</column>
			<column name="access" type="varchar(8)" defaultValue="public">
				<constraints nullable="false" />
			</column>
			<column name="dateadd" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="datemodify" type="datetime(0)">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="access VARCHAR(8) DEFAULT 'public' NOT NULL" 
				with="access VARCHAR(8) DEFAULT 'public' NOT NULL CHECK (access IN ('public', 'aegee', 'draft'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_log_mysql" dbms="mysql">
		<createTable tableName="log">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_log" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="section" type="varchar(16)">
				<constraints nullable="false" />
			</column>
			<column name="message" type="varchar(192)">
				<constraints nullable="false" />
			</column>
			<column name="type" type="enum('debug', 'info', 'warning', 'error')" defaultValue="info">
				<constraints nullable="false" />
			</column>
			<column name="sess_name" type="varchar(50)" />
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_log_pg" dbms="postgresql">
		<createTable tableName="log">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_log" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="section" type="varchar(16)">
				<constraints nullable="false" />
			</column>
			<column name="message" type="varchar(192)">
				<constraints nullable="false" />
			</column>
			<column name="type" type="varchar(8)" defaultValue="info">
				<constraints nullable="false" />
			</column>
			<column name="sess_name" type="varchar(50)" />
		</createTable>
		<modifySql>
			<replace replace="type VARCHAR(8) DEFAULT 'info' NOT NULL"
				with="type VARCHAR(8) DEFAULT 'info' NOT NULL CHECK (type IN ('debug', 'info', 'warning', 'error'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_mailallhistory_mysql" dbms="mysql">
		<createTable tableName="mailallhistory">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_mailallhistory" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="user" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="fromname" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="fromemail" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="accepted" type="varchar(16)">
				<constraints nullable="false" />
			</column>
			<column name="nationality" type="int">
				<constraints nullable="false" />
			</column>
			<column name="firstagora" type="enum('yes', 'undefined')" defaultValue="undefined">
				<constraints nullable="false" />
			</column>
			<column name="subject" type="varchar(128)">
				<constraints nullable="false" />
			</column>
			<column name="message" type="text">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_mailallhistory_pg" dbms="postgresql">
		<createTable tableName="mailallhistory">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_mailallhistory" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="user" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="fromname" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="fromemail" type="varchar(64)">
				<constraints nullable="false" />
			</column>
			<column name="accepted" type="varchar(16)">
				<constraints nullable="false" />
			</column>
			<column name="nationality" type="int">
				<constraints nullable="false" />
			</column>
			<column name="firstagora" type="varchar(8)" defaultValue="undefined">
				<constraints nullable="false" />
			</column>
			<column name="subject" type="varchar(128)">
				<constraints nullable="false" />
			</column>
			<column name="message" type="text">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="firstagora VARCHAR(8) DEFAULT 'undefined' NOT NULL"
				with="firstagora VARCHAR(8) DEFAULT 'undefined' NOT NULL CHECK (firstagora IN ('yes', 'undefined'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_mailbatch">
		<createTable tableName="mailbatch">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_mailbatch" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="receipt" type="varchar(100)">
				<constraints nullable="false" />
			</column>
			<column name="mail" type="BLOB">
				<constraints nullable="false" />
			</column>
			<column name="sender_id" type="int">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_mailout">
		<createTable tableName="mailout">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_mailout" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="to" type="varchar(128)">
				<constraints nullable="false" />
			</column>
			<column name="content" type="varchar(32)">
				<constraints nullable="false" />
			</column>
			<column name="mail" type="blob">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_memberlist">
		<createTable tableName="memberlist">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_memberlist" />
			</column>
			<column name="bodycode" type="varchar(3)">
				<constraints nullable="false" />
			</column>
			<column name="givenname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="surname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="csn" type="varchar(13)">
				<constraints nullable="false" />
			</column>
			<column name="datebirth" type="date">
				<constraints nullable="false" />
			</column>
			<column name="membersince" type="date">
				<constraints nullable="false" />
			</column>
			<column name="fee" type="decimal(8, 2)" />
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_applications_mysql" dbms="mysql">
		<createTable tableName="applications">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_applications" />
			</column>
			<column name="username" type="varchar(64)" />
			<column name="firstname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="lastname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="bodycode" type="varchar(3)">
				<constraints nullable="false" />
			</column>
			<column name="datebirth" type="date">
				<constraints nullable="false" />
			</column>
			<column name="sex" type="enum('male', 'female')">
				<constraints nullable="false" />
			</column>
			<column name="csn" type="varchar(13)" />
			<column name="email" type="varchar(70)" />
			<column name="visa" type="enum('yes', 'no')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="passportno" type="varchar(50)" />
			<column name="idtype" type="enum('Passport', 'National ID Card (EU+Norway+Switzerland only)')" />
			<column name="placeofbirth" type="varchar(64)" />
			<column name="passportexpirationdate" type="date" />
			<column name="nationality" type="int" />
			<column name="embassy" type="int" />
			<column name="workshopid1" type="int" />
			<column name="workshopid2" type="int" />
			<column name="workshopid3" type="int" />
			<column name="workshopid4" type="int" />
			<column name="chairws1" type="enum('yes', 'no')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="chairws3" type="enum('yes', 'no')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="workshopstrategy" type="int" />
			<column name="extrafee" type="enum('yes', 'no')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="datearrival" type="datetime(0)" />
			<column name="datedeparture" type="datetime(0)" />
			<column name="careof" type="varchar(50)" />
			<column name="street" type="varchar(50)" />
			<column name="zip" type="varchar(8)" />
			<column name="city" type="varchar(50)" />
			<column name="countrycode" type="int" />
			<column name="phone" type="varchar(50)" />
			<column name="mobile" type="varchar(50)" />
			<column name="fax" type="varchar(50)" />
			<column name="mac" type="varchar(17)" />
			<column name="tshirtsize" type="enum('S', 'M', 'L', 'XL')" />
			<column name="photo" type="mediumblob" />
			<column name="meals" type="enum('normal', 'vegetarian', 'vegan', 'diet')" defaultValue="normal">
				<constraints nullable="false" />
			</column>
			<column name="lodgingneeded" type="enum('yes', 'no')" defaultValue="yes">
				<constraints nullable="false" />
			</column>
			<column name="membertype" type="enum('Board member of a local', 'Board member of a WG', 'Member of a project team', 'Board member of a contact', 'None of these')" defaultValue="None of these">
				<constraints nullable="false" />
			</column>
			<column name="agoravisited" type="int">
				<constraints nullable="false" />
			</column>
			<column name="motivation" type="text" />
			<column name="remarks" type="text" />
			<column name="commentboard" type="text" />
			<column name="commentnetcom" type="text" />
			<column name="created" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="modified" type="datetime(0)" />
			<column name="boardconfirmed" type="enum('-', 'yes', 'no')" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistconfirmed" type="enum('-', 'yes', 'pending', 'no')" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistonprevious" type="enum('-', 'yes', 'pending', 'no')" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistoncurrent" type="enum('-', 'yes', 'pending', 'no')" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistisboard" type="enum('-', 'yes', 'pending', 'no')" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="accepted" type="enum('yes', 'pending', 'confirmed', '-', 'no', 'cancel', 'arrived')" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="workshopidslot1" type="int" />
			<column name="workshopidslot2" type="int" />
			<column name="participanttype" type="enum('-', 'delegate', 'envoy', 'observer', 'visitor')" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="participantorder" type="int" />
			<column name="fee" type="int" defaultValueNumeric="-1">
				<constraints nullable="false" />
			</column>
			<column name="feepaid" type="decimal(4, 2)" defaultValueComputed="-1.00">
				<constraints nullable="false" />
			</column>
			<column name="gym" type="int" />
			<column name="gympreference" type="varchar(512)" />
			<column name="confirmationnumber" type="int" />
			<column name="registrationdesk" type="int" />
			<column name="registrationcustfield1" type="varchar(200)" />
			<column name="registrationcustfield2" type="varchar(200)" />
			<column name="registrationcustfield3" type="varchar(200)" />
			<column name="log" type="text" />
			<column name="passportissuingauthority" type="varchar(64)" />
			<column name="passportissuingdate" type="date" />
		</createTable>
		<modifySql>
			<!-- It seems liquibase does something wrong with brackets in enum values, re-adding them to get proper query -->
			<replace replace="Switzerland only) NULL"
				with="Switzerland only)') NULL" />
		</modifySql>
	</changeSet>
	<changeSet author="wim" id="createtable_applications_pg" dbms="postgresql">
		<createTable tableName="applications">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_applications" />
			</column>
			<column name="username" type="varchar(64)" />
			<column name="firstname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="lastname" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="bodycode" type="varchar(3)">
				<constraints nullable="false" />
			</column>
			<column name="datebirth" type="date">
				<constraints nullable="false" />
			</column>
			<column name="sex" type="varchar(8)">
				<constraints nullable="false" />
			</column>
			<column name="csn" type="varchar(13)" />
			<column name="email" type="varchar(70)" />
			<column name="visa" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="passportno" type="varchar(50)" />
			<column name="idtype" type="varchar(48)" />
			<column name="placeofbirth" type="varchar(64)" />
			<column name="passportexpirationdate" type="date" />
			<column name="nationality" type="int" />
			<column name="embassy" type="int" />
			<column name="workshopid1" type="int" />
			<column name="workshopid2" type="int" />
			<column name="workshopid3" type="int" />
			<column name="workshopid4" type="int" />
			<column name="chairws1" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="chairws3" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="workshopstrategy" type="int" />
			<column name="extrafee" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="datearrival" type="datetime(0)" />
			<column name="datedeparture" type="datetime(0)" />
			<column name="careof" type="varchar(50)" />
			<column name="street" type="varchar(50)" />
			<column name="zip" type="varchar(8)" />
			<column name="city" type="varchar(50)" />
			<column name="countrycode" type="int" />
			<column name="phone" type="varchar(50)" />
			<column name="mobile" type="varchar(50)" />
			<column name="fax" type="varchar(50)" />
			<column name="mac" type="varchar(17)" />
			<column name="tshirtsize" type="varchar(4)" />
			<column name="photo" type="mediumblob" />
			<column name="meals" type="varchar(12)" defaultValue="normal">
				<constraints nullable="false" />
			</column>
			<column name="lodgingneeded" type="varchar(4)" defaultValue="yes">
				<constraints nullable="false" />
			</column>
			<column name="membertype" type="varchar(32)" defaultValue="None of these">
				<constraints nullable="false" />
			</column>
			<column name="agoravisited" type="int">
				<constraints nullable="false" />
			</column>
			<column name="motivation" type="text" />
			<column name="remarks" type="text" />
			<column name="commentboard" type="text" />
			<column name="commentnetcom" type="text" />
			<column name="created" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="modified" type="datetime(0)" />
			<column name="boardconfirmed" type="varchar(4)" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistconfirmed" type="varchar(8)" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistonprevious" type="varchar(8)" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistoncurrent" type="varchar(8)" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="memberlistisboard" type="varchar(8)" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="accepted" type="varchar(12)" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="workshopidslot1" type="int" />
			<column name="workshopidslot2" type="int" />
			<column name="participanttype" type="varchar(8)" defaultValue="-">
				<constraints nullable="false" />
			</column>
			<column name="participantorder" type="int" />
			<column name="fee" type="int" defaultValueNumeric="-1">
				<constraints nullable="false" />
			</column>
			<column name="feepaid" type="decimal(4, 2)" defaultValueComputed="-1.00">
				<constraints nullable="false" />
			</column>
			<column name="gym" type="int" />
			<column name="gympreference" type="varchar(512)" />
			<column name="confirmationnumber" type="int" />
			<column name="registrationdesk" type="int" />
			<column name="registrationcustfield1" type="varchar(200)" />
			<column name="registrationcustfield2" type="varchar(200)" />
			<column name="registrationcustfield3" type="varchar(200)" />
			<column name="log" type="text" />
			<column name="passportissuingauthority" type="varchar(64)" />
			<column name="passportissuingdate" type="date" />
		</createTable>
		<modifySql>
			<replace replace="sex VARCHAR(8) NOT NULL"
				with="sex VARCHAR(8) NOT NULL CHECK (sex IN ('male', 'female'))" />
		</modifySql>
		<modifySql>
			<replace replace="visa VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="visa VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (visa IN ('yes', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="idtype VARCHAR(48)"
				with="idtype VARCHAR(48) CHECK (idtype IN ('Passport', 'National ID Card (EU+Norway+Switzerland only)'))" />
		</modifySql>
		<modifySql>
			<replace replace="chairws1 VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="chairws1 VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (chairws1 IN ('yes', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="chairws3 VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="chairws3 VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (chairws3 IN ('yes', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="extrafee VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="extrafee VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (extrafee IN ('yes', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="tshirtsize VARCHAR(4)"
				with="tshirtsize VARCHAR(4) CHECK (tshirtsize IN ('S', 'M', 'L', 'XL'))" />
		</modifySql>
		<modifySql>
			<replace replace="meals VARCHAR(12) DEFAULT 'normal' NOT NULL"
				with="meals VARCHAR(12) DEFAULT 'normal' NOT NULL CHECK (meals IN ('normal', 'vegetarian', 'vegan', 'diet'))" />
		</modifySql>
		<modifySql>
			<replace replace="lodgingneeded VARCHAR(4) DEFAULT 'yes' NOT NULL"
				with="lodgingneeded VARCHAR(4) DEFAULT 'yes' NOT NULL CHECK (lodgingneeded IN ('yes', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="membertype VARCHAR(32) DEFAULT 'None of these' NOT NULL"
				with="membertype VARCHAR(32) DEFAULT 'None of these' NOT NULL CHECK (membertype IN ('Board member of a local', 'Board member of a WG', 'Member of a project team', 'Board member of a contact', 'None of these'))" />
		</modifySql>
		<modifySql>
			<replace replace="boardconfirmed VARCHAR(4) DEFAULT '-' NOT NULL"
				with="boardconfirmed VARCHAR(4) DEFAULT '-' NOT NULL CHECK (boardconfirmed IN ('-', 'yes', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="memberlistconfirmed VARCHAR(8) DEFAULT '-' NOT NULL"
				with="memberlistconfirmed VARCHAR(8) DEFAULT '-' NOT NULL CHECK (memberlistconfirmed IN ('-', 'yes', 'pending', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="memberlistonprevious VARCHAR(8) DEFAULT '-' NOT NULL"
				with="memberlistonprevious VARCHAR(8) DEFAULT '-' NOT NULL CHECK (memberlistonprevious IN ('-', 'yes', 'pending', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="memberlistoncurrent VARCHAR(8) DEFAULT '-' NOT NULL"
				with="memberlistoncurrent VARCHAR(8) DEFAULT '-' NOT NULL CHECK (memberlistoncurrent IN ('-', 'yes', 'pending', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="memberlistisboard VARCHAR(8) DEFAULT '-' NOT NULL"
				with="memberlistisboard VARCHAR(8) DEFAULT '-' NOT NULL CHECK (memberlistisboard IN ('-', 'yes', 'pending', 'no'))" />
		</modifySql>
		<modifySql>
			<replace replace="accepted VARCHAR(12) DEFAULT '-' NOT NULL"
				with="accepted VARCHAR(12) DEFAULT '-' NOT NULL CHECK (accepted IN ('yes', 'pending', 'confirmed', '-', 'no', 'cancel', 'arrived'))" />
		</modifySql>
		<modifySql>
			<replace replace="participanttype VARCHAR(8) DEFAULT '-' NOT NULL"
				with="participanttype VARCHAR(8) DEFAULT '-' NOT NULL CHECK (participanttype IN ('-', 'delegate', 'envoy', 'observer', 'visitor'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_querylog">
		<createTable tableName="querylog">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_querylog" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="sid" type="int">
				<constraints nullable="false" />
			</column>
			<column name="user" type="varchar(32)" />
			<column name="query" type="text">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_roles">
		<createTable tableName="roles">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_roles" />
			</column>
			<column name="name" type="varchar(24)">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>

	<changeSet author="wim" id="createtable_setup_mysql" dbms="mysql">
		<createTable tableName="setup">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_setup" />
			</column>
			<column name="category" type="varchar(16)">
				<constraints nullable="false" />
			</column>
			<column name="name" type="varchar(30)">
				<constraints nullable="false" />
			</column>
			<column name="value" type="text" />
			<column name="regex" type="varchar(100)" />
			<column name="explanation" type="text">
				<constraints nullable="false" />
			</column>
			<column name="ac_view" type="enum('no', 'view', 'edit')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_edit" type="enum('no', 'view', 'edit')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_audit" type="enum('no', 'view', 'edit')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_jc" type="enum('no', 'view', 'edit')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_registration" type="enum('no', 'view', 'edit')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_localorg" type="enum('no', 'view', 'edit')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_chair" type="enum('no', 'view', 'edit')" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="default" type="text" />
			<column name="empty" type="enum('yes', 'no')" defaultValue="no">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_setup_pg" dbms="postgresql">
		<createTable tableName="setup">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_setup" />
			</column>
			<column name="category" type="varchar(16)">
				<constraints nullable="false" />
			</column>
			<column name="name" type="varchar(30)">
				<constraints nullable="false" />
			</column>
			<column name="value" type="text" />
			<column name="regex" type="varchar(100)" />
			<column name="explanation" type="text">
				<constraints nullable="false" />
			</column>
			<column name="ac_view" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_edit" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_audit" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_jc" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_registration" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_localorg" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="ac_chair" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
			<column name="default" type="text" />
			<column name="empty" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="ac_view VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="ac_view VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (ac_view IN ('no', 'view', 'edit'))" />
		</modifySql>
		<modifySql>
			<replace replace="ac_edit VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="ac_edit VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (ac_edit IN ('no', 'view', 'edit'))" />
		</modifySql>
		<modifySql>
			<replace replace="ac_audit VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="ac_audit VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (ac_audit IN ('no', 'view', 'edit'))" />
		</modifySql>
		<modifySql>
			<replace replace="ac_jc VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="ac_jc VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (ac_jc IN ('no', 'view', 'edit'))" />
		</modifySql>
		<modifySql>
			<replace replace="ac_registration VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="ac_registration VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (ac_registration IN ('no', 'view', 'edit'))" />
		</modifySql>
		<modifySql>
			<replace replace="ac_localorg VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="ac_localorg VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (ac_localorg IN ('no', 'view', 'edit'))" />
		</modifySql>
		<modifySql>
			<replace replace="ac_chair VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="ac_chair VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (ac_chair IN ('no', 'view', 'edit'))" />
		</modifySql>
		<modifySql>
			<replace replace="empty VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="empty VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (empty IN ('yes', 'no'))" />
		</modifySql>
	</changeSet>
	<changeSet author="wim" id="uniq_setup_name">
		<addUniqueConstraint tableName="setup" columnNames="name" constraintName="uniq_setup_name" />
	</changeSet>

	<changeSet author="wim" id="createtable_statistics_mysql" dbms="mysql">
		<createTable tableName="statistics">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_statistics" />
			</column>
			<column name="selection" type="enum('all', 'accepted', 'arrived')">
				<constraints nullable="false" />
			</column>
			<column name="title" type="varchar(32)">
				<constraints nullable="false" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="html" type="text">
				<constraints nullable="false" />
			</column>
			<column name="image" type="mediumblob">
				<constraints nullable="false" />
			</column>
			<column name="image_height" type="int">
				<constraints nullable="false" />
			</column>
			<column name="image_width" type="int">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_statistics_pg" dbms="postgresql">
		<createTable tableName="statistics">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_statistics" />
			</column>
			<column name="selection" type="varchar(8)">
				<constraints nullable="false" />
			</column>
			<column name="title" type="varchar(32)">
				<constraints nullable="false" />
			</column>
			<column name="date" type="datetime(0)">
				<constraints nullable="false" />
			</column>
			<column name="html" type="text">
				<constraints nullable="false" />
			</column>
			<column name="image" type="mediumblob">
				<constraints nullable="false" />
			</column>
			<column name="image_height" type="int">
				<constraints nullable="false" />
			</column>
			<column name="image_width" type="int">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="selection VARCHAR(8) NOT NULL"
				with="selection VARCHAR(8) NOT NULL CHECK (selection IN ('all', 'accepted', 'arrived'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_users_mysql" dbms="mysql">
		<createTable tableName="users">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_users" />
			</column>
			<column name="user" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="password" type="varchar(40)" />
			<column name="email" type="varchar(75)">
				<constraints nullable="false" />
			</column>
			<column name="role_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="privstatementagree" type="enum('yes', 'no')" defaultValue="no">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_users_pg" dbms="postgresql">
		<createTable tableName="users">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_users" />
			</column>
			<column name="user" type="varchar(50)">
				<constraints nullable="false" />
			</column>
			<column name="password" type="varchar(40)" />
			<column name="email" type="varchar(75)">
				<constraints nullable="false" />
			</column>
			<column name="role_id" type="int">
				<constraints nullable="false" />
			</column>
			<column name="privstatementagree" type="varchar(4)" defaultValue="no">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="privstatementagree VARCHAR(4) DEFAULT 'no' NOT NULL"
				with="privstatementagree VARCHAR(4) DEFAULT 'no' NOT NULL CHECK (privstatementagree IN ('yes', 'no'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="createtable_workshops_mysql" dbms="mysql">
		<createTable tableName="workshops">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_workshops" />
			</column>
			<column name="title" type="varchar(100)">
				<constraints nullable="false" />
			</column>
			<column name="description" type="text">
				<constraints nullable="false" />
			</column>
			<column name="leader" type="varchar(150)">
				<constraints nullable="false" />
			</column>
			<column name="slot" type="enum('first', 'second', 'both', 'strategy')">
				<constraints nullable="false" />
			</column>
			<column name="url" type="varchar(120)" />
			<column name="places" type="int" defaultValueNumeric="0">
				<constraints nullable="false" />
			</column>
		</createTable>
	</changeSet>
	<changeSet author="wim" id="createtable_workshops_pg" dbms="postgresql">
		<createTable tableName="workshops">
			<column name="id" type="int" autoIncrement="true">
				<constraints nullable="false" primaryKey="true" primaryKeyName="pk_workshops" />
			</column>
			<column name="title" type="varchar(100)">
				<constraints nullable="false" />
			</column>
			<column name="description" type="text">
				<constraints nullable="false" />
			</column>
			<column name="leader" type="varchar(150)">
				<constraints nullable="false" />
			</column>
			<column name="slot" type="varchar(8)">
				<constraints nullable="false" />
			</column>
			<column name="url" type="varchar(120)" />
			<column name="places" type="int" defaultValueNumeric="0">
				<constraints nullable="false" />
			</column>
		</createTable>
		<modifySql>
			<replace replace="slot VARCHAR(8) NOT NULL"
				with="slot VARCHAR(8) NOT NULL CHECK (slot IN ('first', 'second', 'both', 'strategy'))" />
		</modifySql>
	</changeSet>

	<changeSet author="wim" id="add_fk_bodies_countrycode">
		<addForeignKeyConstraint constraintName="fk_bodies_countrycode" 
			baseTableName="ab_bodies" baseColumnNames="countrycode"
			referencedTableName="countrycodes" referencedColumnNames="postal" />
	</changeSet>

	<changeSet author="wim" id="add_fk_appl_extraanswers_appl_id">
		<addForeignKeyConstraint constraintName="fk_appl_extraanswers_appl_id" 
			baseTableName="appl_extraanswers" baseColumnNames="appl_id"
			referencedTableName="applications" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_appl_extraanswers_question_id">
		<addForeignKeyConstraint constraintName="fk_appl_extraanswers_question_id" 
			baseTableName="appl_extraanswers" baseColumnNames="question_id"
			referencedTableName="appl_extraquestions" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_candidates_nationality">
		<addForeignKeyConstraint constraintName="fk_candidates_nationality" 
			baseTableName="candidates" baseColumnNames="nationality"
			referencedTableName="countrycodes" referencedColumnNames="code" />
	</changeSet>
	<changeSet author="wim" id="add_fk_candidates_countrycode">
		<addForeignKeyConstraint constraintName="fk_candidates_countrycode" 
			baseTableName="candidates" baseColumnNames="countrycode"
			referencedTableName="countrycodes" referencedColumnNames="code" />
	</changeSet>
	<changeSet author="wim" id="add_fk_candidates_bodycode">
		<addForeignKeyConstraint constraintName="fk_candidates_bodycode" 
			baseTableName="candidates" baseColumnNames="bodycode"
			referencedTableName="ab_bodies" referencedColumnNames="bodycode" />
	</changeSet>
	<changeSet author="wim" id="add_fk_candidates_position">
		<addForeignKeyConstraint constraintName="fk_candidates_position" 
			baseTableName="candidates" baseColumnNames="position"
			referencedTableName="candidatepost" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_cand_extraanswers_cand_id">
		<addForeignKeyConstraint constraintName="fk_cand_extraanswers_cand_id" 
			baseTableName="cand_extraanswers" baseColumnNames="cand_id"
			referencedTableName="candidates" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_cand_extraanswers_question_id">
		<addForeignKeyConstraint constraintName="fk_cand_extraanswers_question_id" 
			baseTableName="cand_extraanswers" baseColumnNames="question_id"
			referencedTableName="cand_extraquestions" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_cand_extraquestions_candidatepost_id">
		<addForeignKeyConstraint constraintName="fk_cand_extraquestions_candidatepost_id" 
			baseTableName="cand_extraquestions" baseColumnNames="candidatepost_id"
			referencedTableName="candidatepost" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_embassies_countrycode">
		<addForeignKeyConstraint constraintName="fk_embassies_countrycode" 
			baseTableName="embassies" baseColumnNames="countrycode"
			referencedTableName="countrycodes" referencedColumnNames="code" />
	</changeSet>

	<changeSet author="wim" id="add_fk_files_info_id">
		<addForeignKeyConstraint constraintName="fk_files_info_id" 
			baseTableName="files" baseColumnNames="info_id"
			referencedTableName="info" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_function_roles_role_id">
		<addForeignKeyConstraint constraintName="fk_function_roles_role_id" 
			baseTableName="function_roles" baseColumnNames="role_id"
			referencedTableName="roles" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_function_roles_function_id">
		<addForeignKeyConstraint constraintName="fk_function_roles_function_id" 
			baseTableName="function_roles" baseColumnNames="function_id"
			referencedTableName="functions" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_mailallhistory_nationality">
		<addForeignKeyConstraint constraintName="fk_mailallhistory_nationality" 
			baseTableName="mailallhistory" baseColumnNames="nationality"
			referencedTableName="countrycodes" referencedColumnNames="code" />
	</changeSet>

	<changeSet author="wim" id="add_fk_mailbatch_sender_id">
		<addForeignKeyConstraint constraintName="fk_mailbatch_sender_id" 
			baseTableName="mailbatch" baseColumnNames="sender_id"
			referencedTableName="users" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_memberlist_bodycode">
		<addForeignKeyConstraint constraintName="fk_memberlist_bodycode" 
			baseTableName="memberlist" baseColumnNames="bodycode"
			referencedTableName="ab_bodies" referencedColumnNames="bodycode" />
	</changeSet>

	<changeSet author="wim" id="add_fk_applications_bodycode">
		<addForeignKeyConstraint constraintName="fk_applications_bodycode" 
			baseTableName="applications" baseColumnNames="bodycode"
			referencedTableName="ab_bodies" referencedColumnNames="bodycode" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_nationality">
		<addForeignKeyConstraint constraintName="fk_applications_nationality" 
			baseTableName="applications" baseColumnNames="nationality"
			referencedTableName="countrycodes" referencedColumnNames="code" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_embassy">
		<addForeignKeyConstraint constraintName="fk_applications_embassy" 
			baseTableName="applications" baseColumnNames="embassy"
			referencedTableName="embassies" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_workshopid1">
		<addForeignKeyConstraint constraintName="fk_applications_workshopid1" 
			baseTableName="applications" baseColumnNames="workshopid1"
			referencedTableName="workshops" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_workshopid2">
		<addForeignKeyConstraint constraintName="fk_applications_workshopid2" 
			baseTableName="applications" baseColumnNames="workshopid2"
			referencedTableName="workshops" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_workshopid3">
		<addForeignKeyConstraint constraintName="fk_applications_workshopid3" 
			baseTableName="applications" baseColumnNames="workshopid3"
			referencedTableName="workshops" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_workshopid4">
		<addForeignKeyConstraint constraintName="fk_applications_workshopid4" 
			baseTableName="applications" baseColumnNames="workshopid4"
			referencedTableName="workshops" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_workshopstrategy">
		<addForeignKeyConstraint constraintName="fk_applications_workshopstrategy" 
			baseTableName="applications" baseColumnNames="workshopstrategy"
			referencedTableName="workshops" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_countrycode">
		<addForeignKeyConstraint constraintName="fk_applications_countrycode" 
			baseTableName="applications" baseColumnNames="countrycode"
			referencedTableName="countrycodes" referencedColumnNames="code" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_workshopidslot1">
		<addForeignKeyConstraint constraintName="fk_applications_workshopidslot1" 
			baseTableName="applications" baseColumnNames="workshopidslot1"
			referencedTableName="workshops" referencedColumnNames="id" />
	</changeSet>
	<changeSet author="wim" id="add_fk_applications_workshopidslot2">
		<addForeignKeyConstraint constraintName="fk_applications_workshopidslot2" 
			baseTableName="applications" baseColumnNames="workshopidslot2"
			referencedTableName="workshops" referencedColumnNames="id" />
	</changeSet>

	<changeSet author="wim" id="add_fk_users_role_id">
		<addForeignKeyConstraint constraintName="fk_users_role_id" 
			baseTableName="users" baseColumnNames="role_id"
			referencedTableName="roles" referencedColumnNames="id" />
	</changeSet>
</databaseChangeLog>
