Skip to content

Commit

Permalink
API Update API to reflect changes to CLI interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 23, 2024
1 parent a8efc75 commit 5e36cce
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/TestSessionEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\FixtureFactory;
use SilverStripe\PolyExecution\Command\DbBuild;
use SilverStripe\PolyExecution\PolyOutput;
use SilverStripe\Dev\YamlFixture;
use SilverStripe\ORM\Connect\TempDatabase;
use SilverStripe\ORM\DatabaseAdmin;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Versioned\Versioned;
Expand Down Expand Up @@ -370,19 +371,27 @@ public function importDatabase($path, $requireDefaultRecords = false)
}

// In case the dump involved CREATE TABLE commands, we need to ensure the schema is still up to date
$dbAdmin = new DatabaseAdmin();
$dbBuild = new DbBuild();
Versioned::set_reading_mode('');
$dbAdmin->doBuild(true, $requireDefaultRecords);
$output = new PolyOutput(
Director::is_cli() ? PolyOutput::FORMAT_ANSI : PolyOutput::FORMAT_HTML,
PolyOutput::VERBOSITY_QUIET
);
$dbBuild->doBuild($output, $requireDefaultRecords);
}

/**
* Build the database with default records, see {@link DataObject->requireDefaultRecords()}.
*/
public function requireDefaultRecords()
{
$dbAdmin = new DatabaseAdmin();
$dbBuild = new DbBuild();
Versioned::set_reading_mode('');
$dbAdmin->doBuild(true, true);
$output = new PolyOutput(
Director::is_cli() ? PolyOutput::FORMAT_ANSI : PolyOutput::FORMAT_HTML,
PolyOutput::VERBOSITY_QUIET
);
$dbBuild->doBuild($output, true);
}

/**
Expand Down

0 comments on commit 5e36cce

Please sign in to comment.