diff --git a/application/migrations/001_init.php b/application/migrations/001_init.php index 2e74ee38d..7cc9e6dad 100644 --- a/application/migrations/001_init.php +++ b/application/migrations/001_init.php @@ -2,35 +2,35 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); -class Migration_Init extends CI_Migration { - - public function up() - { - $this->load->database('system'); - // Schemas - $this->db->query('CREATE SCHEMA IF NOT EXISTS public;'); - $this->db->query('CREATE SCHEMA IF NOT EXISTS addon;'); - $this->db->query('CREATE SCHEMA IF NOT EXISTS fue;'); - $this->db->query('CREATE SCHEMA IF NOT EXISTS lehre;'); - $this->db->query('CREATE SCHEMA IF NOT EXISTS system;'); - $this->db->query('CREATE SCHEMA IF NOT EXISTS bis;'); - } - - public function down() - { - /* $this->db->query(' - DROP SCHEMA IF EXISTS addon; - DROP SCHEMA IF EXISTS bis; - DROP SCHEMA IF EXISTS campus; - DROP SCHEMA IF EXISTS fue; - DROP SCHEMA IF EXISTS kommune; - DROP SCHEMA IF EXISTS lehre; - DROP SCHEMA IF EXISTS public; - DROP SCHEMA IF EXISTS sync; - DROP SCHEMA IF EXISTS system; - DROP SCHEMA IF EXISTS testtool; - DROP SCHEMA IF EXISTS wawi; - ');*/ - } -} +class Migration_Init extends CI_Migration +{ + public function up() + { + $this->load->database('system'); + // Schemas + echo '
'; + $this->db->query('CREATE SCHEMA IF NOT EXISTS public;'); + $this->db->query('CREATE SCHEMA IF NOT EXISTS addon;'); + $this->db->query('CREATE SCHEMA IF NOT EXISTS fue;'); + $this->db->query('CREATE SCHEMA IF NOT EXISTS lehre;'); + $this->db->query('CREATE SCHEMA IF NOT EXISTS system;'); + $this->db->query('CREATE SCHEMA IF NOT EXISTS bis;'); + } + public function down() + { + /* $this->db->query(' + DROP SCHEMA IF EXISTS addon; + DROP SCHEMA IF EXISTS bis; + DROP SCHEMA IF EXISTS campus; + DROP SCHEMA IF EXISTS fue; + DROP SCHEMA IF EXISTS kommune; + DROP SCHEMA IF EXISTS lehre; + DROP SCHEMA IF EXISTS public; + DROP SCHEMA IF EXISTS sync; + DROP SCHEMA IF EXISTS system; + DROP SCHEMA IF EXISTS testtool; + DROP SCHEMA IF EXISTS wawi; + ');*/ + } +} \ No newline at end of file diff --git a/application/migrations/002_pk_migrations.php b/application/migrations/002_pk_migrations.php index 37342e06f..d378b2a01 100644 --- a/application/migrations/002_pk_migrations.php +++ b/application/migrations/002_pk_migrations.php @@ -1,22 +1,36 @@ load->database('system'); - if ($this->db->table_exists('ci_migrations')) - { - $this->db->query('ALTER TABLE ci_migrations ADD CONSTRAINT pk_migrations PRIMARY KEY(version);'); - } - } - - public function down() - { - $this->db->query('ALTER TABLE ci_migrations DROP CONSTRAINT pk_migrations;'); - } -} +class Migration_Pk_migrations extends MigrationLib +{ + public function __construct() + { + parent::__construct(); + } + + public function up() + { + $this->startUP(); + + $this->addPrimaryKey( + "public", + "ci_migrations", + "pk_migrations", + array("version") + ); + + $this->endUP(); + } + public function down() + { + $this->startDown(); + + $this->execQuery('ALTER TABLE ci_migrations DROP CONSTRAINT pk_migrations'); + + $this->endDown(); + } +} \ No newline at end of file