mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
CI Init
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_Init extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
// Schemas
|
||||
//$this->db->query('CREATE SCHEMA IF NOT EXISTS gis;');
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//$this->db->query('DROP SCHEMA IF EXISTS gis;');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_Pk_migrations extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
|
||||
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;');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_Add_apikey extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->dbforge->add_field(array(
|
||||
'apikey_id' => array(
|
||||
'type' => 'INT',
|
||||
'constraint' => 5,
|
||||
'unsigned' => TRUE,
|
||||
'auto_increment' => TRUE
|
||||
),
|
||||
'key' => array(
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => '100',
|
||||
),
|
||||
'level' => array(
|
||||
'type' => 'INT',
|
||||
'null' => TRUE,
|
||||
),
|
||||
'ignore_limits' => array(
|
||||
'type' => 'INT',
|
||||
'null' => TRUE,
|
||||
),
|
||||
'date_created' => array(
|
||||
'type' => 'DATE',
|
||||
'null' => TRUE,
|
||||
'default' => 'now()'
|
||||
)
|
||||
));
|
||||
$this->dbforge->add_key('apikey_id', TRUE);
|
||||
if (!$this->db->table_exists('ci_apikey'))
|
||||
{
|
||||
$this->dbforge->create_table('ci_apikey');
|
||||
}
|
||||
|
||||
if (!$this->db->simple_query("INSERT INTO ci_apikey (key) VALUES ('[email protected]');"))
|
||||
{
|
||||
echo "Error DB-Insert!";
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dbforge->drop_table('ci_apikey');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Migration_Create_basedb extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->load->helper('file');
|
||||
$sqlfile = read_file('./system/fhcomplete3.0.sql');
|
||||
|
||||
if (!$this->db->simple_query($sqlfile))
|
||||
{
|
||||
echo "Error creating Basis DB-Schema!";
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->db->simple_query('DROP SCHEMA addon;');
|
||||
$this->db->simple_query('DROP SCHEMA bis;');
|
||||
$this->db->simple_query('DROP SCHEMA campus;');
|
||||
$this->db->simple_query('DROP SCHEMA fue;');
|
||||
$this->db->simple_query('DROP SCHEMA kommune;');
|
||||
$this->db->simple_query('DROP SCHEMA lehre;');
|
||||
$this->db->simple_query('DROP SCHEMA reports;');
|
||||
$this->db->simple_query('DROP SCHEMA sync;');
|
||||
$this->db->simple_query('DROP SCHEMA system;');
|
||||
$this->db->simple_query('DROP SCHEMA testtool;');
|
||||
$this->db->simple_query('DROP SCHEMA wawi;');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user