Skip to content

Commit

Permalink
Ignore SQLite system indices (#81)
Browse files Browse the repository at this point in the history
* Ignore SQLite system indices

This resolves an issue where SQLite system indices were re-created when executing `change_column`, which throws an error in SQLite.

* Add underscore to SQLite index filter prefix
  • Loading branch information
aeneasr authored Feb 20, 2020
1 parent 018dd7e commit e4f0396
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion translators/sqlite_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ func (p *sqliteSchema) buildTableData(table *fizz.Table, db *sql.DB) error {
}

func (p *sqliteSchema) buildTableIndexes(t *fizz.Table, db *sql.DB) error {
prag := fmt.Sprintf(`SELECT "seq", "name", "unique", "origin", "partial" FROM pragma_index_list('%s')`, t.Name)
// This ignores all internal SQLite keys which are prefixed with `sqlite_` as explained here:
// https://www.sqlite.org/fileformat2.html#intschema
prag := fmt.Sprintf(`SELECT "seq", "name", "unique", "origin", "partial" FROM pragma_index_list('%s') WHERE "name" NOT LIKE 'sqlite_%%'`, t.Name)
res, err := db.Query(prag)
if err != nil {
return err
Expand Down

0 comments on commit e4f0396

Please sign in to comment.