Coder Social home page Coder Social logo

Comments (9)

JalfResi avatar JalfResi commented on June 7, 2024

IS there anymore information you need from me to help diagnose this issue? The Open function gets called by main() once on app start. If clear the schema, run the app, the migrations all go in correctly. If I add a new migration or run the app a second time with an existing up to date schema, the above error message occurs. Should I be check to see if the migration table is up to date somehow before attempting to run any migrations?

from sql-migrate.

JalfResi avatar JalfResi commented on June 7, 2024

Got to the bottom of this at last!

Turns out my DSN had strict=true (MySQL strict mode on), where all "failed" creates, which normally result in a warning, are promoted to errors,hence the error message.

I'm not sure if sql-migrate should acknowledge this; should the call to create the migrations table fail (as it may if the migrations table already exists), and if strict mode is on, should sql-migrate move on without returning an error? After all, the user may want strict mode on for their own queries, but is uninterested if the sql-migrate table already exists; they want to know if the newer migrations were successful or not.

So basically, sql-migrate cannot be used with strict mode on! It might be worth mentioning this in the documentation/read-me too.

from sql-migrate.

rubenv avatar rubenv commented on June 7, 2024

This feels like a gorp bug. Sql-migrate uses CreateTablesIfNotExists, so it shouldn't fail.

from sql-migrate.

JalfResi avatar JalfResi commented on June 7, 2024

Good point. Not sure how gorp would resolve this though; if you use gorp with strict mode on then you may WANT an error if CreateTablesIfNotExists fails. However, in the context of sql-migrate, that situation is NOT an error. Maybe if sql-migrate switched off strict mode before make the call to CreateTablesIfNotExists, then switched it back on afterwards (if strict mode was on to begin with)?

from sql-migrate.

rubenv avatar rubenv commented on June 7, 2024

I might be misunderstanding things here. Are you saying that "CREATE TABLE ... IF NOT EXISTS" causes a failure in MySQL strict mode if the table already exists?

from sql-migrate.

JalfResi avatar JalfResi commented on June 7, 2024

Yes.

OSX Yosemite MySQL 5.6.16.

from sql-migrate.

rubenv avatar rubenv commented on June 7, 2024

Right, that's just idiotic behavior. The whole point of "IF NOT EXISTS" is to safely add a table if it doesn't already exist.

My advice: don't use MySQL strict mode, apparently it breaks SQL behavior, so it's not worth your time.

from sql-migrate.

JalfResi avatar JalfResi commented on June 7, 2024

Exactly. I've had to remove the strict flag for now to get my program working, but I really would like to work with strict mode as it prevents MySQL from truncating data, screwing up dates etc.

from sql-migrate.

fgrosse avatar fgrosse commented on June 7, 2024

The issue is tracked on go-gorp/gorp#284

from sql-migrate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.