traxxx/migrations/20200225223307_search.js

15 lines
480 B
JavaScript

exports.up = knex => Promise.resolve()
.then(() => knex.raw(`
CREATE FUNCTION search_releases(search text) RETURNS SETOF releases AS $$
SELECT * FROM releases
WHERE
title ILIKE ('%' || search || '%') OR
url ILIKE ('%' || search || '%')
$$ LANGUAGE SQL STABLE;
`));
exports.down = knex => Promise.resolve()
.then(() => knex.raw(`
DROP FUNCTION IF EXISTS search_releases;
`));