miałem istniejącej bazy danych PostgreSQL z tabeli utworzonej tak:Jak uniknąć instrukcji DROP DEFAULT przy użyciu Doctrine 2 Migrations podczas pierwszego uruchomienia?
CREATE TABLE product (id SERIAL PRIMARY KEY, name VARCHAR(100) DEFAULT NULL)
Tabela ta jest opisana w pliku yml Doctrine2 ramach projektu Symfony2:
Acme\DemoBundle\Entity\Product:
type: entity
table: product
fields:
id:
id: true
type: integer
nullable: false
generator:
strategy: SEQUENCE
name:
type: string
length: 100
nullable: true
Kiedy biegnę po raz pierwszy Zadanie diff Doctrine Migrations, powinienem otrzymać plik wersjonowania bez danych w metodach up
i down
. Ale zamiast tego otrzymuję:
// ...
class Version20120807125808 extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
$this->addSql("ALTER TABLE product ALTER id DROP DEFAULT");
}
public function down(Schema $schema)
{
// this down() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
$this->addSql("CREATE SEQUENCE product_id_seq");
$this->addSql("SELECT setval('product_id_seq', (SELECT MAX(id) FROM product))");
$this->addSql("ALTER TABLE product ALTER id SET DEFAULT nextval('product_id_seq')");
}
}
Dlaczego wykryto różnice? Jak mogę tego uniknąć? Wypróbowałem kilka strategii sekwencji bez powodzenia.
Dziękujemy za tak cenną odpowiedź! –
@VaheShadunts Nie ma za co! –