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

All migrations are created with altering sessions table #75

Open
vv12131415 opened this issue Jul 8, 2018 · 1 comment
Open

All migrations are created with altering sessions table #75

vv12131415 opened this issue Jul 8, 2018 · 1 comment

Comments

@vv12131415
Copy link

Bug Report

Q A
BC Break no
laravel-doctrine/migrations version 1.1.10
Laravel Framework version 5.6.25
php version 7.2.7-1
MySQL version 5.7.22

Summary

When running artisan doctrine:migrations:diff it's always creates migration that contains changes to sessions table.

Current behavior

Running artisan doctrine:migrations:diff creates migration that contains SQL code below

The up addSql will look like

ALTER TABLE sessions CHANGE id id VARCHAR(255) NOT NULL

The down addSql will look like

ALTER TABLE sessions CHANGE id id VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci

How to reproduce

  • create new laravel app
  • add SESSION_DRIVER=database to .env
  • run artisan session:table
  • run artisan migrations:migrate
  • make basic configurations to laravel-doctrine (use xml mappings)
  • run artisan doctrine:mapping:import --namespace=Your\\Namespace\\ xml Your/Mappings/Folder
  • run artisan doctrine:migrations:diff. It will create migration with session table changes.

My current xml for sessions table is

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <entity
          name="Foo\Bar\Session"
          table="sessions"
          repository-class="Foo\Bar\SessionRepository"
  >
    <unique-constraints>
      <unique-constraint name="sessions_id_unique" columns="id"/>
    </unique-constraints>
    <id name="id" type="string" column="id" length="255">
      <generator strategy="IDENTITY"/>
    </id>
    <field name="ipAddress" type="string" column="ip_address" length="45" nullable="true">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="userAgent" type="text" column="user_agent" length="65535" nullable="true">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="payload" type="text" column="payload" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="lastActivity" type="integer" column="last_activity" nullable="false">
      <options>
        <option name="unsigned"/>
      </options>
    </field>
    <many-to-one field="user" target-entity="App\Doctrine\Entity\User"  inversed-by="sessions" fetch="LAZY">
      <join-columns>
        <join-column name="user_id" referenced-column-name="id"/>
      </join-columns>
    </many-to-one>
  </entity>
</doctrine-mapping>

My doctrine.php (showing only changes because it's almost similar) is

'managers'                   => [
        'default' => [
            'dev'           => env('APP_DEBUG', false),
            'meta'          => env('DOCTRINE_METADATA', 'xml'),
            'connection'    => env('DB_CONNECTION', 'mysql'),
            'namespaces'    => [],
            'paths'         => [
                base_path('Your/Mappings/Folder')
            ],
        ]
    ],

Expected behavior

Running artisan doctrine:migrations:diff gives error with message No changes detected in your mapping information. Like on screenshot
image

@patrickbrouwers
Copy link
Contributor

Perhaps it's better to ask this at doctrine/migrations? I'm not sure what's causing it

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

2 participants