ariga / atlas

Manage your database schema as code
https://atlasgo.io
Apache License 2.0
5.32k stars 235 forks source link

atlas-operator collation mismatch when using MariaDB #2817

Open marc0777 opened 4 weeks ago

marc0777 commented 4 weeks ago

Hello, I've been trying to use atlas-operator on k8s to handle migrations on a MariaDB database.

By default the operator tries to spin up a database instance as dev db. For MariaDB targets the instance created is MySQL, which uses the utf8mb4_0900_ai_ci collation, while our db instead uses utf8mb4_general_ci. The only way to make it work seems to be to explicitly set collation on the schema, and set policy.diff.skip.modify_schema: true.

Is this the expected behaviour, or am I missing something?

This is the configuration I've deployed on my cluster:

apiVersion: db.atlasgo.io/v1alpha1
kind: AtlasSchema
metadata:
  name: myapp
spec:
  urlFrom:
    secretKeyRef:
      key: url
      name: mysql-credentials
  schema:
    configMapKeyRef:
      key: schema.sql
      name: mysql-schema
  policy:
    lint:
      destructive:
        error: true
    diff:
      skip:
        drop_column: true
        modify_schema: true
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: mysql-schema
data:
  schema.sql: |
    create table users (
      id int not null auto_increment,
      name varchar(255) not null,
      email varchar(255) unique not null,
      short_bio varchar(255) not null,
      primary key (id)
    ) collate='utf8mb4_general_ci' charset='utf8mb4';

Thanks, Marco

giautm commented 4 weeks ago

Hey @marc0777, thank you for report this. We'll soon support for custom docker image on devdb, also allow to pull the image from private registry; It should resolve your issue with different environment.