Skip to content

Improve interop between windows <-> linux mariadb development workflow #6972

Open

Description

@pantharshit00

Problem

This issue is outcome of discussion in #6962

Right now when you create migrations in Windows Maria db, migrate tends to lowercase certain statements like ALTER TABLE. Either this is a bug or we should improve the user experience here. When user tries to deploy this migration to their linux production environment, it will fail.

Suggested solution

  • Generate migrations with same case on every system.
  • Add a flag in migrations.toml that migration was generated on windows and using lowercase names and somehow fix those when migrating the same db engine on linux.

Alternatives

Warn the user about this quirk and ask them to use docker/wsl/hosted mariadb instance.

Additional context

#6962

Activity

  1. tomhoule commented on May 19, 2021

    @tomhoule
    Contributor

    This is an artifact of how mysql lowercases table names automatically. We can write a big warning to migration files that mysql on windows behaves that way, and it's super risky if you are not deploying to a windows installation of mysql in production.

  2. added this to the 2.24.0 milestone on May 19, 2021
  3. janpio commented on May 28, 2021

    @janpio
    Contributor

    Can we somehow figure out when MySQL/MariaDB are doing that because of how they are configured? We tell them to do User but they actually do user - only in that case we could throw a fat warning or error and link people to a documentation page that explains what is going on and how to fix it. (Setting a configuration value in MySQL does fix it, right?)

  4. janpio commented on May 28, 2021

    @janpio
    Contributor

    Related: #6972 (some additional information about MySQL configuration causing this potentially)

  5. hrueger commented on Feb 26, 2022

    @hrueger

    It's interesting that the casing in the migration warning comment is not even consistent:
    The following mihration file was just created by npx prisma migrate dev:

    /*
      Warnings:
    
      - You are about to drop the column `redacted` on the `deviceperspective` table. All the data in the column will be lost.
      - Added the required column `redacted` to the `DevicePerspective` table without a default value. This is not possible if the table is not empty.
      - Added the required column `redacted` to the `DevicePerspective` table without a default value. This is not possible if the table is not empty.
      - Added the required column `redacted` to the `DevicePerspective` table without a default value. This is not possible if the table is not empty.
      - Added the required column `redacted` to the `DevicePerspective` table without a default value. This is not possible if the table is not empty.
      - Added the required column `redacted` to the `DevicePerspective` table without a default value. This is not possible if the table is not empty.
      - Added the required column `redacted` to the `DevicePerspective` table without a default value. This is not possible if the table is not empty.
      - Added the required column `redacted` to the `DevicePerspective` table without a default value. This is not possible if the table is not empty.
    
    */
    -- AlterTable
    ALTER TABLE `deviceperspective` DROP COLUMN `redacted`,
        ADD COLUMN `redacted` DOUBLE NOT NULL,
        ADD COLUMN `redacted` VARCHAR(9) NOT NULL,
        ADD COLUMN `redacted` BOOLEAN NOT NULL,
        ADD COLUMN `redacted` DOUBLE NOT NULL,
        ADD COLUMN `redacted` DOUBLE NOT NULL,
        ADD COLUMN `redacted` BOOLEAN NOT NULL,
        ADD COLUMN `redacted` DOUBLE NOT NULL;

    Just one question: (At least my) MariaDB on Windows ignores it if I use a PascalCase table name in my db. It works just fine.
    Is anything preventing us from just using PascalCase in the migration everywhere?

  6. janpio commented on Feb 26, 2022

    @janpio
    Contributor

    Somewhere it gets conflicting information, and just runs with it.
    Can you create a new bug report issue please with your description above and the additional information it asks for? Then we can look deeper into what is going on here. Thanks!

  7. hrueger commented on Feb 26, 2022

    @hrueger

    Sure! Working on it.

  8. hrueger commented on Feb 26, 2022

    @hrueger

    See #12053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions