Fixed sponsor FK
Change-Id: I0224320f973ba9a28dd7936a8aa871c7d918c892 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
e78ec90be7
commit
c64e6faa92
@ -42,14 +42,14 @@ class Sponsor extends SilverstripeBaseModel implements IOrderable
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Company")
|
||||
* @ORM\JoinColumn(name="CompanyID", referencedColumnName="ID")
|
||||
* @ORM\JoinColumn(name="CompanyID", referencedColumnName="ID", onDelete="SET NULL")
|
||||
* @var Company
|
||||
*/
|
||||
protected $company;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="SponsorshipType")
|
||||
* @ORM\JoinColumn(name="SponsorshipTypeID", referencedColumnName="ID")
|
||||
* @ORM\JoinColumn(name="SponsorshipTypeID", referencedColumnName="ID", onDelete="SET NULL")
|
||||
* @var SponsorshipType
|
||||
*/
|
||||
protected $sponsorship;
|
||||
|
60
database/migrations/model/Version20201029175540.php
Normal file
60
database/migrations/model/Version20201029175540.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
|
||||
class Version20201029175540 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
ALTER TABLE `SummitSponsorMetric` CHANGE `ClassName` `ClassName` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'SummitSponsorMetric';
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
$sql = <<<SQL
|
||||
UPDATE Sponsor SET CompanyID = NULL
|
||||
WHERE NOT EXISTS (SELECT ID FROM Company WHERE Company.ID = Sponsor.CompanyID);
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
$sql = <<<SQL
|
||||
ALTER TABLE Sponsor ADD CONSTRAINT FK_SponsorCompany FOREIGN KEY (CompanyID) REFERENCES Company (ID) ON DELETE SET NULL;
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
$sql = <<<SQL
|
||||
UPDATE Sponsor SET SponsorshipTypeID = NULL
|
||||
WHERE NOT EXISTS (SELECT ID FROM SponsorshipType WHERE SponsorshipType.ID = Sponsor.SponsorshipTypeID);
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
$sql = <<<SQL
|
||||
ALTER TABLE Sponsor ADD CONSTRAINT FK_SponsorSponsorshipType FOREIGN KEY (SponsorshipTypeID) REFERENCES SponsorshipType (ID) ON DELETE SET NULL;
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user