Contribution: Drupal 6.11 with postgreSQL and usage of postgres schema
(http://www.postgresql.org/docs/8.3/interactive/sql-createschema.html)
Allows grouping of all tables (indices etc.) belonging to one (virtual) drupal Site.
Benefits:
- not getting hundrets of drupal database tables with prefixed names in your database instance.
- Database dump can be made on specific drupal sites (for example to handout
your customer his table data)
- database tables belonging to a drupal site can easily removed (drop schema ... cascade ...)
instead of manually entering all the table names with prefixes.
I suggest changes to drupal core for this.
Attached is a contribution of 2 changed drupal code (diff's) files:
includes/database.inc
includes/database.pgsql.inc
Platform:
System : FreeBSD 7.2-STABLE
Database: postgreSQL 8.2.3
PHP : Version => 5.2.9
Drupal : 6.11
USAGE - How to add a virtual drupal site:
1. Do as like normal (prepare sites/www.mydomain.com/...)
2. in postgres create a schema:
CREATE SCHEMA schemaname AUTHORIZATION username;
You can list all schema in your database in the psql shell: with \dn
Example:
drupal6=# \dn
List of schemas
Name | Owner
--------------------+--------
bsn | drupal
cantor | drupal
information_schema | pgsql
pg_catalog | pgsql
pg_toast | pgsql
pjb2 | drupal
pjb3 | drupal
public | pgsql
...
3.1. in sites/www.mydomain.com/settings.php set:
$db_url = 'pgsql://username:password@localhost/databasename';
You must set THE SAME username in step 2 and in step 3.1
3.2. in sites/www.mydomain.com/settings.php set:
$db_prefix = 'schemaname.';
Note: use your actual schemaname with a trailing dot (.) !
You must use the same schemaname in step 2 and in step 3.2
DONE.
We are running this with around 6 drupal 6.11 sites and about 12
extra modules installed without problems.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | syntax-error-at-or.jpg | 378.27 KB | prasannah.ganeshan |
| database.pgsql_.inc_.diff | 2.75 KB | Norbert Poellmann | |
| database.inc_.diff | 791 bytes | Norbert Poellmann |
Comments
Comment #1
prasannah.ganeshan commentedI'm been trying to give this a try, but I'm unable to proceed after the point where you get to fill in the db credentials. It give me this error. If you had overcome this before just help me out. I would like to give this patch a try. It would be useful to use schema hold the database of each website I create.
I've attached my error!!
Comment #2
damien tournoud commentedDrupal 7 fully support schemas. This is a won't fix for Drupal 6.