- edited description
Custom driver for sqlite
I set up my dev environment with an sqlite db and have this for my dbconf.yml:
driver: custom
open: ../dev.sqlite
import: github.com/mattn/go-sqlite3
dialect: mysql
It creates the migration, but when I try to run the migration(after changing the extension on it to sql instead of go):
-- +goose Up
CREATE TABLE post (
id int NOT NULL,
title text,
body text,
PRIMARY KEY(id)
);
-- +goose Down
DROP TABLE post;
I get this: 2013/10/16 13:28:28 sql: unknown driver "custom" (forgotten import?)
Comments (4)
-
reporter -
repo owner Unfortunately, SQL migrations can only be run with drivers that goose already knows about and is built with, since no new Go code is being compiled/run, just the existing goose binary. This is mentioned in the
Other Drivers
section of the ReadMe.That said, sqlite3 should probably be one of the drivers that goose knows about - I think I've seen patches lying around somewhere that implement this, but I can't locate them off the top of my head.
-
reporter so I changed over the migration to:
package main import ( "database/sql" ) // Up is executed when this migration is applied func Up_20131016132122(txn *sql.Tx) { txn.Exec(` CREATE TABLE post ( id int NOT NULL, title text, body text, PRIMARY KEY(id) ); `) } // Down is executed when this migration is rolled back func Down_20131016132122(txn *sql.Tx) { txn.Exec(` DROP TABLE post; `) }
I get sql: unknown driver "custom" (forgotten import?)
(sorry for the delay, was trying to get sqlite built-in to try and submit as a pull request, but couldn't get it to work either... /sigh. Wish I had more time to dedicate to this, but this project to the client by the end of next week and this was just meant to save a little time in the future... maybe later)
-
repo owner At least one problem is the
driver: custom
line in your dbconf.yml. That value should match the first param that you would normally pass tosql.Open()
Update that to the appropriate value for your sqlite3 driver and you may be in business.
- Log in to comment
first time posting an issue on bitbucket, getting used to the formatting