Example #1
0
 /**
  * Maps logical Rails types to PostgreSQL-specific data types.
  */
 public function typeToSql($type, $limit = null, $precision = null, $scale = null)
 {
     if ($type != 'integer') {
         return parent::typeToSql($type, $limit, $precision, $scale);
     }
     switch ($limit) {
         case 1:
         case 2:
             return 'smallint';
         case 3:
         case 4:
         case null:
             return 'integer';
         case 5:
         case 6:
         case 7:
         case 8:
             return 'bigint';
         default:
             throw new Horde_Db_Exception("No integer type has byte size {$limit}. Use a numeric with precision 0 instead.");
     }
 }
Example #2
0
 /**
  * Adds a new column to the named table.
  * See TableDefinition#column for details of the options you can use.
  *
  * @param   string  $tableName
  * @param   string  $columnName
  * @param   string  $type
  * @param   array   $options
  */
 public function addColumn($tableName, $columnName, $type, $options = array())
 {
     if ($this->transactionStarted()) {
         throw new Horde_Db_Exception('Cannot add columns to a SQLite database while inside a transaction');
     }
     parent::addColumn($tableName, $columnName, $type, $options);
     // See last paragraph on http://www.sqlite.org/lang_altertable.html
     $this->execute('VACUUM');
 }
Example #3
0
 /**
  * Add AFTER option
  *
  * @param   string  $sql
  * @param   array   $options
  * @return  string
  */
 public function addColumnOptions($sql, $options)
 {
     $sql = parent::addColumnOptions($sql, $options);
     if (isset($options['after'])) {
         $sql .= " AFTER " . $this->quoteColumnName($options['after']);
     }
     return $sql;
 }