Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Merge requests
  • !4282

Merged
Created 11 years ago by Administrator@rootOwner

Increase snippet content column size.

  • Overview 5
  • Commits 1
  • Changes 1

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.

Loading
Loading

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: MrKeiKun

    👍

    By Administrator on 2013-06-12T12:23:46 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dzaporozhets

    How about postgres? Does it proceed with this migration?

    By Administrator on 2013-06-13T07:17:47 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    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)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    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)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dzaporozhets

    ok thanks

    By Administrator on 2013-07-11T16:50:19 (imported from GitLab project)

  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
0 Assignees
Assign to
0 Reviewers
Request review from
Milestone
No milestone
None
None
Time tracking
0
Labels
None
Assign labels
  • No matching results
  • Manage project labels
Lock merge request
Unlocked
participants
Reference:
Source branch: github/fork/dblessing/3904

    0 pending comments