Make all slog errors uniform (lowercase)

This commit is contained in:
Maximilian
2023-09-03 15:56:35 -05:00
parent ed712a5344
commit e87f14bcbf
6 changed files with 22 additions and 22 deletions

View File

@ -24,7 +24,7 @@ func Connect(app *app.App) *sql.DB {
panic(err)
}
slog.Info("Connected to database successfully on " + app.Config.Db.Ip + ":" + app.Config.Db.Port + " using database " + app.Config.Db.Name)
slog.Info("connected to database successfully on " + app.Config.Db.Ip + ":" + app.Config.Db.Port + " using database " + app.Config.Db.Name)
return db
}

View File

@ -39,23 +39,23 @@ func createTable(app *app.App, tableName string) error {
var tableExists bool
err := app.Db.QueryRow("SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relname ~ $1 AND pg_catalog.pg_table_is_visible(c.oid))", "^"+tableName+"$").Scan(&tableExists)
if err != nil {
slog.Error("Error checking if table exists: " + tableName)
slog.Error("error checking if table exists: " + tableName)
return err
}
if tableExists {
slog.Info("Table already exists: " + tableName)
slog.Info("table already exists: " + tableName)
return nil
} else {
sanitizedTableQuery := fmt.Sprintf("CREATE TABLE IF NOT EXISTS \"%s\" (\"Id\" serial primary key)", tableName)
_, err := app.Db.Query(sanitizedTableQuery)
if err != nil {
slog.Error("Error creating table: " + tableName)
slog.Error("error creating table: " + tableName)
return err
}
slog.Info("Table created successfully: " + tableName)
slog.Info("table created successfully: " + tableName)
return nil
}
}
@ -65,17 +65,17 @@ func createColumn(app *app.App, tableName, columnName, columnType string) error
var columnExists bool
err := app.Db.QueryRow("SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = $1 AND column_name = $2)", tableName, columnName).Scan(&columnExists)
if err != nil {
slog.Error("Error checking if column exists: " + columnName + " in table: " + tableName)
slog.Error("error checking if column exists: " + columnName + " in table: " + tableName)
return err
}
if columnExists {
slog.Info("Column already exists: " + columnName + " in table: " + tableName)
slog.Info("column already exists: " + columnName + " in table: " + tableName)
return nil
} else {
postgresType, err := getPostgresType(columnType)
if err != nil {
slog.Error("Error creating column: " + columnName + " in table: " + tableName + " with type: " + postgresType)
slog.Error("error creating column: " + columnName + " in table: " + tableName + " with type: " + postgresType)
return err
}
@ -84,11 +84,11 @@ func createColumn(app *app.App, tableName, columnName, columnType string) error
_, err = app.Db.Query(query)
if err != nil {
slog.Error("Error creating column: " + columnName + " in table: " + tableName + " with type: " + postgresType)
slog.Error("error creating column: " + columnName + " in table: " + tableName + " with type: " + postgresType)
return err
}
slog.Info("Column created successfully:", columnName)
slog.Info("column created successfully:", columnName)
return nil
}