public function checkSchema(Repository $inRepository)
    {
        try {
            /** @var MySql $repos */
            $repos = get_class($inRepository);

            if (stripos($repos, "MySql") === false) {
                // If our repos has been switched to something that isn't MySql (e.g. Offline if unit testing)
                // we need to exit.

                return;
            }

            $existingSchema = MySqlComparisonSchema::fromTable($this->schemaName);
            $testSchema = MySqlComparisonSchema::fromMySqlSchema($this);

            $alterStatement = $testSchema->createAlterTableStatementFor($existingSchema);

            if ($alterStatement != false) {
                $alterStatement = "ALTER TABLE `" . $this->schemaName . "` " . $alterStatement;

                try {
                    $repos::executeStatement($alterStatement);
                } catch (RepositoryStatementException $er) {
                    // The update of the schema failed - probably meaning bad news!
                    Log::error("Database schema update failed: $this->schemaName", "ERROR", [
                        "SQL Statement" => $alterStatement,
                        "Exception"     => $er->getMessage()
                    ]);
                }
            }
        } catch (RepositoryStatementException $er) {
            $this->createTable();
        }
    }
public function checkSchema(Repository $inRepository)
    {
        try {
            /** @var MySql $repos */
            $repos = get_class($inRepository);

            if (stripos($repos, "MySql") === false) {
                // If our repos has been switched to something that isn't MySql (e.g. Offline if unit testing)
                // we need to exit.

                return;
            }

            $existingSchema = MySqlComparisonSchema::fromTable($this->schemaName);
            $testSchema = MySqlComparisonSchema::fromMySqlSchema($this);

            $alterStatement = $testSchema->createAlterTableStatementFor($existingSchema);

            if ($alterStatement != false) {
                $alterStatement = "ALTER TABLE `" . $this->schemaName . "` " . $alterStatement;

                try {
                    $repos::executeStatement($alterStatement);
                } catch (RepositoryStatementException $er) {
                    // The update of the schema failed - probably meaning bad news!
                    Log::error("Database schema update failed: $this->schemaName", "ERROR", [
                        "SQL Statement" => $alterStatement,
                        "Exception"     => $er->getMessage()
                    ]);
                }
            }
        } catch (RepositoryStatementException $er) {
            $this->createTable();
        }
    }
public function checkSchema ( Repository $ inRepository ) { try { /** @var MySql $repos */ $ repos = get_class ( $ inRepository ) ; if ( stripos ( $ repos , "MySql" ) === false ) { // If our repos has been switched to something that isn't MySql (e.g. Offline if unit testing) // we need to exit. return ; } $ existingSchema = MySqlComparisonSchema :: fromTable ( $ this -> schemaName ) ; $ testSchema = MySqlComparisonSchema :: fromMySqlSchema ( $ this ) ; $ alterStatement = $ testSchema -> createAlterTableStatementFor ( $ existingSchema ) ; if ( $ alterStatement != false ) { $ alterStatement = "ALTER TABLE `" . $ this -> schemaName . "` " . $ alterStatement ; try { $ repos :: executeStatement ( $ alterStatement ) ; } catch ( RepositoryStatementException $ er ) { // The update of the schema failed - probably meaning bad news! Log :: error ( "Database schema update failed: $this->schemaName" , "ERROR" , [ "SQL Statement" => $ alterStatement , "Exception" => $ er -> getMessage ( ) ] ) ; } } } catch ( RepositoryStatementException $ er ) { $ this -> createTable ( ) ; } }
Check to see if the back end schema is up to date - if not update it.

@param Repository $inRepository The repository in which to check the schema
Check to see if the back end schema is up to date - if not update it .