-
-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Describe the bug
Hey, guys,
During the deployment of my app to the server, I decided to drop docker (because its minimum system requirements are 4GB of RAM while I want to use a cheaper server with less RAM) and change to MySQL DB. I successfully connected the app with DB, it compiles, starts, etc.
But there is a strange problem with UUID types. Before moving to MySQL the app was working pretty fine - my UUIDs were successfully generated before adding an object in the DB. Now I do get something like "ùïðé¡ Eô + u:Bh " instead of normal UUID in the id cell of the table.
More to the point, the table _fluent_migrations also has the same style of corrupted IDs of the applied migrations. So, looks like that is a global problem of my app and not because I set the wrong type for the field in the table.
How can I get the UUIDs back to normal behavior when I use MySQL?
To Reproduce
Same behavior on MacOS and Ubuntu. The only requirement is to use MySQL.
- My class which is stored in DB has the id variable:
MyClass: Model {
static var schema: String = "myscheme"
@ID(key: .id) var id: UUID?
... other
}
- Migration:
struct MyClassTable: AsyncMigration {
func prepare(on database: FluentKit.Database) async throws {
try await database.schema("myscheme")
.id()
.... other
}
}
- configure method of configure.swift:
var tls = TLSConfiguration.makeClientConfiguration()
tls.certificateVerification = .none
app.databases.use(DatabaseConfigurationFactory.mysql(
hostname: Environment.get("DATABASE_HOST") ?? "0.0.0.0",
port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? MySQLConfiguration.ianaPortNumber,
username: Environment.get("DATABASE_USERNAME") ?? "username",
password: Environment.get("DATABASE_PASSWORD") ?? "password",
database: Environment.get("DATABASE_NAME") ?? "tablename",
tlsConfiguration: tls
), as: .mysql)
Expected behavior
I expect to get F9EFF0E9-A19D-45F4-862B-1D753A426898 this kind of UUIDs in the MySQL table instead of ùïðé¡ Eô + u:Bh ".
Environment
- Vapor Framework version: 4.92.4
- Vapor Toolbox version: 18.7.4
- OS version: Ventura 13.6.1
- Additional package: fluent-mysql-driver 4.0.0
Additional context
I am working on my first Vapor project. So, I mean, I am a newbie and this can be not a bug but my low skill. In this case please help me to fix it.