Exemple #1
0
    /**
     * Create migrations table of not exists
     */
    protected function checkCreateMigrationTable()
    {
        if (strpos($this->connection->getDriverName(), 'mysql') !== false) {
            $sql = <<<TABLE
CREATE TABLE IF NOT EXISTS `%s` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `mdir` text NOT NULL ,
  `mdir_md5` varchar(64) NOT NULL ,
  `version` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `version` (`version`),
  KEY `mdir_md5` (`mdir_md5`)
);
TABLE;
        } else {
            $sql = <<<TABLE
CREATE TABLE IF NOT EXISTS "%s" (
  "id"  SERIAL NOT NULL,
  `mdir` text NOT NULL ,
  `mdir_md5` varchar(64) NOT NULL ,
  "version" bigint NOT NULL,
  PRIMARY KEY ("id")
);
TABLE;
        }
        $this->connection->execute(sprintf($sql, Migration::MIGRATION_TABLE));
    }
Exemple #2
0
 public function export(ConnectionInterface $connection, Schema\AbstractExpoter $exporter = null, $schemaName = null)
 {
     if (!$exporter) {
         switch ($connection->getDriverName()) {
             case 'Mysql':
                 $exporter = new Schema\MySql\Exporter($connection);
                 break;
             case 'Sqlite':
                 $exporter = new Schema\Sqlite\Exporter($connection);
                 break;
             default:
                 throw new Exception\RuntimeException(sprintf("Unknown/unsupported driver %s", $driverName));
         }
     }
     return $exporter->export($schemaName);
 }
Exemple #3
0
 public function import(ConnectionInterface $connection, $filepath, Schema\AbstractImporter $importer = null)
 {
     if (!$importer) {
         switch ($connection->getDriverName()) {
             case 'Mysql':
                 $importer = new Schema\MySql\Importer($connection);
                 break;
             case 'Sqlite':
                 $importer = new Schema\Sqlite\Importer($connection);
                 break;
             default:
                 throw new Exception\RuntimeException(sprintf("Unknown/unsupported driver %s", $driverName));
         }
     }
     $importer->importFile($filepath);
 }