- Improved MigrationLib

- Improved migration script 011_reihungstest
- Added migration script 012_bewerbungsfrist
This commit is contained in:
paolo
2016-07-15 14:57:57 +02:00
parent 2568d8f912
commit 15a1eb2afd
3 changed files with 145 additions and 16 deletions
+41
View File
@@ -74,6 +74,16 @@ class MigrationLib extends CI_Migration
$this->printInfo(sprintf("%s End method up of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR));
}
protected function startDown()
{
$this->printInfo(sprintf("%s Start method down of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR));
}
protected function endDown()
{
$this->printInfo(sprintf("%s End method down of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR));
}
protected function addColumn($schema, $table, $fields)
{
foreach($fields as $name => $definition)
@@ -96,6 +106,25 @@ class MigrationLib extends CI_Migration
}
}
protected function dropColumn($schema, $table, $field)
{
if ($this->columnExists($field, $schema, $table))
{
if ($this->dbforge->drop_column($schema . '.' . $table, $field))
{
$this->printMessage(sprintf("Column %s.%s.%s has been dropped", $schema, $table, $field));
}
else
{
$this->printError(sprintf("Error while dropping column %s.%s.%s", $schema, $table, $field));
}
}
else
{
$this->printInfo(sprintf("Column %s.%s.%s doesn't exist", $schema, $table, $field));
}
}
protected function addPrimaryKey($schema, $table, $name, $fields)
{
$stringFields = null;
@@ -207,6 +236,18 @@ class MigrationLib extends CI_Migration
}
}
protected function dropTable($schema, $table)
{
if ($this->dbforge->drop_table($schema . "." . $table))
{
$this->printMessage(sprintf("Table %s.%s has been dropped", $schema, $table));
}
else
{
$this->printError(sprintf("Dropping table %s.%s", $schema, $table));
}
}
protected function execQuery($query)
{
if (! @$this->db->simple_query($query))