cycle / database

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

Schema diff fails when decimal column precision defined as positional arg #149

Closed shanginn closed 7 months ago

shanginn commented 7 months ago

No duplicates 🥲.

What happened?

In short, this works:

#[Column(
    type: 'decimal(8,2)',
)]
public string $amount;

And this

#[Column(
    type: 'decimal',
    precision: 8,
    scale: 2
)]
public string $amount;

produces an exception while trying to do a schema diff (php app.php cycle:migrate)

exception is:

php app.php cycle:migrate Detecting schema changes... [2023-12-17T05:30:27.458514+00:00] roadrunner.ERROR: Cycle\Schema\Exception\ColumnException: Invalid column type definition in 'public.invoices'.'amount' in /app/vendor/cycle/schema-builder/src/Table/Column.php at line 122 [] [] [Cycle\Schema\Exception\ColumnException] Invalid column type definition in 'public.invoices'.'amount' in vendor/cycle/schema-builder/src/Table/Column.php:122

Previous: [ArgumentCountError] Too few arguments to function Cycle\Database\Schema\AbstractColumn::decimal(), 0 passed and at least 1 expected in vendor/cycle/database/src/Schema/AbstractColumn.php:603

Version

PHP 8.3.0
spiral framework v3.10.1
cycle-bridge v2.8.0
orm v2.5.0