-- Offers to move a mod from its owner's repo to another account's, and how -- far each accepted one has got. -- A record can't change repos, so a transfer copies the listing and its -- versions into the recipient's repo, then deletes the originals. Each step -- is recorded before it's taken, so an accept that fails partway resumes -- where it stopped rather than copying twice. CREATE TABLE IF NOT EXISTS mod_transfer ( id INTEGER PRIMARY KEY, sender_did TEXT NOT NULL, listing_rkey TEXT NOT NULL, -- The mod's slug when it was offered, so its old address can redirect. slug TEXT NOT NULL, recipient_did TEXT NOT NULL, created_at TEXT NOT NULL, -- An offer nobody accepted by now is void. expires_at TEXT NOT NULL, -- Where the copy goes in the recipient's repo, chosen when they first -- accept. Once set, the offer no longer expires and can't be declined. new_rkey TEXT, new_slug TEXT, -- When the copy was finished and the original hidden. accepted_at TEXT, -- When the originals were deleted from the sender's repo, which only the -- sender's own session can do. originals_deleted_at TEXT ); -- One offer per mod at a time. CREATE UNIQUE INDEX IF NOT EXISTS mod_transfer_listing ON mod_transfer (sender_did, listing_rkey); CREATE INDEX IF NOT EXISTS mod_transfer_recipient ON mod_transfer (recipient_did); CREATE INDEX IF NOT EXISTS mod_transfer_slug ON mod_transfer (sender_did, slug); -- The copy of each version of a transferred mod, minted before it's written. CREATE TABLE IF NOT EXISTS mod_transfer_version ( transfer_id INTEGER NOT NULL REFERENCES mod_transfer (id) ON DELETE CASCADE, old_rkey TEXT NOT NULL, new_rkey TEXT NOT NULL, -- Where the version's deliverable is copied to, if it had one. new_object_key TEXT, PRIMARY KEY (transfer_id, old_rkey) );