mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
fix schema dump (#5562)
This commit is contained in:
parent
d7d3076e5d
commit
a005b7e7b7
2 changed files with 27 additions and 14 deletions
|
|
@ -10,19 +10,6 @@ func init() {
|
|||
MigrationClient.AddMigration(Up_20210927143116, Down_20210927143116)
|
||||
}
|
||||
|
||||
func columnExists(tx *sql.Tx, table, column string) bool {
|
||||
var count int
|
||||
err := tx.QueryRow(
|
||||
`SELECT count(*) FROM information_schema.columns WHERE COLUMN_NAME = ? AND table_name = ? LIMIT 1;`,
|
||||
column, table,
|
||||
).Scan(&count)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return count == 1
|
||||
}
|
||||
|
||||
func Up_20210927143116(tx *sql.Tx) error {
|
||||
if columnExists(tx, "software", "bundle_identifier") {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -1,7 +1,33 @@
|
|||
package tables
|
||||
|
||||
import "github.com/fleetdm/goose"
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/fleetdm/goose"
|
||||
)
|
||||
|
||||
var (
|
||||
MigrationClient = goose.New("migration_status_tables", goose.MySqlDialect{})
|
||||
)
|
||||
|
||||
func columnExists(tx *sql.Tx, table, column string) bool {
|
||||
var count int
|
||||
err := tx.QueryRow(
|
||||
`
|
||||
SELECT
|
||||
count(*)
|
||||
FROM
|
||||
information_schema.columns
|
||||
WHERE
|
||||
TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = ?
|
||||
AND COLUMN_NAME = ?
|
||||
`,
|
||||
table, column,
|
||||
).Scan(&count)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return count > 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue