You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then I do php bin/console doctrine:migrations:diff.
The result is
<?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 Version20230206151152 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 "pages" (id UUID NOT NULL, title VARCHAR(255) NOT NULL, content VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN "pages".id IS \'(DC2Type:uuid)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP TABLE "pages"');
}
}
No foreign key or anything for parent is created.
The text was updated successfully, but these errors were encountered:
You imported the namespace as an ORM prefix in your use statement but you haven't use ORM\OneToOne or a use statement for the OneToOne attribute. So your OneToOne attribute is currently a App\Entity\OneToOne, which is not known by Doctrine (and probably does not exist).
@stof You are right, but then I would expect an error message that App\Entity\OneToOne was not found.
But I just get
Generated new migration class to "/var/www/html/migrations/Version20230207113436.php"
To run just this migration for testing purposes, you can use migrations:execute --up 'DoctrineMigrations\\Version20230207113436'
To revert the migration you can use migrations:execute --down 'DoctrineMigrations\\Version20230207113436'
I suggest to let throw an error if a specified attribute class was not found.
PHP allows attribute to use non-existent classes as long as you don't try to instantiate them.
And doctrine/orm won't try to instantiate attributes that are not its own.
However, static analysis tools like Psalm and phpstan (or your IDE) generally report non-existent classes used as attribute as being a mistake.
"doctrine/doctrine-migrations-bundle": "^3.2"
According to https://www.doctrine-project.org/projects/doctrine-orm/en/2.14/reference/association-mapping.html#one-to-one-self-referencing
there is an example
When I test this in my new entity
Then I do
php bin/console doctrine:migrations:diff
.The result is
No foreign key or anything for
parent
is created.The text was updated successfully, but these errors were encountered: