-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move long migrations after the minimal migration
- Loading branch information
Showing
5 changed files
with
39 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
internal/storage/bucket/migrations/12-transaction-reference-index/notes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name: Create transaction reference index concurrently |
1 change: 1 addition & 0 deletions
1
internal/storage/bucket/migrations/12-transaction-reference-index/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create unique index concurrently transactions_reference2 on "{{.Schema}}".transactions (ledger, reference); |
1 change: 1 addition & 0 deletions
1
internal/storage/bucket/migrations/13-create-ledger-indexes/notes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name: Create ledger indexes |
36 changes: 36 additions & 0 deletions
36
internal/storage/bucket/migrations/13-create-ledger-indexes/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
set search_path = '{{.Schema}}'; | ||
|
||
drop index transactions_reference; | ||
alter index transactions_reference2 rename to transactions_reference; | ||
|
||
DO | ||
$do$ | ||
declare | ||
ledger record; | ||
vsql text; | ||
BEGIN | ||
for ledger in select * from _system.ledgers where bucket = current_schema loop | ||
-- enable post commit effective volumes synchronously | ||
vsql = 'create index "pcev_' || ledger.id || '" on moves (accounts_address, asset, effective_date desc) where ledger = ''' || ledger.name || ''''; | ||
execute vsql; | ||
|
||
vsql = 'create index "transactions_sources_' || ledger.id || '" on transactions using gin (sources jsonb_path_ops) where ledger = ''' || ledger.name || ''''; | ||
execute vsql; | ||
|
||
vsql = 'create index "transactions_destinations_' || ledger.id || '" on transactions using gin (destinations jsonb_path_ops) where ledger = ''' || ledger.name || ''''; | ||
execute vsql; | ||
|
||
vsql = 'create index "accounts_address_array_' || ledger.id || '" on accounts using gin (address_array jsonb_ops) where ledger = ''' || ledger.name || ''''; | ||
execute vsql; | ||
|
||
vsql = 'create index "accounts_address_array_length_' || ledger.id || '" on accounts (jsonb_array_length(address_array)) where ledger = ''' || ledger.name || ''''; | ||
execute vsql; | ||
|
||
vsql = 'create index "transactions_sources_arrays_' || ledger.id || '" on transactions using gin (sources_arrays jsonb_path_ops) where ledger = ''' || ledger.name || ''''; | ||
execute vsql; | ||
|
||
vsql = 'create index "transactions_destinations_arrays_' || ledger.id || '" on transactions using gin (destinations_arrays jsonb_path_ops) where ledger = ''' || ledger.name || ''''; | ||
execute vsql; | ||
end loop; | ||
END | ||
$do$; |