Skip to content

Commit

Permalink
Working on closing deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Mar 12, 2024
1 parent 041ee9b commit 3c26ae3
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
DROP TABLE IF EXISTS "old_table";
DROP TABLE IF EXISTS "new_table";

CREATE TABLE "old_table"
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
payment_id TEXT NULL,
from_addr TEXT NOT NULL,
receiver_addr TEXT NOT NULL,
chain_id INTEGER NOT NULL,
token_addr TEXT NULL,
token_amount TEXT NOT NULL,
deposit_id TEXT NULL,
create_date TEXT NOT NULL,
paid_date TEXT NULL,
tx_id INTEGER NULL,
fee_paid TEXT NULL,
error TEXT NULL
) strict;

INSERT INTO old_table SELECT * FROM token_transfer;

DROP TABLE token_transfer;

CREATE TABLE token_transfer
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
payment_id TEXT NULL,
from_addr TEXT NOT NULL,
receiver_addr TEXT NOT NULL,
chain_id INTEGER NOT NULL,
token_addr TEXT NULL,
token_amount TEXT NOT NULL,
deposit_id TEXT NULL,
deposit_finish INTEGER NOT NULL DEFAULT 0,
create_date TEXT NOT NULL,
paid_date TEXT NULL,
tx_id INTEGER NULL,
fee_paid TEXT NULL,
error TEXT NULL,
CONSTRAINT "fk_token_transfer_tx" FOREIGN KEY ("tx_id") REFERENCES "tx" ("id")
) strict;

INSERT INTO token_transfer(id, payment_id, from_addr, receiver_addr, chain_id, token_addr, token_amount, deposit_id, create_date, paid_date, tx_id, fee_paid, error)
SELECT id, payment_id, from_addr, receiver_addr, chain_id, token_addr, token_amount, deposit_id, create_date, paid_date, tx_id, fee_paid, error FROM old_table;

-- Make sure that extracting transfers for given deposit_id is fast
CREATE INDEX "idx_deposit_id" ON "token_transfer" (deposit_id);

0 comments on commit 3c26ae3

Please sign in to comment.