package com.touchableheroes.drafts.db.cupboard.xt;

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


import java.util.Iterator;

import static nl.qbusict.cupboard.CupboardFactory.cupboard;

/**
 * Created by asiebert on 23.02.16.
 */
public class CupboardSQLiteDBHelper extends SQLiteOpenHelper {

    private final DbConfig config;

    public CupboardSQLiteDBHelper(final Context ctx,
                                  final DbConfig config) {
        super(ctx, config.name(), null, config.version());

        this.config = config;
    }

    @Override
    public void onConfigure(final SQLiteDatabase db) {
        bindEntities( );
        super.onConfigure(db);
    }

    private void bindEntities() {
        for( final Class<?> entity : config.entities() ) {
            cupboard().register( entity );
        }
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        for ( final Class<?> entity : config.entities()) {
            cupboard().register( entity );
        }

//        cupboard().withDatabase(db).dropAllTables();
        cupboard().withDatabase(db).createTables();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // dev mode:
        cupboard().withDatabase(db).dropAllTables();
        cupboard().withDatabase(db).createTables();

        // prod mode:
        // cupboard().withDatabase(db).upgradeTables();
    }

}
@@ -618,133 +618,25 @@
     
-%7D%0A%0A    @Override%0A    public void onConfigure(final SQLiteDatabase db) %7B%0A        bindEntities( );%0A        super.onConfigure(db
+    bindEntities(
 );%0A 
@@ -637,24 +637,25 @@
 s();%0A    %7D%0A%0A
+%0A
     private 
@@ -834,16 +834,22 @@
 nCreate(
+final 
 SQLiteDa
@@ -864,176 +864,8 @@
 b) %7B
-%0A        for ( final Class%3C?%3E entity : config.entities()) %7B%0A            cupboard().register( entity );%0A        %7D%0A%0A//        cupboard().withDatabase(db).dropAllTables();
 %0A   

remove unused register entities code