satellite/metabase: add expires_at column to segments

Change-Id: If798198d87edb68cda8859ce2277fdfbd6f8380b
This commit is contained in:
Fadila Khadar 2021-06-05 19:07:20 +02:00 committed by Michal Niewrzal
parent 347f5f87e0
commit 21731ff8d0
2 changed files with 11 additions and 1 deletions

View File

@ -295,6 +295,14 @@ func (db *DB) PostgresMigration() *migrate.Migration {
`DROP INDEX IF EXISTS pending_index`,
},
},
{
DB: &db.db,
Description: "add expires_at column to segments",
Version: 12,
Action: migrate.SQL{
`ALTER TABLE segments ADD COLUMN expires_at TIMESTAMPTZ`,
},
},
},
}
}

View File

@ -48,6 +48,7 @@ type RawSegment struct {
CreatedAt *time.Time // TODO: make it non-nilable after we migrate all existing segments to have creation time
RepairedAt *time.Time
ExpiresAt *time.Time
RootPieceID storj.PieceID
EncryptedKeyNonce []byte
@ -169,7 +170,7 @@ func (db *DB) testingGetAllSegments(ctx context.Context) (_ []RawSegment, err er
rows, err := db.db.Query(ctx, `
SELECT
stream_id, position,
created_at, repaired_at,
created_at, repaired_at, expires_at,
root_piece_id, encrypted_key_nonce, encrypted_key,
encrypted_size,
plain_offset, plain_size,
@ -192,6 +193,7 @@ func (db *DB) testingGetAllSegments(ctx context.Context) (_ []RawSegment, err er
&seg.CreatedAt,
&seg.RepairedAt,
&seg.ExpiresAt,
&seg.RootPieceID,
&seg.EncryptedKeyNonce,