application/migrations/002_pk_migrations.php now is using MigrationLib

This commit is contained in:
bison-paolo
2016-11-11 14:44:16 +01:00
parent 8025974438
commit 857eef0ff6
2 changed files with 62 additions and 48 deletions
+31 -31
View File
@@ -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 '<br/>';
$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;
');*/
}
}
+31 -17
View File
@@ -1,22 +1,36 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
if (! defined("BASEPATH")) exit("No direct script access allowed");
class Migration_Pk_migrations extends CI_Migration {
require_once APPPATH . "/libraries/MigrationLib.php";
public function up()
{
//$this->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();
}
}