/*
 * Copyright 2012 Artur Dryomov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ru.ming13.gambit.local.sqlite;


import android.provider.BaseColumns;


public class DbSchema
{
	private DbSchema() {
	}

	public static final class Versions
	{
		private Versions() {
		}

		public static final int CURRENT = 4;
		public static final int LATEST_WITHOUT_DECK_CARDS_CASCADE_DELETION = 3;
		public static final int LATEST_WITH_UPDATE_TIME_SUPPORT = 2;
		public static final int LATEST_WITH_CAMEL_NAMING_STYLE = 1;
	}

	public static final class Tables
	{
		private Tables() {
		}

		public static final String DECKS = "Decks";
		public static final String CARDS = "Cards";
		public static final String DB_LAST_UPDATE_TIME = "DbLastUpdateTime";
	}

	public static final class DecksColumns implements BaseColumns
	{
		private DecksColumns() {
		}

		public static final String TITLE = "title";
		public static final String CURRENT_CARD_INDEX = "current_card_index";
	}

	public static final class CardsColumns implements BaseColumns
	{
		private CardsColumns() {
		}

		public static final String DECK_ID = "deck_id";
		public static final String FRONT_SIDE_TEXT = "front_page_side";
		public static final String BACK_SIDE_TEXT = "back_page_side";
		public static final String ORDER_INDEX = "order_index";
	}

	static final class DecksColumnsParameters
	{
		private DecksColumnsParameters() {
		}

		public static final String ID = "integer primary key autoincrement not null unique";
		public static final String TITLE = "text not null unique";
		public static final String CURRENT_CARD_INDEX = "int not null";
	}

	static final class CardsColumnsParameters
	{
		private CardsColumnsParameters() {
		}

		public static final String ID = "integer primary key autoincrement not null unique";
		public static final String DECK_ID;
		public static final String FRONT_SIDE_TEXT = "text not null";
		public static final String BACK_SIDE_TEXT = "text not null";
		public static final String ORDER_INDEX = "int not null";

		static {
			final String deckForeignKeyMask = "integer not null references %s(%s) on delete cascade";

			DECK_ID = String.format(deckForeignKeyMask, Tables.DECKS, DecksColumns._ID);
		}
	}
}

@@ -1476,24 +1476,486 @@
 index%22;%0A%09%7D%0A%0A
+%09static final class DecksColumnsParameters%0A%09%7B%0A%09%09private DecksColumnsParameters() %7B%0A%09%09%7D%0A%0A%09%09public static final String _ID = %22integer primary key autoincrement not null unique%22;%0A%09%09public static final String TITLE = %22text not null unique%22;%0A%09%09public static final String CURRENT_CARD_INDEX = %22int not null%22;%0A%09%7D%0A%0A%09public static final class DecksColumnsDefaultValues%0A%09%7B%0A%09%09private DecksColumnsDefaultValues() %7B%0A%09%09%7D%0A%0A%09%09public static final int CURRENT_CARD_INDEX = 0;%0A%09%7D%0A%0A
 %09public stat
@@ -2286,314 +2286,8 @@
 %09%7D%0A%0A
-%09static final class DecksColumnsParameters%0A%09%7B%0A%09%09private DecksColumnsParameters() %7B%0A%09%09%7D%0A%0A%09%09public static final String ID = %22integer primary key autoincrement not null unique%22;%0A%09%09public static final String TITLE = %22text not null unique%22;%0A%09%09public static final String CURRENT_CARD_INDEX = %22int not null%22;%0A%09%7D%0A%0A
 %09sta
@@ -2399,16 +2399,17 @@
  String 
+_
 ID = %22in
@@ -2874,11 +2874,159 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09public static final class CardsColumnsDefaultValues%0A%09%7B%0A%09%09private CardsColumnsDefaultValues() %7B%0A%09%09%7D%0A%0A%09%09public static final int ORDER_INDEX = 0;%0A%09%7D
 %0A%7D%0A

Add database schema default values and fix formatting.