Default values for new columns in standard tables?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
canonknipser
Registered User
Posts: 1552
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Default values for new columns in standard tables?

Post by canonknipser » Tue Jan 23, 2018 3:33 pm

Following with interest the discussion over here: viewtopic.php?f=456&t=2383541&p=14918461#p14917491
It generates a question to the extension validators:
Shouldn't there be a rule to force extension developers to implement a default value (or NULL) when adding new columns to tables in the core, eg. topic, post, users-table in their migration files?
This would
  • set a correct default value when the migration is executed (esp. when using numeric fields)
  • Don't have other extension throw a "column xxx doesn't have a default value" error when adding data to those tables because they don't know about the other extension
  • Don't have the core throw a "column xxx doesn't have a default value" error when inserting data in case the extension is disabled, but data isn't deleted
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

User avatar
Ger
Recognised Extension Developer
Posts: 1592
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Default values for new columns in standard tables?

Post by Ger » Wed Jan 24, 2018 8:52 am

canonknipser wrote:
Tue Jan 23, 2018 3:33 pm
Shouldn't there be a rule to force extension developers to implement a default value (or NULL) when adding new columns to tables in the core, eg. topic, post, users-table in their migration files?
Well, either that or allow NULL values.

To summarize the discussion:linked to by canonknipser: the cmBB extension - like some other extensions - creates a topic in an automated way. When a board also has the Topic Description extension, it throws Column 'topic_desc' cannot be null [1048]
That is because the Topic Description extension adds a column to the topics table with NOT NULL option, but also without a default value.

Apart from this specific case, the discussion boils down to the point where the responsibility is: the extension that adds a column to a default phpBB table (extension A) or any other extension to provide compatibility to said extension A?

In my opinion, it's an endless road to add checks to each extension to make sure about any other installed extension that does something to default tables. I think it makes more sense that when altering a default table all behaviour to cope with that change should be covered by the extension altering it. So in this case the proposal of canonknipser seems sound, but it might be broader than that.

Edit:
RMcGirr83 wrote:
Tue Jan 23, 2018 10:58 am
Poke to notify you of this discussion in general (not specific to the topic description)
My extensions: Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update and Modern Quote
Newest: Quoted Where + anonymize

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 20 guests