Comments (22)
What about this?
https://github.com/go-sql-driver/mysql#multistatements
from migrate.
panic: sql: Register called twice for driver mysql
goroutine 1 [running]:
database/sql.Register(0x71ff90, 0x5, 0xc6c920, 0xafb488)
/usr/local/go/src/database/sql/sql.go:41 +0x181
github.com/go-sql-driver/mysql.init.1()
/Users/alessiocavaleri/Documents/Code/go/src/github.com/go-sql-driver/mysql/driver.go:148 +0x71
github.com/go-sql-driver/mysql.init()
/Users/alessiocavaleri/Documents/Code/go/src/github.com/go-sql-driver/mysql/utils.go:973 +0x61c
github.com/mattes/migrate/driver/mysql.init()
/Users/alessiocavaleri/Documents/Code/go/src/github.com/mattes/migrate/driver/mysql/mysql.go:185 +0x5e
github.com/empatica/web_embrace_api/database.init()
/Users/alessiocavaleri/Documents/Code/go/src/github.com/empatica/web_embrace_api/database/userWatchdog.go:65 +0x6c
github.com/empatica/web_embrace_api/controllers.init()
/Users/alessiocavaleri/Documents/Code/go/src/github.com/empatica/web_embrace_api/controllers/zipperController.go:53 +0x79 main.init()
/Users/alessiocavaleri/Documents/Code/go/src/github.com/empatica/web_embrace_api/embrace_api/main.go:75 +0x62
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1696 +0x1
from migrate.
https://github.com/go-sql-driver/mysql/
from migrate.
see https://github.com/mattes/migrate/tree/mysql
from migrate.
I added experimental support for mysql migrations. The issue is that there is no golang mysql driver that supports multiple sql statements per query. So the mysql driver splits sql statements by semicolons ;
.
Goose uses some custom split strings to format sql migrations. I really would like to avoid that. Is there a golang mysql driver that supports multiple sql statements?
from migrate.
Hi
I like what you did, great job! Keep up the good work.
I came here to ask you a little question, I'm using migrate in my project with MySQL. I know it's still under development, no worries there. It came to my attention that when my program runs and that there is an up migration to do (I added a table for example), migrate does it just fine, no problem with that, but I can't halt my app with ^C anymore.
If migrate runs something against my database, then I can't stop my program anymore. I don't know if it is related to the MySQL driver, but maybe you can point me in a direction while I'm looking into it, it could go faster! It might be on my side too.
Thanks, a lot, and by the way, I looked into the driver and tried a pull request to handle multiple statement but it was closed. You can see my pull request here : go-sql-driver/mysql#296
from migrate.
Thanks!
but I can't halt my app with ^C anymore.
When a migration is running and you hit ^C migrate
will wait until the current migration has been applied. But it's a good point. Sometimes you really want to force an exit regardless of running migrations. I guess hitting ^C twice should exit immediately. This isn't implemented though.
I looked into the driver and tried a pull request to handle multiple statement but it was closed.
It's too bad database/sql
does not support multiple statements. I think @arnehormann put it in a nutshell:
The good news: MySQL can do this on its own. We only have to set two flags when a connection is established. The bad news: database/sql does not support it in any way. As it's unsupported by database/sql, we won't support it either
from migrate.
see also #39
from migrate.
hey @mattes what do you think about mymysql?
I am thinking about implementing the Driver interface
for it, do you think is worth ?
from migrate.
For cases like yours, you can also use the driver by its database/sql/driver interface (mysql.MySQLDriver{}.Open(dsn)
).
That way, you get a single-connection session instead of a connection pool - with a little more setup boilerplate.
I think there's some ORM tools already doing so.
from migrate.
I never used it, but https://github.com/ziutek/mymysql#example-4---multi-statement--multi-result looks promising. If you want to give it a try, go for it. Will definitely merge if it works.
from migrate.
okay, @mattes I will start to work on it soon.
from migrate.
I'd like to use migrate
as a library in my go package, but I've seen that in the init function you call
driver.RegisterDriver("mysql", &Driver{})
and this cause a panic because in the same package I also have to import the mysql package that does the same.
There is a way to prevent that?
Thanks!
from migrate.
I'm surprised, because the mysql driver registers with https://github.com/mattes/migrate/blob/master/driver/registry.go which is unrelated from the any other mysql driver.
from migrate.
Actually the "mysql" name is used both by your driver and by go-sql-driver
package, am I missing something?
https://github.com/go-sql-driver/mysql/blob/master/driver.go
from migrate.
You can rename the package when you import:
import (
MysqlDriver "mysql" //rename
)
from migrate.
This won't solve the problem, because in these two files I'm importing they are creating a driver with the same name, as it will panic
https://github.com/go-sql-driver/mysql/blob/master/driver.go : line 148
https://github.com/mattes/migrate/blob/master/driver/mysql/mysql.go : line 184
from migrate.
Ok, I misunderstood your problem.
from migrate.
Can you send the panic log?
from migrate.
any news?
from migrate.
+1
from migrate.
Running into the same issue as @alecha.
from migrate.
Related Issues (20)
- Postgres taking 16 GB of ram to insert 80k rows? HOT 4
- Reset command HOT 3
- First migration issue cockroachdb HOT 2
- Drop doesn't cleanup functions, custom sequences, ..
- panic: sql: Register called twice for driver postgres HOT 1
- windows file source not supported
- Postgres drop misses schema_migrations table and sequences
- FR: Automatic retrying dirty migrations after fail
- error: no scheme for sqlite3 HOT 1
- Add warning about go-bindata
- source driver: unknown driver file (forgotton import?) HOT 5
- mysql.MySQLWarnings failed my build
- Chain commands in cassandra migration file HOT 1
- Make migrate plugin based
- dep ensure throws Solving failure: No versions of github.com/mattes/migrate met constraints for cassandra
- Support go migrations HOT 4
- Use pt-online-schema-change or gh-ost or ocs_cli for MySQL Online schema changes? HOT 2
- `ErrLocked` not matched
- migrate is no longer supported HOT 1
- Archive the repository
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 migrate.