From 5119490b3de8f8a535cf08a67c5b19fac74f227c Mon Sep 17 00:00:00 2001 From: Ross Trottier Date: Tue, 21 May 2024 11:37:55 -0600 Subject: [PATCH] refactor main --- main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 15ee2e5..c163977 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,13 @@ var slowtwitchDB *sql.DB var resultsDB *sql.DB func main() { - //Connect to databases + connectToDatabases() + migrateAuthors() + migrateCategories() + migratePosts() +} + +func connectToDatabases() { slowtwitchDatabase, slowtwitchDbErr := migration.Connect(slowtwitchAdminUser, slowtwitchAdminPass, federatedDbUrl, federatedDbPort, slowtwitchDbName+"?parseTime=true") if slowtwitchDbErr != nil { panic("Could not connect to slowtwitch database.") @@ -34,7 +40,9 @@ func main() { } else { resultsDB = resultsDatabase } +} +func migrateAuthors() { fmt.Println("Migrating Authors and Editors") editorMigration := migration.MigrateAuthors{ SlowtwitchDatabase: slowtwitchDB, @@ -45,7 +53,9 @@ func main() { } editorResults := editorMigration.Execute() fmt.Println("Migrated", len(editorResults), "Editors and Authors") +} +func migrateCategories() { fmt.Println("Migrating Categories") categoryMigration := migration.MigrateCategories{ SlowtwitchDatabase: slowtwitchDB, @@ -56,7 +66,9 @@ func main() { } categoryResults := categoryMigration.Execute() fmt.Println("Migrated", len(categoryResults), "Categories") +} +func migratePosts() { fmt.Println("Migrating Posts") postMigration := migration.MigratePosts{ SlowtwitchDatabase: slowtwitchDB,