Yajra\Oci8\Schema\Sequence::drop PHP Method

drop() public method

function to safely drop sequence db object
public drop ( string $name ) : boolean
$name string
return boolean
    public function drop($name)
    {
        // check if a valid name and sequence exists
        if (!$name || !$this->exists($name)) {
            return false;
        }
        return $this->connection->statement("\n            declare\n                e exception;\n                pragma exception_init(e,-02289);\n            begin\n                execute immediate 'drop sequence {$name}';\n            exception\n            when e then\n                null;\n            end;");
    }

Usage Example

 /**
  * drop sequence and triggers if exists, autoincrement objects
  *
  * @param  string $table
  * @return null
  */
 public function dropAutoIncrementObjects($table)
 {
     // drop sequence and trigger object
     $prefix = $this->connection->getTablePrefix();
     // get the actual primary column name from table
     $col = $this->getPrimaryKey($prefix . $table);
     // if primary key col is set, drop auto increment objects
     if (isset($col) and !empty($col)) {
         // drop sequence for auto increment
         $sequenceName = $this->createObjectName($prefix, $table, $col, 'seq');
         $this->sequence->drop($sequenceName);
         // drop trigger for auto increment work around
         $triggerName = $this->createObjectName($prefix, $table, $col, 'trg');
         $this->trigger->drop($triggerName);
     }
 }