lotus/lib/harmony/harmonydb/sql/20240425-sector_meta.sql
Łukasz Magiera 01ec229749
feat: curio: Keep more sector metadata in the DB long-term (#11933)
* feat: curio: Migrate lotus-miner sector metadata into Curio DB

* curio seal: Transfer seal pipeline entries to long-term sector metadata table

* curio: Only open db in sectors migrate cmd

* curio: Add an envvar to force migration

* curio: Debugging sector migration

* curio: Fix typo in table name

* curio: Plumb KeepUnsealed into the sealing pipeline

* Don't add redundant keep_data to sdr pipeline pieces table

* fix transferFinalizedSectorData where check

* ui for sector fail

---------

Co-authored-by: Andrew Jackson (Ajax) <snadrus@gmail.com>
2024-05-07 13:03:51 +02:00

45 lines
1.1 KiB
SQL

CREATE TABLE sectors_meta (
sp_id BIGINT NOT NULL,
sector_num BIGINT NOT NULL,
reg_seal_proof INT NOT NULL,
ticket_epoch BIGINT NOT NULL,
ticket_value BYTEA NOT NULL,
orig_sealed_cid TEXT NOT NULL,
orig_unsealed_cid TEXT NOT NULL,
cur_sealed_cid TEXT NOT NULL,
cur_unsealed_cid TEXT NOT NULL,
msg_cid_precommit TEXT,
msg_cid_commit TEXT,
msg_cid_update TEXT, -- snapdeal update
seed_epoch BIGINT NOT NULL,
seed_value BYTEA NOT NULL,
PRIMARY KEY (sp_id, sector_num)
);
CREATE TABLE sectors_meta_pieces (
sp_id BIGINT NOT NULL,
sector_num BIGINT NOT NULL,
piece_num BIGINT NOT NULL,
piece_cid TEXT NOT NULL,
piece_size BIGINT NOT NULL, -- padded size
requested_keep_data BOOLEAN NOT NULL,
raw_data_size BIGINT, -- null = piece_size.unpadded()
start_epoch BIGINT,
orig_end_epoch BIGINT,
f05_deal_id BIGINT,
ddo_pam jsonb,
PRIMARY KEY (sp_id, sector_num, piece_num),
FOREIGN KEY (sp_id, sector_num) REFERENCES sectors_meta(sp_id, sector_num) ON DELETE CASCADE
);