How to Update Extensions Table?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 3621
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

How to Update Extensions Table?

Post by HiFiKabin » Mon Jan 14, 2019 12:39 pm

I know I am probably missing the obvious, but having created a database table in the extensions initial install how do I later add another column to it with a migration update file? I have tried all that I can think of, and can not find an existing extension that I can 'crib' from.

My existing migration file includes this

Code: Select all

	public function update_schema()
	{
		return array(
			'add_tables'	=> array(
			// ADD NEW TABLE STRUCTURE
				$this->table_prefix . 'randombanner'	=> array(
					'COLUMNS' => array(
					'randombanner_id'			=> array('UINT', null, 'auto_increment'),
					'randombanner_image'		=> array('VCHAR', ''),
					'randombanner_url'			=> array('VCHAR', ''),
					),
					'PRIMARY_KEY'	=> 'randombanner_id',
				),
			),
		);
	}
and I want to add

Code: Select all

					'randombanner_target'		=> array('UINT', '0')
As its not yet validated I could of course just re write the migration file, but there are some 80 people using the extension and I don't want to cause them any problems if I can avoid it.

TiA

User avatar
david63
Jr. Extension Validator
Posts: 15583
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: How to Update Extensions Table?

Post by david63 » Mon Jan 14, 2019 12:44 pm

This should do it - don't forget to check that the original is installed

Code: Select all

public function update_schema()
	{
		return array(
			'add_columns'	=> array(
				$this->table_prefix . 'randombanner'	=> array(
					'randombanner_target'	=> array('UINT', '0'),
				),
			),
		);
	}
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
mrgoldy
Jr. Extension Validator
Posts: 891
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: How to Update Extensions Table?

Post by mrgoldy » Mon Jan 14, 2019 1:01 pm

Just to add to what david means, is the public function depends_on() (and possibly even public function effectively_installed()).
Also, and this is a guess, you can probably use something else than UINT, which will allow numbers from 0 to 16,777,215. While I think you're more after a number between 0 and probably something like 10. So you could probably use something like TINT:%d or USINT.
For more about Database Type Map see here: https://wiki.phpbb.com/Database_Type_Map
Formerly known as posey.
''Proud member of the Studio"

User avatar
canonknipser
Registered User
Posts: 1832
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: How to Update Extensions Table?

Post by canonknipser » Mon Jan 14, 2019 1:09 pm

And a additional addition to what david and mrgoldy already explained: There are also some nice tutorials on area 51
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
HiFiKabin
Community Team Member
Community Team Member
Posts: 3621
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: How to Update Extensions Table?

Post by HiFiKabin » Mon Jan 14, 2019 1:33 pm

david63 wrote:
Mon Jan 14, 2019 12:44 pm
This should do it - don't forget to check that the original is installed
<snip>
Perfect, thanks David (and Gijs and Frank. Lots more reading for me there)

User avatar
</Solidjeuh>
Registered User
Posts: 1319
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: How to Update Extensions Table?

Post by </Solidjeuh> » Mon Jan 14, 2019 2:11 pm

HiFiKabin wrote:
Mon Jan 14, 2019 12:39 pm
but there are some 80 people using the extension and I don't want to cause them any problems if I can avoid it.
We know the risks of using RC versions, so it's on us! :D We can also just simple delete data, and start over again. It's not that much, just adding url's and all is good again.
We offer fun HTML5 games for young and old.
Register a free account & enjoy all functions!
Save your score, challenge other members or play along with our tournaments.


~~~ https://www.solidjeuh.be ~~~

Image

User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 3621
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: How to Update Extensions Table?

Post by HiFiKabin » Mon Jan 14, 2019 2:16 pm

Thanks Andy. Just me trying to be kind to everyone (although you will have a bit more translation to do :lol: )

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 9 guests