mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2024-12-22 19:07:33 +01:00
fix: migration
- add cursor descriptions - enable search extension on indexes
This commit is contained in:
parent
b7452778d5
commit
18359139e1
@ -56,15 +56,16 @@ CREATE TABLE IF NOT EXISTS meta (
|
|||||||
tags TEXT[]
|
tags TEXT[]
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS tags ON meta USING gin(tags);
|
CREATE INDEX IF NOT EXISTS tags ON meta USING gin(tags gin_trgm_ops);
|
||||||
CREATE INDEX IF NOT EXISTS location_name_idx ON meta USING gin(location_name);
|
CREATE INDEX IF NOT EXISTS location_name_idx ON meta USING gin(location_name gin_trgm_ops);
|
||||||
CREATE INDEX IF NOT EXISTS products_idx ON meta USING gin(location_name);
|
CREATE INDEX IF NOT EXISTS products_idx ON meta USING gin(location_name gin_trgm_ops);
|
||||||
CREATE INDEX IF NOT EXISTS meta_filter_idx ON meta(gender, preferred_language, age);
|
CREATE INDEX IF NOT EXISTS meta_filter_idx ON meta(gender, preferred_language, age);
|
||||||
|
|
||||||
-- cursors table (for internal syncing)
|
-- cursors table (for internal syncing)
|
||||||
CREATE TABLE IF NOT EXISTS cursors (
|
CREATE TABLE IF NOT EXISTS cursors (
|
||||||
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
id INT PRIMARY KEY,
|
||||||
cursor_pos VARCHAR(64) NOT NULL
|
cursor_pos VARCHAR(64) NOT NULL,
|
||||||
|
cursor_description VARCHAR(100)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- bootstrap first users row
|
-- bootstrap first users row
|
||||||
@ -72,9 +73,9 @@ INSERT INTO users (phone_number, blockchain_address, date_registered)
|
|||||||
SELECT phone_number, blockchain_address, created
|
SELECT phone_number, blockchain_address, created
|
||||||
FROM cic_ussd.account WHERE id = 1;
|
FROM cic_ussd.account WHERE id = 1;
|
||||||
|
|
||||||
-- idx 1 = cic_ussd cursor
|
-- id 1 = cic_ussd cursor
|
||||||
INSERT INTO cursors (cursor_pos)
|
INSERT INTO cursors (id, cursor_pos)
|
||||||
SELECT blockchain_address FROM users ORDER BY id DESC LIMIT 1;
|
SELECT 1, blockchain_address FROM users ORDER BY id DESC LIMIT 1;
|
||||||
|
|
||||||
-- bootstrap first tx row
|
-- bootstrap first tx row
|
||||||
INSERT INTO transactions (tx_hash, block_number, tx_index, token_address, sender_address, recipient_address, tx_value, date_block, tx_type)
|
INSERT INTO transactions (tx_hash, block_number, tx_index, token_address, sender_address, recipient_address, tx_value, date_block, tx_type)
|
||||||
@ -84,6 +85,14 @@ INNER JOIN cic_cache.tag_tx_link ON tx.id = cic_cache.tag_tx_link.tx_id
|
|||||||
INNER JOIN cic_cache.tag ON cic_cache.tag_tx_link.tag_id = cic_cache.tag.id
|
INNER JOIN cic_cache.tag ON cic_cache.tag_tx_link.tag_id = cic_cache.tag.id
|
||||||
WHERE tx.success = true AND tx.id = 1;
|
WHERE tx.success = true AND tx.id = 1;
|
||||||
|
|
||||||
-- idx 2 = cic_cache cursor
|
-- id 2 = cic_cache cursor
|
||||||
INSERT INTO cursors (cursor_pos)
|
INSERT INTO cursors (id,cursor_pos)
|
||||||
SELECT tx_hash FROM transactions ORDER BY id DESC LIMIT 1;
|
SELECT 2, tx_hash FROM transactions ORDER BY id DESC LIMIT 1;
|
||||||
|
|
||||||
|
-- id 3 = kitabu.erc20_token_index cursor
|
||||||
|
INSERT INTO cursors (cursor_pos) VALUES
|
||||||
|
(3, 0, 'kitabu.erc20_token_index contract entry idx');
|
||||||
|
|
||||||
|
-- cursor descriptions
|
||||||
|
UPDATE cursors SET cursor_description = 'cic_ussd.account.block_chain_address remote cursor' WHERE id = 1;
|
||||||
|
UPDATE cursors SET cursor_description = 'cic_cache.tx.tx_hash remote cursor' WHERE id = 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user