I’d like to add a unique constraint to an existing table. The unique constraint spans two existing columns (event, player). How do I do that?
I’d like to add a unique constraint to an existing table. The unique constraint spans two existing columns (event, player). How do I do that?
Oh, it’s really easy. Just make an index and set the Unique Flag to 1:
$this->createIndex(
'idx-unique-teilnehmer-durchfuehrung-spieler',
'teilnehmer',
'durchfuehrung, spieler',
1
);
$this->createIndex(
'{{%idx-unique-user-firstname-lastname}}',
'{{%user}}',
['firstname', 'lastname'],
true
);