adjust news item entity and recreate migration

This commit is contained in:
Julie Lenaerts 2023-11-08 11:40:43 +01:00
parent 88447bbbf8
commit 003ca30c74
2 changed files with 25 additions and 11 deletions

View File

@ -57,6 +57,15 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
*/
private string $content = '';
/**
* @ORM\Column(type="string")
*
* @groups({"write", "read"})
*
* @Assert\NotNull
*/
private string $type = '';
/**
* @ORM\Column(type="date_immutable", nullable=false)
*/
@ -183,4 +192,16 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
{
return $this->id;
}
public function getType(): string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
}

View File

@ -2,32 +2,25 @@
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add news item entity.
* Create news item entity
*/
final class Version20231026091847 extends AbstractMigration
final class Version20231108103723 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add news item entity';
return 'Create news item entity';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE SEQUENCE chill_main_news_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_main_news (id INT NOT NULL, title TEXT NOT NULL, content TEXT NOT NULL, startDate DATE NOT NULL, endDate DATE DEFAULT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE chill_main_news (id INT NOT NULL, title TEXT NOT NULL, content TEXT NOT NULL, type VARCHAR(255) NOT NULL, startDate DATE NOT NULL, endDate DATE DEFAULT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_96922AFB3174800F ON chill_main_news (createdBy_id)');
$this->addSql('CREATE INDEX IDX_96922AFB65FF1AEC ON chill_main_news (updatedBy_id)');
$this->addSql('COMMENT ON COLUMN chill_main_news.startDate IS \'(DC2Type:date_immutable)\'');