WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#4778 closed defect (bug) (fixed)

Change enums to varchar

Reported by: ryan Owned by:
Milestone: 2.5 Priority: high
Severity: normal Version: 2.3
Component: Administration Keywords: schema enum db early
Focuses: Cc:

Description

Drop enums from the schema in favor of the more portable and flexible varchar. I think we can just change all occurrences of enum in schema.php to varchar(20). This will allow plugins to add new post status values, for example, without having to do an alter table to change the enum.

Attachments (1)

enum_to_varchar.diff (2.4 KB) - added by ryan 8 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 @westi8 years ago

+1

This is a really good idea.

comment:2 @Otto428 years ago

-1

This is a really bad idea. The whole point of using an enum is to have a fixed set of values that are valid ones. They are stored as integers internally and make things somewhat speedier, since WordPress selects posts based on post_status more or less constantly. Changing it to a varchar would create a not-insignificant performance loss.

If a plugin is making such a radical change as to require its own special post_status values, then it should be able to take the time to alter the table to allow that status.

comment:3 @ryan8 years ago

Another motivator is to make our SQL more portable. enums aren't.

comment:4 @matt8 years ago

+1 been meaning to do this for years.

comment:5 @foolswisdom8 years ago

  • Milestone changed from 2.3 to 2.4 (next)
  • Priority changed from normal to high

comment:6 @foolswisdom8 years ago

Mark and Ryan have decided to postpone this until 2.4, I have marked the priority is high so hopefully it can be done early in 2.4s cycle.

comment:7 @westi8 years ago

  • Keywords early added

@ryan8 years ago

comment:8 @ryan8 years ago

Change all enums to varchar(20)

comment:9 @ryan8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [6732]) Enum to varchar. fixes #4778

Note: See TracTickets for help on using tickets.