Allow precompile assets without opening db connection

Move the LIKE constant to the core gem as that is the place where it
gets called

Fixes #3690
Fixes #3688