I inherited a project with a large Postgres database (over 150 tables, over 200 custom types, almost 1000 functions, triggers, etc.) Unfortunately, everything is dumped into one schema (public
). It works just fine from the point of view of the application, however it's a major nightmare to maintain.
The obvious thing would be to split these objects into separate schemas by function (e.g. all supplier-related stuff goes into supplier
schema, all admin related stuff into admin
schema, etc.). Once this is done, of course, some changes (ok, a lot of changes) to the code would be required to refer to the new schemas. Considering that the web application contains about 2000 php files, it may be quite a task. Again, as every php in the system already starts with require_once('controller/config.php');
I could add a call there to set search path to include all the new schemas: SET search_path = 'public, supplier, admin, ...'
, yet somehow subconsciously I don't like this solution.
Is there any other way to deal with issue? I don't want to spend more effort than absolutely necessary on reorganising the database. I also can barely incur any downtime on the main web site, as it's used by clients across the world (Australia, Europe, North America).
What would your recommend I do?