cycle / database

Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
MIT License
53 stars 22 forks source link

🐛 It seems that there is an issue with changing primary keys when you try to add sequenced type. #114

Closed tuneyourserver closed 1 year ago

tuneyourserver commented 1 year ago

No duplicates 🥲.

What happened?

I have the table:

class MyTable
{
    #[Column(type: 'uuid', name: 'uuid', primary: true)]
    private string $id;
}

When trying to add a new column to this table using the following migration command:

public function up(): void
{
    $this->database()->execute("ALTER TABLE my_table ADD COLUMN my_column SERIAL;")
}

I receive the following error when running "php ./app.php cycle:sync":

Detecting schema changes:
• my_db.my_table: 1 change(s) detected
[Cycle\Schema\Exception\SyncException]
Unable to change primary keys for existed table
in vendor/cycle/schema-builder/src/Generator/SyncTables.php:47

Previous: [Cycle\Database\Exception\DBALException]
Unable to change primary keys for existed table
in vendor/cycle/database/src/Driver/Handler.php:66

Also expression like #[Column(type: 'bigPrimary', name: 'm_index', primary: false)] not working too.

Thank you.

Version

ORM v2.2.2
PHP 8.1