From 21731ff8d07ab2ef50602b4955bce202027ef2a7 Mon Sep 17 00:00:00 2001 From: Fadila Khadar Date: Sat, 5 Jun 2021 19:07:20 +0200 Subject: [PATCH] satellite/metabase: add expires_at column to segments Change-Id: If798198d87edb68cda8859ce2277fdfbd6f8380b --- satellite/metabase/db.go | 8 ++++++++ satellite/metabase/raw.go | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/satellite/metabase/db.go b/satellite/metabase/db.go index 0a28e9dd7..641bd922b 100644 --- a/satellite/metabase/db.go +++ b/satellite/metabase/db.go @@ -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`, + }, + }, }, } } diff --git a/satellite/metabase/raw.go b/satellite/metabase/raw.go index 9dc27190b..71c4c2bf2 100644 --- a/satellite/metabase/raw.go +++ b/satellite/metabase/raw.go @@ -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,