migrate icon indicating copy to clipboard operation
migrate copied to clipboard

m.Drop() throws error with sqlite databases

Open LeonB opened this issue 7 years ago • 1 comments

I get this error when running m.Drop():

table sqlite_sequence may not be dropped in line 0: DROP TABLE sqlite_sequence in line 0: DROP TABLE sqlite_sequence

package main

import (
	"database/sql"
	"log"

	"github.com/mattes/migrate"
	"github.com/mattes/migrate/database/sqlite3"
	_ "github.com/mattes/migrate/source/file"
)

func main() {
	db, _ := sql.Open("sqlite3", "test.sqlite3?_foreign_keys=1")
	driver, _ := sqlite3.WithInstance(db, &sqlite3.Config{})
	m, _ := migrate.NewWithDatabaseInstance(
		"file://",
		"sqlite3", driver)
	m.Up()
	err := m.Drop()
	log.Println(err)
}

So maybe .Drop() should exclude the sqlite_sequence table?

LeonB avatar Oct 19 '17 22:10 LeonB

There's something else needed to trigger this bug (?). I'm trying tonight to find out what exactly.

LeonB avatar Oct 20 '17 08:10 LeonB