package net.somethingdreadful.MAL;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import net.somethingdreadful.MAL.R;

public class MALSqlHelper extends SQLiteOpenHelper {
	
	private static final String DATABASE_NAME = "MAL.db";
	private static final int DATABASE_VERSION = 2;
	
	
	public static final String COLUMN_ID = "_id";
	public static final String TABLE_ANIME = "anime";
	public static final String TABLE_MANGA = "manga";
	
	private static final String CREATE_ANIME_TABLE = "create table "
			+ TABLE_ANIME + "(" 
			+ COLUMN_ID  +" integer primary key autoincrement, "
			+ "recordID varchar, "
			+ "recordName varchar, "
			+ "recordType varchar, "
			+ "imageUrl varchar, "
			+ "recordStatus varchar, "
			+ "myStatus varchar, "
			+ "memberScore varchar, "
			+ "myScore varchar, "
			+ "synopsis varchar, "
			+ "episodesWatched varchar, "
			+ "episodesTotal varchar,"
			+ "dirty boolean DEFAULT false"
			+ ");";
	
	
	public MALSqlHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}


	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_ANIME_TABLE);
		
	}


	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if ((oldVersion == 1) && (newVersion == 2))
		{
			db.execSQL("ALTER TABLE " + TABLE_ANIME + " ADD COLUMN dirty boolean DEFAULT false");
		}
		
	}
}

@@ -1038,27 +1038,604 @@
 + %22);%22;%0D%0A%09%0D%0A
+%09private static final String CREATE_MANGA_TABLE = %22create table %22%0D%0A%09%09%09+ TABLE_MANGA + %22(%22 %0D%0A%09%09%09+ COLUMN_ID  +%22 integer primary key autoincrement, %22%0D%0A%09%09%09+ %22recordID varchar, %22%0D%0A%09%09%09+ %22recordName varchar, %22%0D%0A%09%09%09+ %22recordType varchar, %22%0D%0A%09%09%09+ %22imageUrl varchar, %22%0D%0A%09%09%09+ %22recordStatus varchar, %22%0D%0A%09%09%09+ %22myStatus varchar, %22%0D%0A%09%09%09+ %22memberScore varchar, %22%0D%0A%09%09%09+ %22myScore varchar, %22%0D%0A%09%09%09+ %22synopsis varchar, %22%0D%0A%09%09%09+ %22chaptersRead varchar, %22%0D%0A%09%09%09+ %22chaptersTotal varchar, %22%0D%0A%09%09%09+ %22volumesRead varchar, %22%0D%0A%09%09%09+ %22volumesTotal varchar, %22%0D%0A%09%09%09+ %22dirty boolean DEFAULT false%22%0D%0A%09%09%09+ %22);%22;%0D%0A%09%0D%0A
 %09%0D%0A
-
 %09public MALS
@@ -1820,16 +1820,51 @@
 ABLE);%0D%0A
+%09%09db.execSQL(CREATE_MANGA_TABLE);%0D%0A
 %09%09%0D%0A%09%7D%0D%0A
@@ -2008,16 +2008,16 @@
 )%0D%0A%09%09%7B%0D%0A
-
 %09%09%09db.ex
@@ -2103,16 +2103,109 @@
 ;%0D%0A%09%09%7D%0D%0A
+%09%09if ((oldVersion == 2) && (newVersion == 3))%0D%0A%09%09%7B%0D%0A%09%09%09db.execSQL(CREATE_MANGA_TABLE);%0D%0A%09%09%7D%0D%0A
 %09%09%0D%0A%09%7D%0D%0A

Support manga in database