librespeed / speedtest-go

Go backend for LibreSpeed
GNU Lesser General Public License v3.0
706 stars 153 forks source link

MySQL data types need to be refactored #13

Open alexanderfefelov opened 3 years ago

alexanderfefelov commented 3 years ago

Environment

Links

maddie commented 3 years ago

Sorry for the late reply, I've been held up by work lately.

I agree that the data types aren't quite accurate, but I'm not really sure that I'd want to implement this change now, because:

  1. It would break current users if the Go code changes (types aren't compatible)
  2. It's working fine for now (well...)
  3. I can't really think of the difference between using text and numbers if we're just "showing them in the stats page", and if one wants to use the numbers for statistical use, there are still a lot of ways to write simple code to parse the string into numbers

I'll leave it open for now, but implementing this change is very unlikely in the near future. Maybe in v2?

alexanderfefelov commented 3 years ago

Ping and co generates numerical data by nature. Using numerical data allows the LibreSpeed database to be treated as a time series database without any additional coding.

maddie commented 3 years ago

Yes, I understand, but in the code:

https://github.com/librespeed/speedtest-go/blob/c815103e20b0f090ee8973866bc85ffafe8dc0c1/database/mysql/mysql.go#L30-L46

... fields in schema.TelemetryData are all strings. If this change is to be implemented, users with old schemas will not be able to insert/load records, unless they recreate the database. This would qualify as a breaking change.

Enrico204 commented 3 years ago

This might be fixed with a migration: the code can detect this change at runtime and ask the user to migrate (or automatically migrate)