Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

symfony - 教义迁移不尊重实体(Doctrine migration is not respecting entity)

I made a new entity in symfony

(我在symfony中建立了一个新实体)

...
class MenuDay
{
    /**
     * @ORMId()
     * @ORMGeneratedValue()
     * @ORMColumn(type="integer")
     */
    private $id;

    /**
     * @ORMColumn(type="string", length=255, nullable=true)
     */
    private $name;

    /**
     * @ORMManyToOne(targetEntity="AppEntityMenuWeek", inversedBy="menuDays")
     */
    private $menuWeek;
...

and when i try to make:migration it only generate table with no column

(当我尝试make:migration时,它只生成没有列的表)

...
public function up(Schema $schema) : void
{
    // this up() migration is auto-generated, please modify it to your needs
    $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'sqlite', 'Migration can only be executed safely on 'sqlite'.');

    $this->addSql('CREATE TABLE menu_day (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)');
}
...

it looks like error, but i don't know what I'm doing wrong.

(它看起来像错误,但我不知道我在做什么错。)

Also I want to avoid manually hardcode those new columns into migration file.

(我也想避免手动将这些新列硬编码到迁移文件中。)

It is my first project with this type of error.

(这是我的第一个此类错误项目。)

If you need some additional information, I'll edit this post.

(如果您需要其他信息,我将对此帖子进行编辑。)

I'm bit in panic mode.

(我有点慌乱。)

Please help me, you are my only hope.

(请帮助我,您是我唯一的希望。)

:) Thank you!

(:) 谢谢!)

  ask by Lucius Nagata translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...