diff --git a/dialect_sqlite.go b/dialect_sqlite.go index ca2b3071..013e9c1b 100644 --- a/dialect_sqlite.go +++ b/dialect_sqlite.go @@ -229,15 +229,16 @@ func (m *sqlite) FizzTranslator() fizz.Translator { } func (m *sqlite) DumpSchema(w io.Writer) error { - cmd := exec.Command("sqlite3", m.Details().Database, ".schema") + cmd := exec.Command("sqlite3", m.Details().Database, ".schema --nosys") return genericDumpSchema(m.Details(), cmd, w) } func (m *sqlite) LoadSchema(r io.Reader) error { cmd := exec.Command("sqlite3", m.ConnectionDetails.Database) + cmd.Stderr = os.Stderr in, err := cmd.StdinPipe() if err != nil { - return err + return fmt.Errorf("could not open stdin to SQLite database %s: %w", m.ConnectionDetails.Database, err) } go func() { defer in.Close() @@ -246,12 +247,12 @@ func (m *sqlite) LoadSchema(r io.Reader) error { log(logging.SQL, strings.Join(cmd.Args, " ")) err = cmd.Start() if err != nil { - return err + return fmt.Errorf("could not load schema to SQLite database %s: %w", m.ConnectionDetails.Database, err) } err = cmd.Wait() if err != nil { - return err + return fmt.Errorf("command failure loading schema to SQLite database %s: %w", m.ConnectionDetails.Database, err) } log(logging.Info, "loaded schema for %s", m.Details().Database) diff --git a/dialect_sqlite_test.go b/dialect_sqlite_test.go index ac5db21a..6e8f56f6 100644 --- a/dialect_sqlite_test.go +++ b/dialect_sqlite_test.go @@ -4,6 +4,7 @@ package pop import ( + "bytes" "fmt" "path/filepath" "testing" @@ -196,3 +197,22 @@ func TestSqlite_NewDriver(t *testing.T) { _, err := newSQLiteDriver() require.NoError(t, err) } + +func TestSqlite_NoDumpSysTables(t *testing.T) { + r := require.New(t) + + dir := t.TempDir() + cd := &ConnectionDetails{Dialect: "sqlite", Database: filepath.Join(dir, "testdb.sqlite")} + c, err := NewConnection(cd) + r.NoError(err) + r.NoError(c.Open()) + + r.NoError(c.RawQuery("CREATE TABLE aitest (id integer primary key autoincrement);").Exec()) + + + schema := new(bytes.Buffer) + r.NoError(c.Dialect.DumpSchema(schema)) + + r.Contains(schema.String(), "CREATE TABLE aitest") + r.NotContains(schema.String(), "CREATE TABLE sqlite_sequence") +}