- Added migration script to removing table lehre.tbl_bewerbungsfrist

- Added migration script to adding column studienplan_id and relative foreign key
to table public.tbl_bewerbungstermine
- Changed model Studiengang_model to use the new column in table public.tbl_bewerbungstermine
This commit is contained in:
bison
2016-09-07 12:15:02 +02:00
parent 0b5644d6f1
commit 3065b02512
3 changed files with 152 additions and 4 deletions
@@ -0,0 +1,96 @@
<?php
if (! defined("BASEPATH")) exit("No direct script access allowed");
require_once APPPATH . "/libraries/MigrationLib.php";
class Migration_Bewerbungsfrist2 extends MigrationLib
{
public function __construct()
{
parent::__construct();
}
public function up()
{
$this->startUP();
$this->dropTable("lehre", "tbl_bewerbungsfrist");
$this->endUP();
}
public function down()
{
$this->startDown();
// Create table lehre.tbl_bewerbungsfrist
$fields = array(
"bewerbungsfrist_id" => array(
"type" => "integer",
"auto_increment" => true
),
"studiensemester_kurzbz" => array(
"type" => "varchar(16)"
),
"begin" => array(
"type" => "date"
),
"ende" => array(
"type" => "date"
),
"ende" => array(
"type" => "date"
),
"nachfrist" => array(
"type" => "boolean DEFAULT FALSE",
"null" => true
),
"nachfristende" => array(
"type" => "date",
"null" => true
),
"anmerkung" => array(
"type" => "text"
),
"insertamum" => array(
"type" => "timestamp DEFAULT NOW()",
"null" => true
),
"insertvon" => array(
"type" => "varchar(32)",
"null" => true
),
"updateamum" => array(
"type" => "timestamp DEFAULT NOW()",
"null" => true
),
"updatevon" => array(
"type" => "varchar(32)",
"null" => true
)
);
$this->createTable("lehre", "tbl_bewerbungsfrist", $fields);
$this->addPrimaryKey(
"lehre",
"tbl_bewerbungsfrist",
"pk_tbl_bewerbungsfrist",
array("bewerbungsfrist_id")
);
$this->addForeingKey(
"lehre",
"tbl_bewerbungsfrist",
"fk_bewerbungsfrist_studiensemester_kurzbz",
"studiensemester_kurzbz",
"public",
"tbl_studiensemester",
"studiensemester_kurzbz",
"ON UPDATE CASCADE ON DELETE RESTRICT"
);
$this->grantTable("SELECT", "lehre", "tbl_bewerbungsfrist", "web");
$this->grantTable(array("SELECT", "INSERT", "DELETE", "UPDATE"), "lehre", "tbl_bewerbungsfrist", "admin");
$this->grantTable(array("SELECT", "INSERT", "DELETE", "UPDATE"), "lehre", "tbl_bewerbungsfrist", "vilesci");
$this->endDown();
}
}
@@ -0,0 +1,49 @@
<?php
if (! defined("BASEPATH")) exit("No direct script access allowed");
require_once APPPATH . "/libraries/MigrationLib.php";
class Migration_Bewerbungstermine extends MigrationLib
{
public function __construct()
{
parent::__construct();
}
public function up()
{
$this->startUP();
// Add studienplan_id to public.tbl_bewerbungstermine
$columns = array(
"studienplan_id" => array(
"type" => "integer",
"null" => true
)
);
$this->addColumn("public", "tbl_bewerbungstermine", $columns);
$this->addForeingKey(
"public",
"tbl_bewerbungstermine",
"fk_bewerbungstermine_studienplan_id",
"studienplan_id",
"lehre",
"tbl_studienplan",
"studienplan_id",
"ON UPDATE CASCADE ON DELETE RESTRICT"
);
$this->endUP();
}
public function down()
{
$this->startDown();
$this->dropColumn("public", "tbl_bewerbungstermine", "studienplan_id");
$this->endDown();
}
}
@@ -146,9 +146,12 @@ class Studiengang_model extends DB_Model
// Then join with table lehre.tbl_studienplan on column studienordnung_id
$this->addJoin("lehre.tbl_studienplan", "studienordnung_id");
// Then join with table lehre.tbl_studienplan_semester on column studienplan_id
$this->addJoin("lehre.tbl_studienplan_semester", "studienplan_id");
$this->addJoin("lehre.tbl_studienplan_semester ss", "studienplan_id");
// Then join with table lehre.tbl_bewerbungsfrist on column studiensemester_kurzbz
$this->addJoin("public.tbl_bewerbungstermine", "studiensemester_kurzbz");
$this->addJoin(
"public.tbl_bewerbungstermine b",
"b.studiensemester_kurzbz = ss.studiensemester_kurzbz AND b.studienplan_id = ss.studienplan_id"
);
// Ordering by studiengang_kz and studienplan_id
$this->addOrder("public.tbl_studiengang.studiengang_kz");
@@ -162,8 +165,8 @@ class Studiengang_model extends DB_Model
array(
"public.tbl_studiengang.aktiv" => "true",
"public.tbl_studiengang.onlinebewerbung" => "true",
"public.tbl_bewerbungstermine.beginn <= " => "NOW()",
"public.tbl_bewerbungstermine.ende >= " => "NOW()"
"b.beginn <= " => "NOW()",
"b.ende >= " => "NOW()"
),
array(
"studienplaene"