diff --git a/storage/migrations/08_evm_tokens_name_index.up.sql b/storage/migrations/08_evm_tokens_name_index.up.sql new file mode 100644 index 000000000..3fb9c1503 --- /dev/null +++ b/storage/migrations/08_evm_tokens_name_index.up.sql @@ -0,0 +1,10 @@ +-- Add indexes for evm_tokens token names and symbols for search. + +BEGIN; + +CREATE EXTENSION pg_trgm; + +CREATE INDEX ix_evm_tokens_name ON chain.evm_tokens USING GIST (token_name gist_trgm_ops); +CREATE INDEX ix_evm_tokens_symbol ON chain.evm_tokens USING GIST (symbol gist_trgm_ops); + +COMMIT; diff --git a/storage/postgres/client.go b/storage/postgres/client.go index 8a51dded6..3a251ef2b 100644 --- a/storage/postgres/client.go +++ b/storage/postgres/client.go @@ -309,6 +309,10 @@ func (c *Client) listNexusMaterializedViews(ctx context.Context) ([]string, erro // Wipe removes all contents of the database. func (c *Client) Wipe(ctx context.Context) error { + if _, err := c.pool.Exec(ctx, "DROP EXTENSION IF EXISTS pg_trgm CASCADE;"); err != nil { + return err + } + tables, err := c.listNexusTables(ctx) if err != nil { return err @@ -322,6 +326,7 @@ func (c *Client) Wipe(ctx context.Context) error { // List, then drop all custom types. // Query from https://stackoverflow.com/questions/3660787/how-to-list-custom-types-using-postgres-information-schema + // TODO: Don't delete extensions' types. types, err := c.listNexusTypes(ctx) if err != nil { return err @@ -334,6 +339,7 @@ func (c *Client) Wipe(ctx context.Context) error { } // List, then drop all custom functions. + // TODO: Don't delete extensions' functions. functions, err := c.listNexusFunctions(ctx) if err != nil { return err