diff --git a/hasura/migrations/1601918477756_run_sql_migration/down.yaml b/hasura/migrations/1601918477756_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1601918477756_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1601918477756_run_sql_migration/up.yaml b/hasura/migrations/1601918477756_run_sql_migration/up.yaml new file mode 100644 index 000000000..c7e841dff --- /dev/null +++ b/hasura/migrations/1601918477756_run_sql_migration/up.yaml @@ -0,0 +1,14 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE FUNCTION public.search_vehicles(search text)\n RETURNS + SETOF vehicles\n LANGUAGE plpgsql\n STABLE\nAS $function$\n\nBEGIN\n if search + = '' then\n return query select * from vehicles ;\n else \n return query + \n \n \n\n SELECT *\nFROM vehicles\nWHERE v_vin ILIKE '%' || search + || '%'\n or plate_no ILIKE '%' || search || '%'\n or v_make_desc ILIKE + '%' || search || '%'\n or v_model_desc ILIKE '%' || search || '%'\n \n + \ ORDER BY v_vin ILIKE '%' || search || '%'\n OR NULL,\n plate_no ILIKE + '%' || search || '%'\n OR NULL,\n v_model_desc ILIKE '%' || search + || '%'\n OR NULL,\n v_make_desc ILIKE '%' || search || '%'\n OR null;\n\n\n\n\n\n\n\n + \ end if;\n\n\tEND\n$function$;" + type: run_sql