robmorgan/phinx — pull request #290 by SamuelFisher (2014-08-17 14:47:54+00:00)
Title: Table prefix and suffix support

Support for specifying a prefix and/or suffix for tables - implements #65.

Choices for implementing this were either:

* Modify `Phinx\Db\Table` to add prefix and suffix when passing down to adapter, but the configuration options are not accessible from that class. Also better to preserve the abstract view of a table, rather than how it is represented in the database, by not modifying this class.

* Modify the database adapters, but this would add the same logic for modifying the table name to each of them.

* Create a proxy adapter to modify the table name before the command is passed on to the real adapter. This solves the above issues and allows `Migration\Manager\Manager` to use the `TablePrefixAdapter` when a prefix/suffix has been specified. _(this option was taken)_

Specify the prefix and/or suffix in the phinx.yml (or other configuration file) for each environment as follows:

```
paths:
migrations: %%PHINX_CONFIG_DIR%%/migrations

environments:
default_migration_table: phinxlog
default_database: development
production:
adapter: mysql
host: localhost
name: production_db
user: root
pass: ''
port: 3306
charset: utf8
table_prefix: tbl_
table_suffix: _suffix

development:
adapter: mysql
host: localhost
name: development_db
user: root
pass: ''
port: 3306
charset: utf8

testing:
adapter: mysql
host: localhost
name: lgtest
user: root
pass: ''
port: 3306
charset: utf8
table_prefix: test_
```