mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
created alteration_message method to replace all the code used to echo changes when dbbuild runs, with appropriate colouring.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@40809 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
46c9efaecc
commit
e386cbae57
@ -1595,9 +1595,7 @@ class DataObject extends Controller {
|
|||||||
$obj = new $baseClass($record);
|
$obj = new $baseClass($record);
|
||||||
$obj->write();
|
$obj->write();
|
||||||
}
|
}
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Added default records to $baseClass table","created");
|
||||||
echo "<li style=\"color: green\">Added default records to $baseClass table</li>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,9 +204,7 @@ abstract class Database extends Object {
|
|||||||
function requireTable($table, $fieldSchema = null, $indexSchema = null) {
|
function requireTable($table, $fieldSchema = null, $indexSchema = null) {
|
||||||
if(!isset($this->tableList[strtolower($table)])) {
|
if(!isset($this->tableList[strtolower($table)])) {
|
||||||
$this->transCreateTable($table);
|
$this->transCreateTable($table);
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Table $table: created","created");
|
||||||
echo "<li style=\"color: green\">Table $table: created</li>";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->checkAndRepairTable($table);
|
$this->checkAndRepairTable($table);
|
||||||
}
|
}
|
||||||
@ -239,9 +237,7 @@ abstract class Database extends Object {
|
|||||||
$suffix = $suffix ? ($suffix+1) : 2;
|
$suffix = $suffix ? ($suffix+1) : 2;
|
||||||
}
|
}
|
||||||
$this->renameTable($table, "_obsolete_{$table}$suffix");
|
$this->renameTable($table, "_obsolete_{$table}$suffix");
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Table $table: renamed to _obsolete_{$table}$suffix","obsolete");
|
||||||
echo "<li style=\"color: red\">Table $table: renamed to _obsolete_{$table}$suffix</li>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,14 +262,10 @@ abstract class Database extends Object {
|
|||||||
}
|
}
|
||||||
if($newTable || !isset($this->indexList[$table][$index])) {
|
if($newTable || !isset($this->indexList[$table][$index])) {
|
||||||
$this->transCreateIndex($table, $index, $spec);
|
$this->transCreateIndex($table, $index, $spec);
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Index $table.$index: created as $spec","created");
|
||||||
echo "<li style=\"color: green\">Index $table.$index: created as $spec</li>";
|
|
||||||
}
|
|
||||||
} else if($this->indexList[$table][$index] != $spec) {
|
} else if($this->indexList[$table][$index] != $spec) {
|
||||||
$this->transAlterIndex($table, $index, $spec);
|
$this->transAlterIndex($table, $index, $spec);
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Index $table.$index: changed to $spec <i style=\"color: #AAA\">(from {$this->indexList[$table][$index]})</i>","changed");
|
||||||
echo "<li style=\"color: blue\">Index $table.$index: changed to $spec <i style=\"color: #AAA\">(from {$this->indexList[$table][$index]})</i></li>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,16 +294,12 @@ abstract class Database extends Object {
|
|||||||
Profiler::mark('createField');
|
Profiler::mark('createField');
|
||||||
$this->transCreateField($table, $field, $spec);
|
$this->transCreateField($table, $field, $spec);
|
||||||
Profiler::unmark('createField');
|
Profiler::unmark('createField');
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Field $table.$field: created as $spec","created");
|
||||||
echo "<li style=\"color: green\">Field $table.$field: created as $spec</li>";
|
|
||||||
}
|
|
||||||
} else if($this->fieldList[$table][$field] != $spec) {
|
} else if($this->fieldList[$table][$field] != $spec) {
|
||||||
Profiler::mark('alterField');
|
Profiler::mark('alterField');
|
||||||
$this->transAlterField($table, $field, $spec);
|
$this->transAlterField($table, $field, $spec);
|
||||||
Profiler::unmark('alterField');
|
Profiler::unmark('alterField');
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Field $table.$field: changed to $spec <i style=\"color: #AAA\">(from {$this->fieldList[$table][$field]})</i>","changed");
|
||||||
echo "<li style=\"color: blue\">Field $table.$field: changed to $spec <i style=\"color: #AAA\">(from {$this->fieldList[$table][$field]})</i></li>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Profiler::unmark('requireField');
|
Profiler::unmark('requireField');
|
||||||
}
|
}
|
||||||
@ -387,6 +375,35 @@ abstract class Database extends Object {
|
|||||||
Database::$supressOutput = true;
|
Database::$supressOutput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function alteration_message($message,$type=""){
|
||||||
|
if(!Database::$supressOutput) {
|
||||||
|
$color = "";
|
||||||
|
switch ($type){
|
||||||
|
case "created":
|
||||||
|
$color = "green";
|
||||||
|
break;
|
||||||
|
case "obsolete":
|
||||||
|
$color = "red";
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
$color = "red";
|
||||||
|
break;
|
||||||
|
case "deleted":
|
||||||
|
$color = "red";
|
||||||
|
break;
|
||||||
|
case "changed":
|
||||||
|
$color = "blue";
|
||||||
|
break;
|
||||||
|
case "repaired":
|
||||||
|
$color = "blue";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$color="";
|
||||||
|
}
|
||||||
|
echo "<li style=\"color: $color\">$message</li>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,10 +34,7 @@ class ErrorPage extends Page {
|
|||||||
// Don't publish, as the manifest may not be built yet
|
// Don't publish, as the manifest may not be built yet
|
||||||
// $errorpage->publish("Stage", "Live");
|
// $errorpage->publish("Stage", "Live");
|
||||||
|
|
||||||
|
Database::alteration_message("404 page created","created");
|
||||||
if(!Database::$supressOutput) {
|
|
||||||
echo "<li style=\"color: green\">404 page created</li>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,10 +206,7 @@ class MySQLDatabase extends Database {
|
|||||||
*/
|
*/
|
||||||
public function checkAndRepairTable($tableName) {
|
public function checkAndRepairTable($tableName) {
|
||||||
if(!$this->runTableCheckCommand("CHECK TABLE `$tableName`")) {
|
if(!$this->runTableCheckCommand("CHECK TABLE `$tableName`")) {
|
||||||
if(!Database::$supressOutput) {
|
Database::alteration_message("Table $tableName: repaired","repaired");
|
||||||
echo "<li style=\"color: blue\">Table $tableName: repaired</li>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->runTableCheckCommand("REPAIR TABLE `$tableName` USE_FRM");
|
return $this->runTableCheckCommand("REPAIR TABLE `$tableName` USE_FRM");
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -406,10 +406,7 @@ class SiteTree extends DataObject {
|
|||||||
$homepage->write();
|
$homepage->write();
|
||||||
$homepage->publish("Stage", "Live");
|
$homepage->publish("Stage", "Live");
|
||||||
$homepage->flushCache();
|
$homepage->flushCache();
|
||||||
|
Database::alteration_message("Home page created","created");
|
||||||
if(!Database::$supressOutput) {
|
|
||||||
echo "<li style=\"color: green\">Home page created</li>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DB::query("SELECT COUNT(*) FROM SiteTree")->value() == 1) {
|
if(DB::query("SELECT COUNT(*) FROM SiteTree")->value() == 1) {
|
||||||
@ -420,10 +417,7 @@ class SiteTree extends DataObject {
|
|||||||
$aboutus->Status = "Published";
|
$aboutus->Status = "Published";
|
||||||
$aboutus->write();
|
$aboutus->write();
|
||||||
$aboutus->publish("Stage", "Live");
|
$aboutus->publish("Stage", "Live");
|
||||||
|
Database::alteration_message("About Us created","created");
|
||||||
if(!Database::$supressOutput) {
|
|
||||||
echo "<li style=\"color: green\">About Us created</li>";
|
|
||||||
}
|
|
||||||
|
|
||||||
$contactus = new Page();
|
$contactus = new Page();
|
||||||
$contactus->Title = "Contact Us";
|
$contactus->Title = "Contact Us";
|
||||||
|
@ -426,10 +426,7 @@ class Member extends DataObject {
|
|||||||
|
|
||||||
if(!DB::query("SELECT * FROM Member")->value() && isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
|
if(!DB::query("SELECT * FROM Member")->value() && isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
|
||||||
Security::findAnAdministrator($_REQUEST['username'], $_REQUEST['password']);
|
Security::findAnAdministrator($_REQUEST['username'], $_REQUEST['password']);
|
||||||
|
Database::alteration_message("Added admin account","created");
|
||||||
if(!Database::$supressOutput) {
|
|
||||||
echo "<li style=\"color: green\">Added admin account</li>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user