提交 e9cc6744 编写于 作者: T teebbstudios

postImage and make migration

上级 f4d19866
......@@ -3,7 +3,7 @@
<component name="ChangeListManager">
<list default="true" id="17d8167b-fad0-4299-92ba-cd29175aa02c" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tests/PostFactoryTest.php" beforeDir="false" afterPath="$PROJECT_DIR$/tests/PostFactoryTest.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/Post.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/Post.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -158,7 +158,7 @@
<updated>1624256528785</updated>
<workItem from="1624256531936" duration="6242000" />
<workItem from="1624275706243" duration="12749000" />
<workItem from="1624356371515" duration="18640000" />
<workItem from="1624356371515" duration="19838000" />
</task>
<servers />
</component>
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210624090831 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE comment (id INT AUTO_INCREMENT NOT NULL, post_id INT NOT NULL, author VARCHAR(30) NOT NULL, email VARCHAR(255) NOT NULL, message LONGTEXT DEFAULT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_9474526C4B89032C (post_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE post (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, summary LONGTEXT DEFAULT NULL, body LONGTEXT DEFAULT NULL, status VARCHAR(20) DEFAULT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, post_image VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C4B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C4B89032C');
$this->addSql('DROP TABLE comment');
$this->addSql('DROP TABLE post');
}
}
......@@ -54,6 +54,11 @@ class Post
*/
private $comments;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $postImage;
public function __construct()
{
$this->comments = new ArrayCollection();
......@@ -166,4 +171,16 @@ class Post
return $this;
}
public function getPostImage(): ?string
{
return $this->postImage;
}
public function setPostImage(?string $postImage): self
{
$this->postImage = $postImage;
return $this;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册