Do not create migrations table on dump#701
Conversation
0e68950 to
829d216
Compare
When running dbmate dump, no changes to the database should be made.
829d216 to
ddb60ec
Compare
| err := db.Drop() | ||
| require.NoError(t, err) | ||
|
|
||
| // create and migrate |
There was a problem hiding this comment.
nit: create and don't migrate
| func (drv *Driver) schemaMigrationsDump(db *sql.DB) ([]byte, error) { | ||
| exists, err := drv.MigrationsTableExists(db) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to check if migration table exists: %w", err) |
There was a problem hiding this comment.
This doesn't appear to be a failure to check (we just tried to), but that we were unable to verify the existence of the migrations table? Saying "failed to check" seems a bit misleading here.
Would return nil, err be sufficient here, assuming that the error being returned from MigrationsTableExists() is well-formed?
| func (drv *Driver) schemaMigrationsDump(db *sql.DB, buf *bytes.Buffer) error { | ||
| exists, err := drv.MigrationsTableExists(db) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to check if migration table exists: %w", err) |
There was a problem hiding this comment.
See previous comment about returning err as-is.
| func (drv *Driver) schemaMigrationsDump(db *sql.DB) ([]byte, error) { | ||
| exists, err := drv.MigrationsTableExists(db) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to check if migration table exists: %w", err) |
There was a problem hiding this comment.
See previous comment about returning err as-is.
| func (drv *Driver) schemaMigrationsDump(db *sql.DB) ([]byte, error) { | ||
| exists, err := drv.MigrationsTableExists(db) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to check if migration table exists: %w", err) |
There was a problem hiding this comment.
See previous comment about returning err as-is.
| func (drv *Driver) schemaMigrationsDump(db *sql.DB) ([]byte, error) { | ||
| exists, err := drv.MigrationsTableExists(db) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to check if migration table exists: %w", err) |
There was a problem hiding this comment.
See previous comment about returning err as-is.
When running
dbmate dump, no changes to the database should be made.Use case: running
dbmate dumpwith credentials that do not have CREATE permissions.