Increase snippet content column size.
Created by: dblessing
This fixes issue #3904 (closed)
Before:
mysql> desc snippets;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(255) | YES | | NULL | |
| content | text | YES | | NULL | |
| author_id | int(11) | NO | | NULL | |
| project_id | int(11) | NO | MUL | NULL | |
| created_at | datetime | NO | MUL | NULL | |
| updated_at | datetime | NO | | NULL | |
| file_name | varchar(255) | YES | | NULL | |
| expires_at | datetime | YES | MUL | NULL | |
+------------+--------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)
mysql> SELECT MAX(LENGTH(content)) FROM snippets;
+----------------------+
| MAX(LENGTH(content)) |
+----------------------+
| 65535 |
+----------------------+
1 row in set (0.02 sec)
After:
mysql> desc snippets;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(255) | YES | | NULL | |
| content | longtext | YES | | NULL | |
| author_id | int(11) | NO | | NULL | |
| project_id | int(11) | NO | MUL | NULL | |
| created_at | datetime | YES | MUL | NULL | |
| updated_at | datetime | YES | | NULL | |
| file_name | varchar(255) | YES | | NULL | |
| expires_at | datetime | YES | MUL | NULL | |
+------------+--------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)
mysql> SELECT MAX(LENGTH(content)) FROM snippets;
+----------------------+
| MAX(LENGTH(content)) |
+----------------------+
| 279552 |
+----------------------+
1 row in set (0.00 sec)
You will see that the 'text' type was changed to 'longtext' now after implementing this change and running a db:migrate task. The 'SELECT MAX(LENGTH(content)) FROM snippets;' simply shows that I was able to successfully create a snippet with content length > 65,535 which was the previous limit.
I went with longtext (4294967295) because I didn't see a reason why not. Merge requests also support this limit.
Created by: dblessing
Yes the migration works in postgres also. There is no visual I can give you to show that anything changed. I found that 'text' datatype in postgres actually does not have a limit like MySQL does. The migrate command comes back clean with postgres db though. I found documentation on text type at http://www.postgresql.org/docs/8.0/interactive/datatype-character.html
== IncreaseSnippetTextColumnSize: migrating ================================== -- change_column(:snippets, :content, :text, {:limit=>4294967295}) -> 0.1713s == IncreaseSnippetTextColumnSize: migrated (0.1714s) =========================
By Administrator on 2013-06-13T12:13:38 (imported from GitLab project)
Created by: zzet
@randx limit work with https://github.com/gitlabhq/gitlabhq/blob/master/config/initializers/postgresql_limit_fix.rb
By Administrator on 2013-06-14T06:20:14 (imported from GitLab project)