Comments (9)
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.
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.
This feels like a gorp bug. Sql-migrate uses CreateTablesIfNotExists
, so it shouldn't fail.
from sql-migrate.
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.
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.
Yes.
OSX Yosemite MySQL 5.6.16.
from sql-migrate.
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.
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.
The issue is tracked on go-gorp/gorp#284
from sql-migrate.
Related Issues (20)
- Migration not applied
- IgnoreUnknown is not working
- SetTable fails race detector HOT 3
- Support for multiple migration dirs
- Where may I ask questions? HOT 2
- gorp retracted by module author warning HOT 2
- Support for exclusive connection while executing migration HOT 3
- ToApply doesn't consider IgnoreUnknown flags when apply migrations up dir HOT 1
- Multiple `migrate Up` blocks in a single file? HOT 1
- Migrate transactions for multiple shards HOT 5
- [Proposal] Addition of 'reset' to sql-migrate command HOT 3
- Go install fails on Go 1.19 HOT 5
- schema field in dbconfig.yml being ignored
- Doing a migrate down when there is a migration βholeβ is corrupting the database
- MemoryMigrationSource execution order is wrong HOT 2
- [BUG] Missing integrity checks on migrations lead to corrupt DB schema state HOT 3
- Logic Bug with ExecVersion HOT 1
- Possible release to fix build issue on Alpine Linux HOT 1
- Migration failed: pq: unterminated dollar-quoted string at or near HOT 1
- sql-migrate in docker registry
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sql-migrate.