Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testutils/db: use schema provided by migrate data during export #445

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

alessandro-sorint
Copy link
Contributor

When exporting, use schema provided by migrate data and not the create data since the migration change the db shema to the migrate version.

@@ -672,6 +672,8 @@ func TestMigrate(t *testing.T, lastVersion uint, dataFixtures DataFixtures, setu

assert.Assert(t, len(diff) == 0, "schema of db created at version %d and db migrated from version %d to version %d is different:\n %s", migrateVersion, createVersion, migrateVersion, diff)

dc.Schema = createDC.Schema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment explaining the reason of this change.

@@ -672,6 +672,8 @@ func TestMigrate(t *testing.T, lastVersion uint, dataFixtures DataFixtures, setu

assert.Assert(t, len(diff) == 0, "schema of db created at version %d and db migrated from version %d to version %d is different:\n %s", migrateVersion, createVersion, migrateVersion, diff)

dc.Schema = createDC.Schema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll prefer to use the source variable:

dc.Schema = createDataCreate.Tables

@@ -672,6 +672,9 @@ func TestMigrate(t *testing.T, lastVersion uint, dataFixtures DataFixtures, setu

assert.Assert(t, len(diff) == 0, "schema of db created at version %d and db migrated from version %d to version %d is different:\n %s", migrateVersion, createVersion, migrateVersion, diff)

// MigrateToVersion update the db schema but not change the DBContext
Copy link
Member

@sgotti sgotti Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// set the db schema at the migrated version.

When exporting, use schema provided by migrate data and not the create data since the migration change the db shema to the migrate version.
@sgotti sgotti merged commit 1326c5d into agola-io:master Oct 10, 2023
1 check was pending
@alessandro-sorint alessandro-sorint deleted the fix-testutil branch October 17, 2023 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants