Skip to content

Wrap migrations into a transaction, if possible #7641

Closed
prisma/prisma-engines
#2080

Description

@pimeys

SQL Server allows modifying the schema in a transaction, which is something our other databases don't let you to do. It adds a certain security though, if we could wrap the whole migration into a transaction, so we might want to implement this for SQL Server.

Activity

  1. tomhoule commented on Jun 17, 2021

    @tomhoule
    Contributor

    Maybe we don't want to do this by default because it doesn't scale to very big migrations (presumably, not very familiar with MSSQL). But at least offering the option in a convenient way is definitely something we can do.

  2. tomhoule commented on Jul 1, 2021

    @tomhoule
    Contributor

    Moved to "Before GA" in the sense that we should make a decision on this before GA, because changing our default (transactions or not) would be breaking for users.

    • If we decide after GA that we want migrations to be wrapped in transactions, and mssql is anything like postgres and users started using transactions themselves inside migration scripts, their existing migrations will break.
    • And the reverse is also bad, because operations that would have been rolled back before wouldn't be rolled back anymore.

    Factors to take into account:

    • Entity Framework does it, so existing SQL Server users could be expecting it.
  3. janpio commented on Jul 5, 2021

    @janpio
    Contributor

    Note from an internal discussion: Automatic rollback of a migration via transaction rollback on failure, might have implications on the migrations table. By default we would still log the migration as failed, which could/would lead to reset messaging on future Migrate commands.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech/engines/migration enginetopic: sql server

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions