From 1846a9c0fae6541b0eab130a506e9c5ce18c2d7f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 16 Sep 2017 14:28:30 +0200 Subject: Update ci_session table for CI3 Signed-off-by: Florian Pritz --- .../migrations/020_update_session_table.php | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 application/migrations/020_update_session_table.php (limited to 'application/migrations/020_update_session_table.php') diff --git a/application/migrations/020_update_session_table.php b/application/migrations/020_update_session_table.php new file mode 100644 index 000000000..9052071e0 --- /dev/null +++ b/application/migrations/020_update_session_table.php @@ -0,0 +1,42 @@ +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"; + '); + } else { + $this->db->query(' + ALTER TABLE `'.$prefix.'ci_sessions` + DROP `user_agent`, + CHANGE `session_id` `id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 0, + 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"); + } +} -- cgit v1.2.3-24-g4f1b From 2342ef0eed12a5dd8c368b37c5b8d8d193f10aed Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 26 Sep 2017 13:41:09 +0200 Subject: Migration 20: Fix id column size Signed-off-by: Florian Pritz --- application/migrations/020_update_session_table.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'application/migrations/020_update_session_table.php') diff --git a/application/migrations/020_update_session_table.php b/application/migrations/020_update_session_table.php index 9052071e0..716b95efb 100644 --- a/application/migrations/020_update_session_table.php +++ b/application/migrations/020_update_session_table.php @@ -24,11 +24,14 @@ class Migration_update_session_table extends CI_Migration { 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(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 0, + 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; '); -- cgit v1.2.3-24-g4f1b