package models

import "chain33-pai/pkg/util"

type RaspDevHistory struct {
	//Model
	Id   int64 `json:"id" gorm:"PRIMARY_KEY"`
	Addr string `json:"addr"`
	Info string `json:"info"`
	Addtime string `json:"addtime"`
}

const MonthDevHistoryTable  = `
DROP TABLE IF EXISTS '?_rasp_miner_stat';
CREATE TABLE '?_rasp_dev_history' (
  'id' bigint(20) NOT NULL AUTO_INCREMENT,
  'addr' varchar(20) NOT NULL,
  'info' text,
  'addtime' varchar(32) DEFAULT NULL,
  PRIMARY KEY ('id')
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='上传历史'`

//
func CreateMonthDevHistoryTable()  error {
	date := util.GetMonthDate()
	return db.Raw(MonthDevHistoryTable,date,date).Error
}

func AddDevHistory(rasp *RaspDevHistory) error {
	return db.Create(rasp).Error
}
