protected function createTagTable()
 {
     $table = $this->getTable();
     $tagTableName = $this->getTagTableName();
     $tagTablePhpName = $this->replaceTokens($this->parameters['tag_table_phpname']);
     $database = $table->getDatabase();
     if ($database->hasTable($tagTableName)) {
         $this->tagTable = $database->getTable($tagTableName);
     } else {
         $this->tagTable = $database->addTable(array('name' => $tagTableName, 'phpName' => $tagTablePhpName, 'package' => $table->getPackage(), 'schema' => $table->getSchema(), 'namespace' => '\\' . $table->getNamespace()));
         // every behavior adding a table should re-execute database behaviors
         // see bug 2188 http://www.propelorm.org/changeset/2188
         foreach ($database->getBehaviors() as $behavior) {
             $behavior->modifyDatabase();
         }
     }
     if (!$this->tagTable->hasColumn('id')) {
         $this->tagTable->addColumn(array('name' => 'id', 'type' => PropelTypes::INTEGER, 'primaryKey' => 'true', 'autoIncrement' => 'true'));
     }
     if ($this->tagTable->hasColumn('category_id')) {
         $categoryFkColumn = $this->tagTable->getColumn('category_id');
     } else {
         $categoryFkColumn = $this->tagTable->addColumn(array('name' => 'category_id', 'type' => PropelTypes::INTEGER, 'required' => false));
     }
     $fkTagCategory = new ForeignKey();
     $fkTagCategory->setPhpName('Category');
     $fkTagCategory->setForeignTableCommonName($this->tagCategoryTable->getCommonName());
     $fkTagCategory->setForeignSchemaName($this->tagCategoryTable->getSchema());
     $fkTagCategory->setOnDelete(ForeignKey::CASCADE);
     $fkTagCategory->setOnUpdate(ForeignKey::CASCADE);
     $pks = $this->getTable()->getPrimaryKey();
     foreach ($pks as $column) {
         $fkTagCategory->addReference($categoryFkColumn->getName(), $column->getName());
     }
     $this->tagTable->addForeignKey($fkTagCategory);
     if (!$this->tagTable->hasColumn('name')) {
         $this->tagTable->addColumn(array('name' => 'name', 'type' => PropelTypes::VARCHAR, 'size' => '60', 'primaryString' => 'true'));
     }
 }