Skip to content

Commit

Permalink
Prevent TruncateAll from emptying the migration table (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
ypjama authored and stanislas-m committed Oct 6, 2019
1 parent d04f898 commit 8c9b756
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dialect_cockroach.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
const nameCockroach = "cockroach"
const portCockroach = "26257"

const selectTablesQueryCockroach = "select table_name from information_schema.tables where table_schema = 'public' and table_type = 'BASE TABLE' and table_catalog = ?"
const selectTablesQueryCockroachV1 = "select table_name from information_schema.tables where table_schema = ?"
const selectTablesQueryCockroach = "select table_name from information_schema.tables where table_schema = 'public' and table_type = 'BASE TABLE' and table_name <> ? and table_catalog = ?"
const selectTablesQueryCockroachV1 = "select table_name from information_schema.tables where table_name <> ? and table_schema = ?"

func init() {
AvailableDialects = append(AvailableDialects, nameCockroach)
Expand Down Expand Up @@ -209,7 +209,7 @@ func (p *cockroach) TruncateAll(tx *Connection) error {
tableQuery := p.tablesQuery()

var tables []table
if err := tx.RawQuery(tableQuery, tx.Dialect.Details().Database).All(&tables); err != nil {
if err := tx.RawQuery(tableQuery, tx.MigrationTableName(), tx.Dialect.Details().Database).All(&tables); err != nil {
return err
}

Expand Down

0 comments on commit 8c9b756

Please sign in to comment.