update readme with new db migration & vendor sync command

This commit is contained in:
Danny van Kooten 2017-01-09 21:07:41 +01:00
parent fbaa8d6932
commit 13216033b8
4 changed files with 14 additions and 9 deletions

View File

@ -14,9 +14,10 @@ This is nowhere near being usable, let alone stable. Please treat as a proof of
For getting a development version of Ana up & running, please go through the following steps.
1. Rename `.env.example` to `.env` and set your database credentials.
2. Install Go dependencies: `./do install_dependencies`
3. Run the database migrations: `./do database_migrate up`
3. Compile into binary: `./do bin`
1. Create or migrate the database: `export $(cat .env | xargs) && $GOPATH/bin/migrate -url mysql://$ANA_DATABASE_USER:$ANA_DATABASE_PASSWORD@$ANA_DATABSE_HOST/$ANA_DATABASE_NAME -path ./db/migrations up`
2. Make sure you have [govendor](https://github.com/kardianos/govendor) installed.
2. Install Go dependencies: `govendor sync`
3. Compile into binary: `make`
4. Create your user account: `./ana -create_user -email="johndoe@email.com" -password="...."`
5. Run default Gulp task to build static assets: `gulp`
6. Start the webserver: `./ana -start_server -port=8080` & visit **localhost:8080** to access your analytics dashboard.

View File

@ -26,7 +26,7 @@ func Parse() {
flag.BoolVar(&runCreateUserCommand, "create_user", false, "Create a new user")
flag.BoolVar(&runDeleteUserCommand, "delete_user", false, "Deletes a user")
flag.BoolVar(&runStartServerCommand, "start_server", true, "Start the API web server, listen on -port")
flag.BoolVar(&runSeedDataCommand, "seed_data", false, "Seed the database -n times")
flag.BoolVar(&runSeedDataCommand, "db_seed", false, "Seed the database -n times")
flag.BoolVar(&runArchiveDataCommand, "archive_data", false, "Aggregates data into daily totals")
flag.StringVar(&emailArg, "email", "", "Email address")
flag.StringVar(&passwordArg, "password", "", "Password")

View File

@ -97,7 +97,7 @@ func calculatePointPercentages(points []Point, total int) []Point {
for i, d := range points {
points[i].PercentageValue = float64(d.Value) / float64(total) * 100
}
return points
}

View File

@ -10,9 +10,7 @@ import (
var Conn *sql.DB
// SetupDatabaseConnection opens up & returns a SQL connection
func SetupDatabaseConnection() (*sql.DB, error) {
var err error
func getDSN() string {
var dsn = fmt.Sprintf(
"%s:%s@%s/%s",
os.Getenv("ANA_DATABASE_USER"),
@ -20,8 +18,14 @@ func SetupDatabaseConnection() (*sql.DB, error) {
os.Getenv("ANA_DATABASE_HOST"),
os.Getenv("ANA_DATABASE_NAME"),
)
return dsn
}
Conn, err = sql.Open("mysql", dsn)
// SetupDatabaseConnection opens up & returns a SQL connection
func SetupDatabaseConnection() (*sql.DB, error) {
var err error
Conn, err = sql.Open("mysql", getDSN())
if err != nil {
return nil, err
}