diff --git a/packages/schemas/alterations/next-1671039448-add-user-name-index.ts b/packages/schemas/alterations/next-1671039448-add-user-name-index.ts new file mode 100644 index 000000000..fb30bec7c --- /dev/null +++ b/packages/schemas/alterations/next-1671039448-add-user-name-index.ts @@ -0,0 +1,18 @@ +import { sql } from 'slonik'; + +import type { AlterationScript } from '../lib/types/alteration.js'; + +const alteration: AlterationScript = { + up: async (pool) => { + await pool.query(sql` + create index users__name on users (name); + `); + }, + down: async (pool) => { + await pool.query(sql` + drop index users__name; + `); + }, +}; + +export default alteration; diff --git a/packages/schemas/tables/users.sql b/packages/schemas/tables/users.sql index d7ca8bd51..3d988a435 100644 --- a/packages/schemas/tables/users.sql +++ b/packages/schemas/tables/users.sql @@ -20,3 +20,4 @@ create table users ( ); create index users__created_at on users (created_at); +create index users__name on users (name);