0
votes

I need to set environment specific table prefixes, so i found unperfect solution in inserting this in ProjectConfiguration::configureDoctrine(Doctrine_Manager $manager): (config/ProjectConfiguration.class.php)

if (sfConfig::get('app_database_table_prefix')) {
    $manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT,
    sfConfig::get('app_database_table_prefix'));
}

... and then i can set env-unique prefixes in app.yml:

prod:
  database_table_prefix: prefix__%s

BUT.. this is cool for all app, except plugins. Plugins ignores config/ProjectConfiguration.class.php.

Dont you know about alglobal solution WITHOUT changing anything in plugins directory (i need something what will influent all posible future applications plugins too)

1
i found temporary sollution in updating of sfPluginConfiguration::initialize() of concrete plugin by the same code like upper, but substitute $manager by Doctrine_Manager::getInstance(), but its still not final solution which should influent all future plugins without changing anything in their code.palmic

1 Answers

2
votes

It looks like you're using Doctrine, so it looks like you can set the prefix in your databases.yml file. The instructions are at the bottom of this page, but it looks like you can set the table name format by adding the tblname_format to the attributes in databases.yml like so:

all:
  doctrine:
    param:
      attributes:
        tblname_format: YOURPREFIX_%s