Skip to content

Commit

Permalink
scripts: add a script to migrate the DB
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk Kalinowski committed Mar 2, 2021
1 parent a481405 commit 5d441a1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/migrate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"context"
"database/sql"
"fmt"
"log"

_ "github.com/go-sql-driver/mysql"

"github.com/cycloidio/terracost/mysql"
)

func main() {
db, err := sql.Open("mysql", "root:terracost@tcp(localhost:33060)/terracost_test?multiStatements=true")
if err != nil {
log.Fatal(err)
}

if err := mysql.Migrate(context.Background(), db, "_migrations"); err != nil {
log.Fatal(err)
}

fmt.Println("Migrated successfully!")
}

0 comments on commit 5d441a1

Please sign in to comment.