func RegSchema(dbmap *gorp.DbMap) { dbmap.AddTable(Entry{}).SetKeys(true, "Id") err := dbmap.CreateTables() if err != nil { fmt.Println(err) return } }
// Serve starts the RPC server on listener. Serve blocks. func Serve(listener net.Listener, dbmap *gorp.DbMap) error { dbmap.AddTable(UniVar{}).SetKeys(false, "Name") err := dbmap.CreateTablesIfNotExists() if err != nil { return err } server := &Elvishd{dbmap} rpc.Register(server) rpc.Accept(listener) return nil }
func AddTables(dbm *gorp.DbMap) { dbm.AddTable(Game{}).SetKeys(true, "Id") dbm.AddTable(Organization{}).SetKeys(true, "Id") dbm.AddTable(Player{}).SetKeys(true, "Id") dbm.AddTable(User{}).SetKeys(true, "Id") dbm.AddTable(Oz{}).SetKeys(true, "Id") dbm.AddTable(Tag{}).SetKeys(true, "Id") dbm.AddTable(Member{}).SetKeys(true, "Id") dbm.AddTable(Event{}).SetKeys(true, "Id") dbm.AddTableWithName(EventType{}, "event_type").SetKeys(true, "Id") dbm.AddTableWithName(EventTag{}, "event_tag") dbm.AddTableWithName(EventPlayer{}, "event_player") dbm.AddTableWithName(EventRole{}, "event_role").SetKeys(true, "Id") dbm.AddTableWithName(EventToPlayer{}, "event_to_player").SetKeys(true, "Id") dbm.AddTableWithName(EventToGame{}, "event_to_game").SetKeys(true, "Id") dbm.AddTableWithName(HumanCode{}, "human_code").SetKeys(false, "Id") dbm.AddTableWithName(OzPool{}, "oz_pool").SetKeys(true, "Id") dbm.AddTableWithName(PasswordReset{}, "password_reset") }
// using 'define' and not 'create' - because db is not actually created until call to Dbm.CreateTablesIfNotExists() func defineBidItemTable(dbm *gorp.DbMap) { // set "id" as primary key and autoincrement t := dbm.AddTable(models.BidItem{}).SetKeys(true, "id") // e.g. VARCHAR(25) t.ColMap("name").SetMaxSize(25) }
func RegSchema(dbmap *gorp.DbMap) { dbmap.AddTable(Category{}).SetKeys(true, "Id") dbmap.AddTable(EntryInCategory{}).SetKeys(true, "Id") dbmap.CreateTables() }