connection->getDatabasePlatform()->getName(); switch ($db_type) { case 'mysql': $this->mySQLUp($schema); break; case 'sqlite': $this->sqLiteUp($schema); break; default: $this->abortIf(true, "Database type '$db_type' is not supported!"); break; } } public function down(Schema $schema): void { $db_type = $this->connection->getDatabasePlatform()->getName(); switch ($db_type) { case 'mysql': $this->mySQLDown($schema); break; case 'sqlite': $this->sqLiteDown($schema); break; default: $this->abortIf(true, "Database type '$db_type' is not supported!"); break; } } /** * Gets the legacy Part-DB version number. Returns 0, if target database is not an legacy Part-DB database. * @return int */ public function getOldDBVersion(): int { if ($this->connection->getDatabasePlatform()->getName() !== "mysql") { //Old Part-DB version only supported MySQL therefore only return 0; } try { return (int) $this->connection->fetchColumn("SELECT keyValue AS version FROM `internal` WHERE `keyName` = 'dbVersion'"); } catch (DBALException $dBALException) { //when the table was not found, we can proceed, because we have an empty DB! return 0; } } public function getInitalAdminPW(): string { //CHANGEME: Improve this return '$2y$10$36AnqCBS.YnHlVdM4UQ0oOCV7BjU7NmE0qnAVEex65AyZw1cbcEjq'; } public function printPermissionUpdateMessage(): void { $this->permissions_updated = true; //$this->write('[!!!] Permissions were updated! Please check if they fit your expectations!'); } public function postUp(Schema $schema): void { parent::postUp($schema); $this->write('[!!!] Permissions were updated! Please check if they fit your expectations!'); } abstract public function mySQLUp(Schema $schema): void; abstract public function mySQLDown(Schema $schema): void; abstract public function sqLiteUp(Schema $schema): void; abstract public function sqLiteDown(Schema $schema): void; }