3

I want to install & setup my Drupal databases in a specific schema of the PostgreSQL database. For example, let's say I have created a schema named "test_drupal" in my existing PostGreSQL database and want all Drupal tables such as "block_content", "block_content_field_data" etc. inside my schema.

I also tried specifying the prefix while doing the database setup through Advanced options but it is only adding a prefix before the table names. Ideally I want to put all my tables in a specific schema in PostGreSQL. How can prefix be used in this case?

Can someone please help?

I am using drupal version 8.7.1

Regards, Parth

Parth Doshi
  • 4,200
  • 15
  • 79
  • 129

1 Answers1

0

Without having it tested myself: there is an option 'init_commands'. Check the code Drupal\Core\Database\Driver\pgsql\Connection::__construct.

You could set the "search_path" to your schema e.g. how to set the connection with a schema in a Postgresql DB with PDO PHP

I don't think you can do this during installation, but importing the data into your own schema and setting the search_path with the init_command to the right schema could workd

DrColossos
  • 12,656
  • 3
  • 46
  • 67
  • I will try this and get back to you soon. Thanks a lot. If possible can you please try testing the same as well ? – Parth Doshi Jun 03 '19 at 18:18
  • Also, one more point. Importing the data into my own custom schema, yes this is possible can be done through import scripts initially during setup. However, lets say I want to add or update this in future through a Drupal form then in that case how do I tell Drupal to insert this data in the right table of my own custom schema? – Parth Doshi Jun 03 '19 at 18:21