Beispiel #1
0
func InitAllTables(dbm *gorp.DbMap) error {
	defineAllTables(dbm)
	if err := dbm.CreateTablesIfNotExists(); err != nil {
		return err
	}

	txn, err := dbm.Begin()
	if err != nil {
		return err
	}
	defer txn.Rollback()

	count, err := CountRows("loglevel", "id", txn)
	if err != nil {
		return err
	}
	if count == 0 {
		InitLoglevelTable(txn)
	}

	count, err = CountRows("utmstatus", "id", txn)
	if err != nil {
		return err
	}
	if count == 0 {
		InitUtmstatusTable(txn)
	}

	txn.Commit()
	return nil
}