From 02ffa0c14f1c7401344eee4acde46c000f91bcc7 Mon Sep 17 00:00:00 2001 From: hashworks Date: Mon, 10 Jul 2017 20:12:03 +0200 Subject: 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. --- application/config/migration.php | 2 +- .../migrations/019_change_filesize_type.php | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 application/migrations/019_change_filesize_type.php diff --git a/application/config/migration.php b/application/config/migration.php index 659907cb8..45ce7711b 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -21,7 +21,7 @@ $config['migration_enabled'] = true; | be upgraded / downgraded to. | */ -$config['migration_version'] = 18; +$config['migration_version'] = 19; /* 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 @@ +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"); + } +} -- cgit v1.2.3-24-g4f1b