Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
by![](https://cdn.sanity.io/images/aho0e32c/production/61b763a05f41a7aea0b3b3265ff0fc83534ef28c-20x21.svg?w=20&fit=max&auto=format)
Codemod
Sql/Add Index Before Select
Last update
Jul 26, 2024
Example of using codemod that changes SQL.
It detects all SELECT statements and adds an index creation statement before them.
Inside SELECT statement for any fields that ends with _id
it creates an index on that field.
Example
Before
select * FROM orders WHERE customer_id = 123;
After
CREATE INDEX idx_customer_id ON orders(customer_id);SELECT * FROM orders WHERE customer_id = 123;
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community