-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
🐛 fkAction/fkOnDelete has no effect for automatically created migrations #458
Labels
Comments
wapmorgan
added
status:to be verified
Needs to be reproduced and validated.
type:bug
Bug
labels
Jan 23, 2024
wapmorgan
changed the title
🐛 fkAction/fkOnDelete has no effect
🐛 fkAction/fkOnDelete has no effect for automatically created migrations
Jan 23, 2024
Hi @wapmorgan I tried to reproduce your issue. I created test entities: use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\BelongsTo;
#[Entity(table: 'users')]
class User
{
#[Column(type: 'primary')]
public int $id;
#[BelongsTo(target: Voucher::class, nullable: true, fkAction: 'SET NULL')]
public ?Voucher $voucher = null;
} #[Entity(table: 'vouchers')]
class Voucher
{
#[Column(type: 'primary')]
public int $id;
#[Column(type: 'string')]
public string $title;
} After that, I created the users table and set the foreign key for voucher_id with on delete And then I ran the migration creation. As expected, the migration specifies 'SET NULL' for on delete and on update. Versionsphp:8.3.0
postgresql 12
cycle/annotated v4.1.0
cycle/database 2.9.0
cycle/migrations v4.2.3
cycle/orm v2.7.1
cycle/schema-builder v2.8.0
cycle/schema-migrations-generator 2.2.0
cycle/schema-renderer 1.2.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
No duplicates 🥲.
What happened?
Problem: When
fkAction
orfkOnDelete
is specified (has value that differs fromCASCADE
) for relation, it has not effect when creating a migration viacycle:migrate
.Example:
cycle:migrate
is called, I except change on update action toset null
.But It creates migration, that changes on delete action to
cascade
in up method - it's incorrect!In down method it correctly returns back all things (to current schema):
Version
The text was updated successfully, but these errors were encountered: