<?xml version="1.0" ?>
<database>
	<name>*dbname*</name>
	<create>true</create>
	<overwrite>false</overwrite>
	<charset>utf8</charset>

	<table>
		<name>*dbprefix*audioplayer_artists</name>
		<declaration>
			<field>
				<name>id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>true</autoincrement>
				<unsigned>true</unsigned>
				<primary>true</primary>
			</field>
			<field>
				<name>user_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
			</field>
			<field>
				<name>name</name>
				<type>text</type>
				<notnull>false</notnull>
				<length>256</length>
			</field>
		</declaration>
	</table>

	<table>
		<name>*dbprefix*audioplayer_albums</name>
		<declaration>
			<field>
				<name>id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>true</autoincrement>
				<unsigned>true</unsigned>
				<primary>true</primary>
			</field>
			<field>
				<name>user_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
			</field>
			<field>
				<name>name</name>
				<type>text</type>
				<notnull>false</notnull>
				<length>256</length>
			</field>
			<field>
				<name>year</name>
				<type>integer</type>
				<notnull>false</notnull>
				<unsigned>true</unsigned>
			</field>
			<field>
				<name>genre_id</name>
				<type>integer</type>
				<notnull>false</notnull>
			</field>
			<field>
				<name>cover</name>
				<type>clob</type>
    			<notnull>false</notnull>
			</field>
			<field>
				<name>bgcolor</name>
				<type>text</type>
				<notnull>false</notnull>
				<length>40</length>
			</field>
		</declaration>
	</table>

	<table>
		<name>*dbprefix*audioplayer_album_artists</name>
		<declaration>
			<field>
				<name>artist_id</name>
				<type>integer</type>
				<notnull>false</notnull>
			</field>
			<field>
				<name>album_id</name>
				<type>integer</type>
				<notnull>false</notnull>
			</field>

			<index>
				<name>a_artist_id_album_id_idx</name>
				<unique>true</unique>
				<field>
					<name>artist_id</name>
				</field>
				<field>
					<name>album_id</name>
				</field>
			</index>
		</declaration>
	</table>
	
	<table>
		<name>*dbprefix*audioplayer_genre</name>
		<declaration>
			<field>
				<name>id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>true</autoincrement>
				<unsigned>true</unsigned>
				<primary>true</primary>
			</field>
			<field>
				<name>user_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
			</field>
			<field>
				<name>name</name>
				<type>text</type>
				<notnull>false</notnull>
				<length>256</length>
			</field>
		</declaration>
	</table>
	
	<table>
		<name>*dbprefix*audioplayer_playlists</name>
		<declaration>
			<field>
				<name>id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>true</autoincrement>
				<unsigned>true</unsigned>
				<primary>true</primary>
			</field>
			<field>
				<name>user_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
			</field>
			<field>
				<name>name</name>
				<type>text</type>
				<notnull>false</notnull>
				<length>256</length>
			</field>
		</declaration>
	</table>
	
	<table>
		<name>*dbprefix*audioplayer_playlist_tracks</name>
		<declaration>
			<field>
				<name>playlist_id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<unsigned>true</unsigned>
			</field>
			<field>
				<name>track_id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<unsigned>true</unsigned>
			</field>
			<field>
				<name>sortorder</name>
				<type>integer</type>
			    <default>0</default>
			    <notnull>true</notnull>
			    <unsigned>true</unsigned>
			    <length>1</length>
			</field>
			<index>
				<name>aa_playlist_tracks_idx</name>
				<field>
					<name>playlist_id</name>
				</field>
			</index>

			<index>
				<name>aa_playlist_tracks_unique_idx</name>
				<unique>true</unique>
				<field>
					<name>playlist_id</name>
				</field>
				<field>
					<name>track_id</name>
				</field>
			</index>
		</declaration>
	</table>

	<table>
		<name>*dbprefix*audioplayer_tracks</name>
		<declaration>
			<field>
				<name>id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<autoincrement>true</autoincrement>
				<unsigned>true</unsigned>
				<primary>true</primary>
			</field>
			<field>
				<name>user_id</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
			</field>
			<field>
				<name>title</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>256</length>
			</field>
			<field>
				<name>number</name>
				<type>integer</type>
				<notnull>false</notnull>
				<unsigned>true</unsigned>
			</field>
			<field>
				<name>artist_id</name>
				<type>integer</type>
				<notnull>false</notnull>
			</field>
			<field>
				<name>album_id</name>
				<type>integer</type>
				<notnull>false</notnull>
			</field>
			<field>
				<name>length</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>50</length>
			</field>
			<field>
				<name>file_id</name>
				<type>integer</type>
				<notnull>true</notnull>
				<length>4</length>
			</field>
			<field>
				<name>bitrate</name>
				<type>integer</type>
				<notnull>false</notnull>
				<unsigned>true</unsigned>
			</field>
			<field>
				<name>mimetype</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>256</length>
			</field>

			<index>
				<name>aa_tracks_artist_id_idx</name>
				<field>
					<name>artist_id</name>
				</field>
			</index>
			<index>
				<name>aa_tracks_album_id_idx</name>
				<field>
					<name>album_id</name>
				</field>
			</index>

			<index>
				<name>aa_tracks_file_user_id_idx</name>
				<unique>true</unique>
				<field>
					<name>file_id</name>
				</field>
				<field>
					<name>user_id</name>
				</field>
			</index>
		</declaration>
	</table>

</database>
