Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(sqlite): skip dumping SQLite internal sequence table if dump only (#588)

Danny Xu0126528f750b
diff --git a/plugin/db/sqlite/sqlite.go b/plugin/db/sqlite/sqlite.go
index 83048820c1..c2da268d9c 100644
--- a/plugin/db/sqlite/sqlite.go
+++ b/plugin/db/sqlite/sqlite.go
@@ -638,6 +638,10 @@ func (driver *Driver) dumpOneDatabase(ctx context.Context, database string, out
}
for _, s := range sqliteSchemas {
+ // We should skip sqlite sequence table if we're dumping schema only.
+ if schemaOnly && s.name == "sqlite_sequence" {
+ continue
+ }
if _, err := io.WriteString(out, fmt.Sprintf("%s;\n", s.statement)); err != nil {
return err
}
diff --git a/tests/schema_update_test.go b/tests/schema_update_test.go
index 756f8a6cd3..836fc51e6f 100644
--- a/tests/schema_update_test.go
+++ b/tests/schema_update_test.go
@@ -32,7 +32,6 @@ var (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
);
-CREATE TABLE sqlite_sequence(name,seq);
`
backupDump = "CREATE TABLE book (\n\t\tid INTEGER PRIMARY KEY AUTOINCREMENT,\n\t\tname TEXT NOT NULL\n\t);\nINSERT INTO 'book' VALUES ('1', 'byte');\nINSERT INTO 'book' VALUES ('2', 'base');\n\nCREATE TABLE sqlite_sequence(name,seq);\nINSERT INTO 'sqlite_sequence' VALUES ('book', '2');\n\n"
)