-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into release/booster-bitswap
- Loading branch information
Showing
31 changed files
with
503 additions
and
235 deletions.
There are no files selected for viewing
Binary file not shown.
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,10 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
ALTER TABLE Deals | ||
ADD AnnounceToIPNI BOOL; | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
SELECT 'down SQL query'; | ||
-- +goose StatementEnd |
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,24 @@ | ||
package migrations | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/pressly/goose/v3" | ||
) | ||
|
||
func init() { | ||
goose.AddMigration(upSetdealsAnnounceToIPNI, downSetdealsAnnounceToIPNI) | ||
} | ||
|
||
func upSetdealsAnnounceToIPNI(tx *sql.Tx) error { | ||
_, err := tx.Exec("UPDATE Deals SET AnnounceToIPNI=?;", true) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func downSetdealsAnnounceToIPNI(tx *sql.Tx) error { | ||
// This code is executed when the migration is rolled back. | ||
return nil | ||
} |
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,46 @@ | ||
package migrations_tests | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/filecoin-project/boost/db" | ||
"github.com/filecoin-project/boost/db/migrations" | ||
"github.com/pressly/goose/v3" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDealAnnounceToIPNI(t *testing.T) { | ||
req := require.New(t) | ||
ctx := context.Background() | ||
|
||
sqldb := db.CreateTestTmpDB(t) | ||
req.NoError(db.CreateAllBoostTables(ctx, sqldb, sqldb)) | ||
|
||
// Run migrations up to the one that adds the AnnounceToIPNI field to Deals | ||
goose.SetBaseFS(migrations.EmbedMigrations) | ||
req.NoError(goose.SetDialect("sqlite3")) | ||
req.NoError(goose.UpTo(sqldb, ".", 20230104230242)) | ||
|
||
// Generate 1 deal | ||
dealsDB := db.NewDealsDB(sqldb) | ||
deals, err := db.GenerateNDeals(1) | ||
req.NoError(err) | ||
|
||
// Insert the deals in DB | ||
err = dealsDB.Insert(ctx, &deals[0]) | ||
require.NoError(t, err) | ||
|
||
// Get deal state | ||
dealState, err := dealsDB.ByID(ctx, deals[0].DealUuid) | ||
require.NoError(t, err) | ||
require.False(t, dealState.AnnounceToIPNI) | ||
|
||
//Run migration | ||
req.NoError(goose.UpByOne(sqldb, ".")) | ||
|
||
// Check the deal state again | ||
dealState, err = dealsDB.ByID(ctx, deals[0].DealUuid) | ||
require.NoError(t, err) | ||
require.True(t, dealState.AnnounceToIPNI) | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.