package com.tofly.ghrq_route.module.sqlite;

import android.content.Context;

import com.github.yuweiguocn.library.greendao.MigrationHelper;
import com.tofly.data.sql.dao.BuildHandleDataBeanDao;
import com.tofly.data.sql.dao.BuildSignDataBeanDao;
import com.tofly.data.sql.dao.CheckGPSDataBeanDao;
import com.tofly.data.sql.dao.DaoMaster;
import com.tofly.data.sql.dao.DeviceInfoBeanDao;
import com.tofly.data.sql.dao.DownloadDataDao;
import com.tofly.data.sql.dao.FieldsBeanDao;
import com.tofly.data.sql.dao.GPSDataBeanDao;
import com.tofly.data.sql.dao.JobBeanDao;
import com.tofly.data.sql.dao.LocalPlanRecordBeanDao;
import com.tofly.data.sql.dao.LocationGPSDataBeanDao;
import com.tofly.data.sql.dao.MaintainAdjustParamDao;
import com.tofly.data.sql.dao.MaintainCommonParamDao;
import com.tofly.data.sql.dao.MapUrlConfigDataBeanDao;
import com.tofly.data.sql.dao.OfflinePathBeanDao;
import com.tofly.data.sql.dao.PlanPointRepairDao;
import com.tofly.data.sql.dao.SignDataBeanDao;
import com.tofly.data.sql.dao.SketchBeanDao;
import com.tofly.data.sql.dao.SystemConfigBeanDao;
import com.tofly.data.sql.dao.TroubleAudioBeanDao;
import com.tofly.data.sql.dao.TroubleBeanDao;
import com.tofly.data.sql.dao.TroublePictureBeanDao;
import com.tofly.data.sql.dao.TroubleRiskLevelBeanDao;
import com.tofly.data.sql.dao.TroubleTypeBeanDao;
import com.tofly.data.sql.dao.UserBeanDao;
import com.tofly.data.sql.dao.UserMapDataBeanDao;
import com.tofly.data.sql.dao.UserOnlineMapDataBeanDao;

import org.greenrobot.greendao.database.Database;

/**
 * Created by Amu on 2017/12/22.
 */

class UserOpenHelper extends DaoMaster.OpenHelper {
    public UserOpenHelper(Context context, String dbName) {
        super(context, dbName);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {
            @Override
            public void onCreateAllTables(Database db, boolean ifNotExists) {
                DaoMaster.createAllTables(db, ifNotExists);
            }

            @Override
            public void onDropAllTables(Database db, boolean ifExists) {
                DaoMaster.dropAllTables(db, ifExists);
            }
        }, BuildHandleDataBeanDao.class, BuildSignDataBeanDao.class, CheckGPSDataBeanDao.class,
                DeviceInfoBeanDao.class, DownloadDataDao.class, GPSDataBeanDao.class,
                LocalPlanRecordBeanDao.class, LocationGPSDataBeanDao.class, MapUrlConfigDataBeanDao.class,
                OfflinePathBeanDao.class, PlanPointRepairDao.class, SignDataBeanDao.class, SystemConfigBeanDao.class,
                TroubleAudioBeanDao.class, TroubleBeanDao.class, TroublePictureBeanDao.class, TroubleTypeBeanDao.class,
                TroubleRiskLevelBeanDao.class, UserBeanDao.class, UserMapDataBeanDao.class, JobBeanDao.class,
                SketchBeanDao.class, FieldsBeanDao.class, MaintainCommonParamDao.class, MaintainAdjustParamDao.class,
                UserOnlineMapDataBeanDao.class);
/*        switch (oldVersion) {
            case 1:
            case 2:
            case 3: {
                DaoMaster.dropAllTables(db, true);
                onCreate(db);
            }
            break;
            default: {
                DaoMaster.dropAllTables(db, true);
                onCreate(db);
            }
            break;
        }*/
    }
}
