| @@ 22-28 (lines=7) @@ | ||
| 19 | $dbDriver->execute("IF NOT EXISTS(select * from sys.databases where name='$database') CREATE DATABASE $database"); |
|
| 20 | } |
|
| 21 | ||
| 22 | public function createDatabase() |
|
| 23 | { |
|
| 24 | $database = preg_replace('~^/~', '', $this->getDbDriver()->getUri()->getPath()); |
|
| 25 | ||
| 26 | $this->getDbDriver()->execute("IF NOT EXISTS(select * from sys.databases where name='$database') CREATE DATABASE $database"); |
|
| 27 | $this->getDbDriver()->execute("USE $database"); |
|
| 28 | } |
|
| 29 | ||
| 30 | public function dropDatabase() |
|
| 31 | { |
|
| @@ 30-36 (lines=7) @@ | ||
| 27 | $this->getDbDriver()->execute("USE $database"); |
|
| 28 | } |
|
| 29 | ||
| 30 | public function dropDatabase() |
|
| 31 | { |
|
| 32 | $database = preg_replace('~^/~', '', $this->getDbDriver()->getUri()->getPath()); |
|
| 33 | ||
| 34 | $this->getDbDriver()->execute("use master"); |
|
| 35 | $this->getDbDriver()->execute("drop database $database"); |
|
| 36 | } |
|
| 37 | ||
| 38 | protected function createTableIfNotExists($database, $createTable) |
|
| 39 | { |
|
| @@ 57-63 (lines=7) @@ | ||
| 54 | * @throws \ByJG\DbMigration\Exception\DatabaseNotVersionedException |
|
| 55 | * @throws \ByJG\DbMigration\Exception\OldVersionSchemaException |
|
| 56 | */ |
|
| 57 | public function createVersion() |
|
| 58 | { |
|
| 59 | $database = preg_replace('~^/~', '', $this->getDbDriver()->getUri()->getPath()); |
|
| 60 | $createTable = 'CREATE TABLE ' . $this->getMigrationTable() . ' (version int, status varchar(20))'; |
|
| 61 | $this->createTableIfNotExists($database, $createTable); |
|
| 62 | $this->checkExistsVersion(); |
|
| 63 | } |
|
| 64 | ||
| 65 | public function executeSql($sql) |
|
| 66 | { |
|
| @@ 22-28 (lines=7) @@ | ||
| 19 | $dbDriver->execute("CREATE SCHEMA IF NOT EXISTS `$database` DEFAULT CHARACTER SET utf8 ;"); |
|
| 20 | } |
|
| 21 | ||
| 22 | public function createDatabase() |
|
| 23 | { |
|
| 24 | $database = preg_replace('~^/~', '', $this->getDbDriver()->getUri()->getPath()); |
|
| 25 | ||
| 26 | $this->getDbDriver()->execute("CREATE SCHEMA IF NOT EXISTS `$database` DEFAULT CHARACTER SET utf8 ;"); |
|
| 27 | $this->getDbDriver()->execute("USE `$database`"); |
|
| 28 | } |
|
| 29 | ||
| 30 | public function dropDatabase() |
|
| 31 | { |
|