Example #1
0
 public function resume(SnapshotInterface $snapshot)
 {
     $basic = $snapshot->getBasic();
     $this->database->query("CREATE SCHEMA {$basic['database']}");
     $tables = $snapshot->getTables();
     foreach ($tables as $table) {
         /** @var \MyDbvc\Repository\Database\TableInterface $table */
         $sql = "CREATE TABLE {$basic['database']}.{$table->getName()} (";
         foreach ($table->getColumns() as $column) {
             /** @var \MyDbvc\Repository\Database\ColumnInterface $column */
             $column;
         }
         $sql .= ") ENGINE = {$table->getEngine()} DEFAULT CHARACTER SET = {$table->getCollation()};";
         $table->getCollation();
     }
     /**
     * CREATE TABLE `mydbvc_remote`.`new_table` (
             `idnew_table` INT UNSIGNED NOT NULL AUTO_INCREMENT,
             `new_tablecol` VARCHAR(45) NULL,
             PRIMARY KEY (`idnew_table`),
             UNIQUE INDEX `idnew_table_UNIQUE` (`idnew_table` ASC));
     */
     $snapshot->getViews();
     $snapshot->getRows();
 }
Example #2
0
 public static function create(DatabaseInterface $database, $name)
 {
     $colums = new StructureBag();
     $indexs = new StructureBag();
     $options = array();
     foreach ($database->getRawColumns($name) as $rawColumn) {
         $colums->append(Column::createUsingRawData($rawColumn));
     }
     foreach (Index::mergeRawIndexs($database->getRawIndexs($name)) as $rawIndex) {
         $indexs->append(Index::createUsingRawData($rawIndex));
     }
     foreach ($database->getRawOptions($name) as $rawOptionName => $rawOptionValue) {
         switch ($rawOptionName) {
             case 'Engine':
             case 'Collation':
                 $options[lcfirst(Str::convertCamel($rawOptionName))] = $rawOptionValue;
                 break;
             default:
                 // Ignore other options
         }
     }
     return new static($name, $colums, $indexs, $options);
 }