/*
 * Copyright (C) 2014 Gregory S. Meiste  <http://gregmeiste.com>
 *
 * 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 com.meiste.tempalarm.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * SQLite backend for @{link RasPiProvider}.
 *
 * Provides access to an disk-backed, SQLite datastore which is utilized by PtwProvider. This
 * database should never be accessed by other parts of the application directly.
 */
public class RasPiDatabase extends SQLiteOpenHelper {
    /** Schema version. */
    public static final int DATABASE_VERSION = 1;

    /** Filename for SQLite file. */
    public static final String DATABASE_NAME = "raspi.db";

    /** SQL statement to create reports table. */
    private static final String SQL_CREATE_REPORTS =
            "CREATE TABLE " + RasPiContract.RasPiReport.TABLE_NAME + " (" +
                    RasPiContract.RasPiReport._ID + " INTEGER PRIMARY KEY," +
                    RasPiContract.RasPiReport.COLUMN_NAME_DEGF + " INTEGER," +
                    RasPiContract.RasPiReport.COLUMN_NAME_LIGHT + " INTEGER," +
                    RasPiContract.RasPiReport.COLUMN_NAME_TIMESTAMP + " INTEGER)";

    /** SQL statement to drop reports table. */
    private static final String SQL_DELETE_REPORTS =
            "DROP TABLE IF EXISTS " + RasPiContract.RasPiReport.TABLE_NAME;

    public RasPiDatabase(final Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

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

    @Override
    public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
        // Upgrade policy is to simply to discard the data and start over
        db.execSQL(SQL_DELETE_REPORTS);
        onCreate(db);
    }
}

@@ -794,16 +794,43 @@
 elper;%0A%0A
+import timber.log.Timber;%0A%0A
 /**%0A * S
@@ -1180,17 +1180,17 @@
 RSION = 
-1
+2
 ;%0A%0A    /
@@ -1601,31 +1601,28 @@
 ME_DEGF + %22 
-INTEGER
+REAL
 ,%22 +%0A       
@@ -2138,24 +2138,63 @@
 abase db) %7B%0A
+        Timber.d(%22Creating database%22);%0A
         db.e
@@ -2234,32 +2234,32 @@
 %0A%0A    @Override%0A
-
     public void 
@@ -2335,24 +2335,119 @@
 wVersion) %7B%0A
+        Timber.d(%22Upgrading database from version %25s to version %25s%22, oldVersion, newVersion);%0A%0A
         // U

Update type of degF column in sqlite database