refactor main
This commit is contained in:
parent
cb6dd813f5
commit
5119490b3d
14
main.go
14
main.go
@ -21,7 +21,13 @@ var slowtwitchDB *sql.DB
|
|||||||
var resultsDB *sql.DB
|
var resultsDB *sql.DB
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
//Connect to databases
|
connectToDatabases()
|
||||||
|
migrateAuthors()
|
||||||
|
migrateCategories()
|
||||||
|
migratePosts()
|
||||||
|
}
|
||||||
|
|
||||||
|
func connectToDatabases() {
|
||||||
slowtwitchDatabase, slowtwitchDbErr := migration.Connect(slowtwitchAdminUser, slowtwitchAdminPass, federatedDbUrl, federatedDbPort, slowtwitchDbName+"?parseTime=true")
|
slowtwitchDatabase, slowtwitchDbErr := migration.Connect(slowtwitchAdminUser, slowtwitchAdminPass, federatedDbUrl, federatedDbPort, slowtwitchDbName+"?parseTime=true")
|
||||||
if slowtwitchDbErr != nil {
|
if slowtwitchDbErr != nil {
|
||||||
panic("Could not connect to slowtwitch database.")
|
panic("Could not connect to slowtwitch database.")
|
||||||
@ -34,7 +40,9 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
resultsDB = resultsDatabase
|
resultsDB = resultsDatabase
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func migrateAuthors() {
|
||||||
fmt.Println("Migrating Authors and Editors")
|
fmt.Println("Migrating Authors and Editors")
|
||||||
editorMigration := migration.MigrateAuthors{
|
editorMigration := migration.MigrateAuthors{
|
||||||
SlowtwitchDatabase: slowtwitchDB,
|
SlowtwitchDatabase: slowtwitchDB,
|
||||||
@ -45,7 +53,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
editorResults := editorMigration.Execute()
|
editorResults := editorMigration.Execute()
|
||||||
fmt.Println("Migrated", len(editorResults), "Editors and Authors")
|
fmt.Println("Migrated", len(editorResults), "Editors and Authors")
|
||||||
|
}
|
||||||
|
|
||||||
|
func migrateCategories() {
|
||||||
fmt.Println("Migrating Categories")
|
fmt.Println("Migrating Categories")
|
||||||
categoryMigration := migration.MigrateCategories{
|
categoryMigration := migration.MigrateCategories{
|
||||||
SlowtwitchDatabase: slowtwitchDB,
|
SlowtwitchDatabase: slowtwitchDB,
|
||||||
@ -56,7 +66,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
categoryResults := categoryMigration.Execute()
|
categoryResults := categoryMigration.Execute()
|
||||||
fmt.Println("Migrated", len(categoryResults), "Categories")
|
fmt.Println("Migrated", len(categoryResults), "Categories")
|
||||||
|
}
|
||||||
|
|
||||||
|
func migratePosts() {
|
||||||
fmt.Println("Migrating Posts")
|
fmt.Println("Migrating Posts")
|
||||||
postMigration := migration.MigratePosts{
|
postMigration := migration.MigratePosts{
|
||||||
SlowtwitchDatabase: slowtwitchDB,
|
SlowtwitchDatabase: slowtwitchDB,
|
||||||
|
Loading…
Reference in New Issue
Block a user