-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
ERROR: index "primary" does not exist #6271
Comments
This information is not sufficient to provide any help on our side. You'll have to debug further, maybe with a trace and dumping the schema diff object. Closing as |
Dug a little deeper into the issue. I may actually attempt to fix it. Seems like any time a primary key is changed (standard sequence, auto-increment to/from guid) it has an issue fetching the tables metadata (primary keys/index name). I'm going take a stab at this on my own and see if I can come up with the fix |
@Ocramius this is definitely a legit bug. It has seemed intermittent for me but I can reproduce it using postgres and a composite key.
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class Test
{
/**
* @ORM\Column(type="integer")
* @ORM\Id()
*/
protected $id;
/**
* @ORM\Column(type="integer")
* @ORM\Id()
*/
protected $test;
}
|
@johnpancoast can you put this in a test case? I think this might be a DBAL issue though. |
@Ocramius sure. |
Just came across this as well, postgresql trying to remove a composite key and replace it with a single id column because i needed to add a WHERE conditional to the composite key |
@plimpton try making a test case and a new PR with just the failing scenario, if you can |
I can reproduce this problem too. <?php
// bootstrap.php
require_once "vendor/autoload.php";
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$isDevMode = true;
$paths = array(__DIR__.'/entity');
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false);
$dbParams = array(
'driver' => 'pdo_pgsql',
'user' => 'doctrine_test',
'password' => 'doctrine_test',
'dbname' => 'doctrine_test',
'host' => 'localhost',
'charset' => 'UTF8',
);
$entityManager = EntityManager::create($dbParams, $config); <?php
// cli-config.php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
require_once 'bootstrap.php';
return ConsoleRunner::createHelperSet($entityManager); <?php
// entity/user.php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class User
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*/
private $sapid;
} # composer.json
{
"name": "john/doctrine_test",
"require": {
"doctrine/orm": "*"
}
} (create postgresql user and database, see dbParams)
(rename primary key sapid to something else)
|
I have the same bug using Doctrine + Oracle when I'm changing a composite key. |
@Ocramius, could you please re-open this issue? |
As asked already twice, a test case is needed. The above are examples. |
Apologies for not getting to writing this test case, but I have no time at the moment due to other projects (typical story, I know). It's easily re-produceable using those steps iirc. That's the most I can offer at the moment, unfortunately. |
I think this is being resolved in doctrine/dbal#2929 |
Any update on this? I'm struggling with this problem. |
Hello, I had the same problem; I just drop manually the of the entity (database table) you need to change indexes (for example DROP INDEX actual_pk) and then re-run your doctrine update or query. |
Most probably related to doctrine/dbal#3936 |
Eh, example would be fresh install of a Symfony project using Postgres. Nothing special needs to be done. It just happens out of the box. Don't even need to drop any indexes. Just make an entity change, generate a migration and there it goes. |
doctrine/dbal#3936 is solving the issue (builds were green and tests oo), but is rather a big change and probably should be split in 2 or 3 different pull request. |
The problem is still present (2.14.1). Is there any way to solve it? |
@f-lombardo, maybe check out @tlorens' workaround above. Until one of us writes a simple test case, the contributors cannot do much. I was super busy when I wrote this and didn't have time to go through doctrine's merge standards and all that at the time. I can't commit time for certain (I'm an awful human) but I'll try to do it unless somebody beats me to it. The test itself should be easy, and can likely just do something similar to this (just my assumption). Once that's written contributors can dig in. |
Thank you @johnpancoast , see doctrine/dbal#6025 |
Glad I could help... well, at least like .5% like 5 years ago :) |
Fixed: |
Cannot for the life of me find where this
DROP INDEX "primary";
is coming from. If I execute each query statement generated from the output of "doctrine:schema:update" everything goes just fine. Symfony 3.2 / Postgres 9.6.1 / Doctrine 2.5 (bundle 1.6)I've searched my code and there's not a single instance of declaring any indexes named primary.
The text was updated successfully, but these errors were encountered: