status-go/appdatabase/migrations/sql/1676368933_keypairs_to_keycards.up.sql
Sale Djenic b9de89ca38 chore(keycard): keypair improvements
Due to easier maintaining in future the following is done:
- keypairs table removed
- keycard table added, storing only keycards/keypairs
- keycard_accounts table added, storing only accounts migrated to a keycard

Migration is done keeping the current keycard state accurate (no keycard records will be lost).
2023-02-17 12:45:34 +01:00

20 lines
639 B
SQL

CREATE TABLE IF NOT EXISTS keycards (
keycard_uid VARCHAR NOT NULL PRIMARY KEY,
keycard_name VARCHAR NOT NULL,
keycard_locked BOOLEAN DEFAULT FALSE,
key_uid VARCHAR NOT NULL
);
CREATE TABLE IF NOT EXISTS keycards_accounts (
keycard_uid VARCHAR NOT NULL,
account_address VARCHAR NOT NULL,
FOREIGN KEY(keycard_uid) REFERENCES keycards(keycard_uid)
ON UPDATE CASCADE
ON DELETE CASCADE
);
INSERT INTO keycards select distinct keycard_uid, keycard_name, keycard_locked, key_uid from keypairs;
INSERT INTO keycards_accounts select keycard_uid, account_address from keypairs;
DROP TABLE keypairs;