summaryrefslogtreecommitdiffstats
path: root/application/migrations/020_update_session_table.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-09-26 13:46:14 +0200
committerFlorian Pritz <bluewind@xinu.at>2017-09-26 13:46:14 +0200
commit3ff6ffa3341c876b741feb66552cdd110b67872e (patch)
tree69e11cd0009ddd1346f2dc4cd8c47244368db28e /application/migrations/020_update_session_table.php
parentbc2f7f596f727e204e8b8c5b849545745b3cbfaa (diff)
parent81a4c8c630ef59cffea0c24e64fb6fa7f09bfcf6 (diff)
Merge CodeIgniter 3 support
Diffstat (limited to 'application/migrations/020_update_session_table.php')
-rw-r--r--application/migrations/020_update_session_table.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/application/migrations/020_update_session_table.php b/application/migrations/020_update_session_table.php
new file mode 100644
index 000000000..716b95efb
--- /dev/null
+++ b/application/migrations/020_update_session_table.php
@@ -0,0 +1,45 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_update_session_table extends CI_Migration {
+
+ public function up()
+ {
+ $prefix = $this->db->dbprefix;
+
+ if ($this->db->dbdriver == 'postgre') {
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'ci_sessions"
+ DROP COLUMN "user_agent";
+ ');
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'ci_sessions"
+ RENAME COLUMN "session_id" TO "id";
+ ');
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'ci_sessions"
+ RENAME COLUMN "last_activity" TO "timestamp";
+ ');
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'ci_sessions"
+ RENAME COLUMN "user_data" TO "data";
+ ');
+ $this->db->query('
+ ALTER TABLE ci_sessions ALTER COLUMN id SET DATA TYPE varchar(128);
+ ');
+ } else {
+ $this->db->query('
+ ALTER TABLE `'.$prefix.'ci_sessions`
+ DROP `user_agent`,
+ CHANGE `session_id` `id` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
+ CHANGE `last_activity` `timestamp` INT(10) UNSIGNED NOT NULL DEFAULT 0,
+ CHANGE `user_data` `data` BLOB NOT NULL;
+ ');
+ }
+ }
+
+ public function down()
+ {
+ throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported");
+ }
+}