Migration 011_reihunstest anpassungen

- Add Studienplan_id to testtool.tbl_ablauf
- Add Aktiv to testtool.tbl_frage
- Add Aktiv to testtool.tbl_vorschlag
- Add Bezeichnung_mehrsprachig to testtool.tbl_gebiet
- Typing error "stundenplan_id" corrected to "studienplan_id"
- New column rt_person_id with Primary-Key to tbl_rt_person
- UniqueKey on "person_id","rt_id","studienplan_id"
This commit is contained in:
kindlm
2016-08-09 13:58:39 +02:00
parent 68b911fef4
commit 5e4833bac5
+78 -11
View File
@@ -33,13 +33,38 @@ class Migration_Reihungstest extends MigrationLib
"rt_stufe" => array("type" => "smallint DEFAULT NULL")
);
$this->addColumn("public", "tbl_prestudentstatus", $columns);
// Add studienplan_id to testtool.tbl_ablauf
$columns = array(
"studienplan_id" => array("type" => "integer", "null" => true)
);
$this->addColumn("testtool", "tbl_ablauf", $columns);
// Add aktiv to testtool.tbl_frage
$columns = array(
"aktiv" => array("type" => "boolean DEFAULT TRUE")
);
$this->addColumn("testtool", "tbl_frage", $columns);
// Add aktiv to testtool.tbl_vorschlag
$columns = array(
"aktiv" => array("type" => "boolean DEFAULT TRUE")
);
$this->addColumn("testtool", "tbl_vorschlag", $columns);
// Add bezeichnung_mehrsprachig to testtool.tbl_gebiet
$columns = array(
"bezeichnung_mehrsprachig" => array("type" => "varchar(255)[]")
);
$this->addColumn("testtool", "tbl_gebiet", $columns);
$this->execQuery("UPDATE tbl_gebiet set bezeichnung_mehrsprachig = cast('{\"'||bezeichnung||'\",\"'||bezeichnung||'\"}' as varchar[]);");
// Create table public.tbl_rt_studienplan
$fields = array(
"reihungstest_id" => array(
"type" => "integer"
),
"stundenplan_id" => array(
"studienplan_id" => array(
"type" => "integer"
)
);
@@ -48,7 +73,7 @@ class Migration_Reihungstest extends MigrationLib
"public",
"tbl_rt_studienplan",
"pk_tbl_rt_studienplan",
array("reihungstest_id", "stundenplan_id")
array("reihungstest_id", "studienplan_id")
);
$this->addForeingKey(
"public",
@@ -63,11 +88,22 @@ class Migration_Reihungstest extends MigrationLib
$this->addForeingKey(
"public",
"tbl_rt_studienplan",
"fk_rt_studienplan_stundenplan_id",
"stundenplan_id",
"fk_rt_studienplan_studienplan_id",
"studienplan_id",
"lehre",
"tbl_stundenplan",
"stundenplan_id",
"tbl_studienplan",
"studienplan_id",
"ON UPDATE CASCADE ON DELETE RESTRICT"
);
$this->addForeingKey(
"testtool",
"tbl_ablauf",
"fk_ablauf_studienplan_id",
"studienplan_id",
"lehre",
"tbl_studienplan",
"studienplan_id",
"ON UPDATE CASCADE ON DELETE RESTRICT"
);
$this->grantTable("SELECT", "public", "tbl_rt_studienplan", "web");
@@ -76,23 +112,34 @@ class Migration_Reihungstest extends MigrationLib
// Create table public.tbl_rt_person
$fields = array(
"rt_person_id" => array(
"type" => "integer",
"auto_increment" => true
),
"person_id" => array(
"type" => "integer"
),
"rt_id" => array(
"type" => "integer"
),
"studienplan_id" => array(
"type" => "integer"
),
"anmeldedatum" => array(
"type" => "date"
"type" => "date",
"null" => true
),
"teilgenommen" => array(
"type" => "boolean DEFAULT FALSE"
"type" => "boolean DEFAULT FALSE",
"null" => true
),
"ort_kurzbz" => array(
"type" => "varchar(16)"
"type" => "varchar(16)",
"null" => true
),
"punkte" => array(
"type" => "numeric(8,4) DEFAULT NULL"
"type" => "numeric(8,4) DEFAULT NULL",
"null" => true
)
);
$this->createTable("public", "tbl_rt_person", $fields);
@@ -100,7 +147,7 @@ class Migration_Reihungstest extends MigrationLib
"public",
"tbl_rt_person",
"pk_tbl_rt_person",
array("person_id", "rt_id")
array("rt_person_id")
);
$this->addForeingKey(
"public",
@@ -122,6 +169,22 @@ class Migration_Reihungstest extends MigrationLib
"reihungstest_id",
"ON UPDATE CASCADE ON DELETE RESTRICT"
);
$this->addForeingKey(
"public",
"tbl_rt_person",
"fk_rt_person_studienplan_id",
"studienplan_id",
"lehre",
"tbl_studienplan",
"studienplan_id",
"ON UPDATE CASCADE ON DELETE RESTRICT"
);
$this->addUniqueKey(
"public",
"tbl_rt_person",
"uk_tbl_rt_person_person_id_rt_id_studienplan_id",
array("person_id","rt_id","studienplan_id")
);
$this->grantTable("SELECT", "public", "tbl_rt_person", "web");
$this->grantTable(array("SELECT", "INSERT", "DELETE", "UPDATE"), "public", "tbl_rt_person", "admin");
$this->grantTable(array("SELECT", "INSERT", "DELETE", "UPDATE"), "public", "tbl_rt_person", "vilesci");
@@ -190,6 +253,10 @@ class Migration_Reihungstest extends MigrationLib
$this->dropColumn("public", "tbl_reihungstest", "stufe");
$this->dropColumn("public", "tbl_reihungstest", "anmeldefrist");
$this->dropColumn("public", "tbl_prestudentstatus", "rt_stufe");
$this->dropColumn("testtool", "tbl_ablauf", "studienplan_id");
$this->dropColumn("testtool", "tbl_frage", "aktiv");
$this->dropColumn("testtool", "tbl_vorschlag", "aktiv");
$this->dropColumn("testtool", "tbl_gebiet", "bezeichnung_mehrsprachig");
$this->dropTable("public", "tbl_rt_studienplan");
$this->dropTable("public", "tbl_rt_person");