summaryrefslogtreecommitdiffstats
path: root/application/migrations
diff options
context:
space:
mode:
authorhashworks <mail@hashworks.net>2017-07-10 20:12:03 +0200
committerhashworks <mail@hashworks.net>2017-07-10 20:12:03 +0200
commit02ffa0c14f1c7401344eee4acde46c000f91bcc7 (patch)
tree6e9e87be9627356cd93ff1a85409d3927820a3b5 /application/migrations
parentb253c9a893077711e503c69970b24ae94e7451ac (diff)
Use bigint for filesize in database
The current type, integer, only stores numerics up to 2147483647. Since filebin stores the size in byte MySQL will only write up to 2GB in there, PostgreSQL failes by default for files >2GB. The new type bigint allows file sizes up to ~9223 petabyte.
Diffstat (limited to 'application/migrations')
-rw-r--r--application/migrations/019_change_filesize_type.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/application/migrations/019_change_filesize_type.php b/application/migrations/019_change_filesize_type.php
new file mode 100644
index 000000000..327d8dcae
--- /dev/null
+++ b/application/migrations/019_change_filesize_type.php
@@ -0,0 +1,27 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+
+class Migration_change_filesize_type extends CI_Migration {
+
+ public function up()
+ {
+ $prefix = $this->db->dbprefix;
+
+ if ($this->db->dbdriver == 'postgre') {
+ $this->db->query('
+ ALTER TABLE "'.$prefix.'file_storage"
+ ALTER "filesize" TYPE bigint;
+ ');
+ } else {
+ $this->db->query('
+ ALTER TABLE `'.$prefix.'file_storage`
+ MODIFY `filesize` bigint;
+ ');
+ }
+ }
+
+ public function down()
+ {
+ throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported");
+ }
+}