Development

Changeset 11247

You must first sign up to be able to contribute.

Changeset 11247

Show
Ignore:
Timestamp:
08/30/08 00:12:06 (3 months ago)
Author:
Kris.Wallsmith
Message:

sfPropelPlugin [migration]: Added drop index support to abstraction layer.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelPlugin/branches/migration/lib/propel/builder/sql/SfmssqlDDLBuilder.php

    r11245 r11247  
    1818    return $script; 
    1919  } 
     20 
     21  public function getDropIndexStatement($tableName, $indexName, $indexType) 
     22  { 
     23    /** 
     24     * @todo Different syntax for dropping a unique index? 
     25     */ 
     26    return sprintf('DROP INDEX %s;', $this->quoteIdentifier($indexName)); 
     27  } 
    2028} 
  • plugins/sfPropelPlugin/branches/migration/lib/propel/builder/sql/SfmysqlDDLBuilder.php

    r11245 r11247  
    1818    return $script; 
    1919  } 
     20 
     21  public function getDropIndexStatement($tableName, $indexName, $indexType) 
     22  { 
     23    return vsprintf('DROP INDEX %s ON %s;', array( 
     24      $this->quoteIdentifier($indexName), 
     25      $this->quoteIdentifier($this->prefixTablename($tableName)), 
     26    )); 
     27  } 
    2028} 
  • plugins/sfPropelPlugin/branches/migration/lib/propel/builder/sql/SforacleDDLBuilder.php

    r11245 r11247  
    1818    return $script; 
    1919  } 
     20 
     21  public function getDropIndexStatement($tableName, $indexName, $indexType) 
     22  { 
     23    return sprintf('DROP INDEX %s;', $this->quoteIdentifier($indexName)); 
     24  } 
    2025} 
  • plugins/sfPropelPlugin/branches/migration/lib/propel/builder/sql/SfpgsqlDDLBuilder.php

    r11245 r11247  
    1818    return $script; 
    1919  } 
     20 
     21  public function getDropIndexStatement($tableName, $indexName, $indexType) 
     22  { 
     23    return sprintf('DROP INDEX %s CASCADE;', $this->quoteIdentifier($indexName)); 
     24  } 
    2025} 
  • plugins/sfPropelPlugin/branches/migration/lib/propel/builder/sql/SfsqliteDDLBuilder.php

    r11245 r11247  
    1818    return $script; 
    1919  } 
     20 
     21  public function getDropIndexStatement($tableName, $indexName, $indexType) 
     22  { 
     23    return sprintf('DROP INDEX %s;', $this->quoteIdentifier($indexName)); 
     24  } 
    2025} 
  • plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelIndex.class.php

    r11242 r11247  
    8282    $indexClass = $this->type; 
    8383    $index = new $indexClass; 
     84    $index->setName($this->name); 
    8485 
    8586    $columns = array_combine(array_map(create_function('$c', 'return $c->getName();'), $columns), $columns); 
     
    108109    $builder = $this->getBuilder($table->asPropel()); 
    109110 
    110     $script = vsprintf('CREATE %sINDEX %s ON %s (%s);', array( 
     111    $script  = $builder->getDatabaseStartDDL(); 
     112    $script .= vsprintf('CREATE %sINDEX %s ON %s (%s);', array( 
    111113      'unique' == $this->type ? 'UNIQUE ' : '', 
    112114      $builder->quoteIdentifier($this->name), 
     
    114116      $this->getColumnList($builder), 
    115117    )); 
     118    $script .= $builder->getDatabaseEndDDL(); 
    116119 
    117     return $builder->getDatabaseStartDDL()."\n".$script."\n".$builder->getDatabaseEndDDL(); 
     120    return $script; 
     121  } 
     122 
     123  public function asDropSql(sfPropelTable $table) 
     124  { 
     125    $builder = $this->getBuilder($table->asPropel()); 
     126 
     127    $script  = $builder->getDatabaseStartDDL(); 
     128    $script .= $builder->getDropIndexStatement($table->getName(), $this->name, $this->type); 
     129    $script .= $builder->getDatabaseEndDDL(); 
     130 
     131    return $script; 
    118132  } 
    119133 
  • plugins/sfPropelPlugin/branches/migration/lib/propel/migration/model/sfPropelTable.class.php

    r11245 r11247  
    9797    } 
    9898 
     99    $table->doFinalInitialization(); 
     100 
    99101    return $table; 
    100102  } 
     
    102104  public function asCreateSql() 
    103105  { 
    104     $table = $this->asPropel(); 
    105     $table->setDatabase($this->getDatabase()); 
    106     $table->doFinalInitialization(); 
    107  
    108     $builder = $this->getBuilder($table); 
     106    $builder = $this->getBuilder($this->asPropel()); 
    109107 
    110108    $script  = $builder->getDatabaseStartDDL(); 
     
    117115  public function asDropSql() 
    118116  { 
    119     $table = $this->asPropel(); 
    120     $table->setDatabase($this->getDatabase()); 
    121     $table->doFinalInitialization(); 
    122  
    123     $builder = $this->getBuilder($table); 
     117    $builder = $this->getBuilder($this->asPropel()); 
    124118 
    125119    $script  = $builder->getDatabaseStartDDL();