1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00
agendav_ynh/sources/web/application/migrations/003_prefs_no_eav.php
2014-01-07 17:53:08 +01:00

36 lines
1.1 KiB
PHP

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Migration_Prefs_no_eav extends CI_Migration {
public function up() {
// New user preferences table
echo "Creating table prefs...\n";
// DBForge doesn't support foreign keys
if (preg_match('/^mysql/', $this->db->dbdriver)) {
$sql = <<< 'MYSQL'
CREATE TABLE prefs (
username VARCHAR(255) NOT NULL,
options TEXT NOT NULL,
PRIMARY KEY(username)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
MYSQL;
} elseif ($this->db->dbdriver == 'postgre') {
$sql = <<< 'PGSQL'
CREATE TABLE prefs (
username varchar(255) not null,
options text not null,
primary key (username));
PGSQL;
} else {
echo 'Unsupported database driver!';
die();
}
$this->db->query($sql);
}
public function down() {
$this->dbforge->drop_table('prefs');
}
}