删除迁移php文件后,迁移的SQL仍保留

发布于 2025-02-11 11:26:42 字数 902 浏览 2 评论 0原文

删除迁移php文件后,迁移的SQL仍保留。

运行迁移数据库后,我想删除此文件表单源代码,因为此逻辑不是必需的。但是,当我运行此命令以仔细检查将要执行的内容时。任何想法,请帮助。

 bin/console doctrine:schema:update --dump-sql

迁移的Alter表仍然剩下:

ALTER TABLE categories ALTER status SET NOT NULL

迁移文件php:

namespace Doctrine\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20220601122421 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE categories ALTER status SET NOT NULL');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE categories ALTER status DROP NOT NULL');
    }
}

The migrate sql still remaining after remove migrate php file.

After run migrate db I want to remove this file form source code because this logic is not necessary. But when I run this command to double check what will be execute. Any idea, please help.

 bin/console doctrine:schema:update --dump-sql

The migrate alter table still remaining:

ALTER TABLE categories ALTER status SET NOT NULL

Migration file php:

namespace Doctrine\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20220601122421 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE categories ALTER status SET NOT NULL');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE categories ALTER status DROP NOT NULL');
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪菊怪哟 2025-02-18 11:26:42

检查类别实体的映射。

学说:架构:更新比较您的数据库的外观(基于您实体的映射信息)与实际外观的外观,并执行将数据库架构更新为应其位置所需的SQL语句。

Check the mapping of your categories entity.

doctrine:schema:update compares what your database should look like (based on the mapping information of your entities) with how it actually looks, and executes the SQL statements needed to update the database schema to where it should be.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文