Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change delimiter in mysql migrations #1036

Open
jessebye opened this issue Jan 25, 2024 · 1 comment
Open

Unable to change delimiter in mysql migrations #1036

jessebye opened this issue Jan 25, 2024 · 1 comment

Comments

@jessebye
Copy link

Describe the Bug

In MySQL migrations, it is typical to set the value of the delimiter to a different value than ; when creating a stored procedure. The official docs even recommend doing this.

However, when trying to use such a migration with migrate, it results in an error:

 DELIMITER ; (details: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER ^

CREATE PROCEDURE myProcedure()

Other delimiters likewise fail (tested with // and FOOBAR).

Steps to Reproduce
Steps to reproduce the behavior:

  1. Create a migration like:
    DELIMITER ^
    CREATE PROCEDURE myProcedure()
    BEGIN
    END^
    DELIMITER ;
    
  2. Run migrate
  3. See error.

Expected Behavior
migrate should run the migration correctly with no errors.

Migrate Version
4.17.0

Loaded Source Drivers
go-bindata, file, github, github-ee, godoc-vfs, s3, gcs, gitlab, bitbucket

Loaded Database Drivers
clickhouse, cockroach, crdb-postgres, yugabyte, ysql, neo4j, stub, firebird, cassandra, mysql, redshift, yugabytedb, sqlserver, pgx, pgx4, postgresql, mongodb+srv, spanner, firebirdsql, pgx5, cockroachdb, postgres, rqlite, mongodb

Go Version
n/a

Stacktrace
n/a

Additional context
n/a

@jessebye
Copy link
Author

As a workaround, I found that you can add multiStatements=true to the connection string. Then, procedures can be created without the use of the delimiter:

CREATE PROCEDURE myProcedure()
BEGIN
END

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant