func setupDatabase() (err error) {
	err = rethink.DbCreate(TODO_DB).Run(session).Exec()
	if err != nil {
		// TODO: Check if the failure is that the database already exists
		return
	}

	err = rethink.TableCreate(TODO_TABLE).Run(session).Exec()
	if err != nil {
		// TODO: Check if the failure is that the table already exists
		return
	}
	return nil
}
예제 #2
0
파일: main.go 프로젝트: rbl00/go_marks
func initDb() {
	session, err := r.Connect(os.Getenv("WERCKER_RETHINKDB_URL"), "gettingstarted")
	if err != nil {
		log.Fatal(err)
		return
	}

	err = r.DbCreate("gettingstarted").Run(session).Exec()
	if err != nil {
		log.Println(err)
	}

	err = r.TableCreate("bookmarks").Run(session).Exec()
	if err != nil {
		log.Println(err)
	}

	sessionArray = append(sessionArray, session)
}
예제 #3
0
func (c *Connection) InitDatabase() {
	rethinkgo.DbCreate("magnet").Run(c.session).Exec()
	rethinkgo.TableCreate("users").Run(c.session).Exec()
	rethinkgo.TableCreate("bookmarks").Run(c.session).Exec()
	rethinkgo.TableCreate("sessions").Run(c.session).Exec()
}