Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with doctrine diff #598

Closed
baiiko opened this issue Jan 29, 2018 · 7 comments
Closed

Problem with doctrine diff #598

baiiko opened this issue Jan 29, 2018 · 7 comments

Comments

@baiiko
Copy link

baiiko commented Jan 29, 2018

Hi,

When i use the doctrine diff, doctrine create a file with this line :

<?php declare(strict_types = 1);

namespace DoctrineMigrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20180129135625 extends AbstractMigration
{
    public function up(Schema $schema)
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

        $this->addSql('ALTER TABLE address CHANGE complement complement VARCHAR(255) DEFAULT NULL');
    }

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

        $this->addSql('ALTER TABLE address CHANGE complement complement VARCHAR(255) DEFAULT \'NULL\' COLLATE utf8_unicode_ci');
    }
}
@chrisguitarguy
Copy link
Contributor

@GuigZ- we'll need some more info about what you expected vs what happened.

But, in general, problems with the database diffing are bugs in doctrine/dbal not migrations.

@stof
Copy link
Member

stof commented Jan 29, 2018

This should be reported to doctrine/dbal, as it is the project implementing the schema diffing (the migrations project rely on the schema diffing tools of DBAL).

Btw, when reporting it to DBAL, please provide more information about your schema and about the platform you are using.

@baiiko
Copy link
Author

baiiko commented Jan 29, 2018

I use Symfony 4, with php 7 and MariaDB from latest version.

My mapping is

App\Entity\Address:
  type: entity
  repositoryClass: App\Repository\AddressRepository
  indexes:
    uuid_index:
      columns: [ uuid ]
  id:
    id:
      type: integer
      generator: {strategy: AUTO}
  fields:
    uuid:
      type: uuid
      unique: true
    name:
      type: string
      length: 100
    address:
      type: string
      length: 255
    complement:
      type: string
      nullable: true
      length: 255
    postcode:
      type: string
      length: 100
    city:
      type: string
      length: 100
    deleted:
      type: boolean
    createdAt:
      type: datetime
      gedmo:
        timestampable:
          on: create
    updatedAt:
      type: datetime
      gedmo:
        timestampable:
          on: update

I go on dbal to open an issue :)

@Nek-
Copy link

Nek- commented Jan 29, 2018

looks related to doctrine/orm#6845

@malukenho
Copy link

malukenho commented Jan 29, 2018

@GuigZ- did you checked your current database/tables state? Because doctrine will try to do a diff comparing the entity metadata and the current state of the database.

@baiiko
Copy link
Author

baiiko commented Jan 30, 2018

Hi, when i use very verbose on my command, doctrine create this request :

CREATE TABLE address (
id INT AUTO_INCREMENT NOT NULL, 
uuid CHAR(36) NOT NULL COMMENT '(DC2Type:uuid)', 
name VARCHAR(100) NOT NULL, 
address VARCHAR(255) NOT NULL, 
complement VARCHAR(255) DEFAULT NULL, 
postcode VARCHAR(100) NOT NULL, 
city VARCHAR(100) NOT NULL, 
deleted TINYINT(1) NOT NULL, 
created_at DATETIME NOT NULL, 
updated_at DATETIME NOT NULL, 
UNIQUE INDEX UNIQ_D4E6F81D17F50A6 (uuid),
 INDEX uuid_index (uuid), 
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB

When i use PMA to export my table :

DROP TABLE IF EXISTS `address`;
CREATE TABLE IF NOT EXISTS `address` (
`id` int(11) NOT NULL,
  `uuid` char(36) COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:uuid)',
  `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `address` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `complement` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `postcode` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `city` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `deleted` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

So the problem is not on my server i think...

@baiiko
Copy link
Author

baiiko commented Jan 30, 2018

I open the new issue here : doctrine/dbal#3006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants