forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Hot fix gorm issue Signed-off-by: Prafulla Mahindrakar <[email protected]> * Removed the bigint type conversion on ID column and instead using only during migration Signed-off-by: Prafulla Mahindrakar <[email protected]> * Added other tables for int to bigint migration Signed-off-by: Prafulla Mahindrakar <[email protected]> * Refactored and added rollback Signed-off-by: Prafulla Mahindrakar <[email protected]> * Added mocked unit tests for migration changes Signed-off-by: Prafulla Mahindrakar <[email protected]> * linter fixes Signed-off-by: Prafulla Mahindrakar <[email protected]>
- Loading branch information
1 parent
997d2f7
commit 5dbecdc
Showing
4 changed files
with
96 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
mocket "github.com/Selvatico/go-mocket" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"gorm.io/driver/postgres" | ||
"gorm.io/gorm" | ||
) | ||
|
||
func TestAlterTableColumnType(t *testing.T) { | ||
gormDb := GetDbForTest(t) | ||
db, err := gormDb.DB() | ||
GlobalMock := mocket.Catcher.Reset() | ||
GlobalMock.Logging = true | ||
query := GlobalMock.NewMock() | ||
query.WithQuery( | ||
`ALTER TABLE IF EXISTS execution_events ALTER COLUMN "id" TYPE bigint`) | ||
assert.NoError(t, err) | ||
tables = []string{"execution_events"} | ||
_ = alterTableColumnType(db, "id", "bigint") | ||
assert.True(t, query.Triggered) | ||
} | ||
|
||
func GetDbForTest(t *testing.T) *gorm.DB { | ||
mocket.Catcher.Register() | ||
db, err := gorm.Open(postgres.New(postgres.Config{DriverName: mocket.DriverName})) | ||
if err != nil { | ||
t.Fatal(fmt.Sprintf("Failed to open mock db with err %v", err)) | ||
} | ||
return db | ||
} |