Composite index in database migration?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
martti
Registered User
Posts: 682
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Composite index in database migration?

Post by martti » Tue Jun 12, 2018 3:15 pm

The question is in the title. How do we add a composite index in a database migration?

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

Re: Composite index in database migration?

Post by canonknipser » Tue Jun 12, 2018 3:34 pm

As a example check the core migrations, eg. phpbb/db/migration/data/v31x/add_latest_topics_index.php:

Code: Select all

	public function update_schema()
	{
		return array(
			'add_index' => array(
				$this->table_prefix . 'topics' => array(
					'latest_topics'	=> array(
						'forum_id',
						'topic_last_post_time',
						'topic_last_post_id',
						'topic_moved_id',
					),
				),
			),
		);
	}
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
martti
Registered User
Posts: 682
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: Composite index in database migration?

Post by martti » Tue Jun 12, 2018 5:13 pm

Thanks!

User avatar
3Di
Registered User
Posts: 12992
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Composite index in database migration?

Post by 3Di » Sun Jun 17, 2018 4:03 pm

martti wrote:
Tue Jun 12, 2018 3:15 pm
The question is in the title. How do we add a composite index in a database migration?
To add to the above, a check for the existance of it it's always a good thing to do.
https://github.com/3D-I/tpotm/blob/7969 ... hp#L19-L23

For more infos about Database Tools for handling cross-db actions such as altering columns, etc.:
https://github.com/phpbb/phpbb/blob/3.2 ... erface.php

Ref.: https://github.com/phpbb/phpbb/blob/3.2 ... /tools.php
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests