I'm halfway through the tutorial but unable to progress as I keep getting the following error:
[User Error] Couldn't run query: ALTER TABLE "Region" ADD "PhotoID" int(11) not null default 0, ADD index "PhotoID" ("PhotoID") Duplicate column name 'PhotoID'
GET /example3/dev/build?flush=&=f4889263f3dbd503cfdc1090ca898ae4
Line 598 in /Applications/mampstack-5.4.34-0/apache2/htdocs/example3/framework/model/MySQLDatabase.php
Regions page currently has its two empty class definitions:
<?php
class RegionsPage extends Page {
}
class RegionsPage_Controller extends Page_Controller {
}
…so I assume the problem is with Region.php
<?php
class Region extends DataObject {
private static $db = array (
'Title' => 'Varchar',
'Description' => 'Text',
);
private static $has_one = array (
'Photo' => 'Image',
'RegionsPage' => 'RegionsPage'
);
public function getCMSFields() {
$fields = FieldList::create(
TextField::create('Title'),
TextareaField::create('Description'),
$uploader = UploadField::create('Photo')
);
$uploader->setFolderName('region-photos');
$uploader->getValidator()->setAllowedExtensions(array('gif','png','jpg','jpeg'));
return $fields;
}
}
…but I can't see any obvious errors and I'm having trouble understanding the debug message. Could someone give me a hand please? Is the problem in plain sight? I've been stuck on this for hours and it's driving me mad!