20240718203721_allow_unspent.sql 629 B

123456789101112131415161718192021
  1. -- Create a new table with the updated CHECK constraint
  2. CREATE TABLE proof_new (
  3. y BLOB PRIMARY KEY,
  4. amount INTEGER NOT NULL,
  5. keyset_id TEXT NOT NULL,
  6. secret TEXT NOT NULL,
  7. c BLOB NOT NULL,
  8. witness TEXT,
  9. state TEXT CHECK (state IN ('SPENT', 'PENDING', 'UNSPENT')) NOT NULL
  10. );
  11. -- Copy the data from the old table to the new table
  12. INSERT INTO proof_new (y, amount, keyset_id, secret, c, witness, state)
  13. SELECT y, amount, keyset_id, secret, c, witness, state
  14. FROM proof;
  15. -- Drop the old table
  16. DROP TABLE proof;
  17. -- Rename the new table to the original table name
  18. ALTER TABLE proof_new RENAME TO proof;