package com.phlx.anchorcollect.db;

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

import com.github.yuweiguocn.library.greendao.MigrationHelper;
import com.phlx.anchorcollect.db.gen.BreedingRecordDetailEntityDao;
import com.phlx.anchorcollect.db.gen.BreedingRecordEntityDao;
import com.phlx.anchorcollect.db.gen.CattleResumeEntityDao;
import com.phlx.anchorcollect.db.gen.DaoMaster;
import com.phlx.anchorcollect.db.gen.DictEntityDao;
import com.phlx.anchorcollect.db.gen.ImmuneBatchDetailEntityDao;
import com.phlx.anchorcollect.db.gen.ImmuneBatchEntityDao;
import com.phlx.anchorcollect.db.gen.MedicalRecordEntityDao;
import com.phlx.anchorcollect.db.gen.PerformanceEntityDao;
import com.phlx.anchorcollect.db.gen.WeightManEntityDao;

import org.greenrobot.greendao.database.Database;

public class MyOpenHelper extends DaoMaster.DevOpenHelper {

    public MyOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
        super(context, name, factory);
    }

    @Override
    public void onUpgrade(Database db, int oldVersion, int newVersion) {
        //把需要管理的数据库表DAO作为最后一个参数传入到方法中
        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);
            }
        },
                CattleResumeEntityDao.class,
                PerformanceEntityDao.class,
                WeightManEntityDao.class,
                MedicalRecordEntityDao.class,
                ImmuneBatchEntityDao.class,
                ImmuneBatchDetailEntityDao.class,
                BreedingRecordEntityDao.class,
                BreedingRecordDetailEntityDao.class,
                DictEntityDao.class
//                CardEntityDao.class
//                DivisionEntityDao.class,  HarmlessDao.class,  HarmlessDetailDao.class,  LabelDao.class
//                ,  MarkingDao.class,  QuarantineDao.class,  QuarantineDetailDao.class
//                ,  TreatmentMethodDao.class,  UnitDao.class,  VarietyDao.class,  VeterinaryDao.class
//                ,  VillusBuyEntityDao.class,  VillusGaugeEntityDao.class, EntryRegistrationEntityDao.class, CacheLabelDao.class
        );

    }

}
