Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Add absolute path to Spiral/Database/Injection/Fragment in alterColumn function #8

Open
mrakolice opened this issue Jan 14, 2020 · 21 comments
Assignees

Comments

@mrakolice
Copy link

image

Without leading slash composer try to find this class in Migration namespace instead of global.

@mrakolice
Copy link
Author

I found monkey patching solution for this particular usecase, spiral/reactor/src/Serializer#117-119 need to be rewrite as

 if (is_object($value)) {
            return '\\' . var_export($value, true);
}

@mrakolice
Copy link
Author

Or just add __set_state function to Spiral/Database/Injection/Fragment class

@wolfy-j wolfy-j self-assigned this Jan 14, 2020
@wolfy-j
Copy link
Member

wolfy-j commented Jan 14, 2020

Thank you for the report. Will be fixed today.

@wolfy-j
Copy link
Member

wolfy-j commented Jan 14, 2020

Please check the v2.7.1 version of spiral/database. Let me know if you still need the Reactor change.

@wolfy-j wolfy-j closed this as completed Jan 14, 2020
@mrakolice
Copy link
Author

mrakolice commented Jan 17, 2020

This problem is still in project. So I think, that Reactor need to change a little bit.

@wolfy-j wolfy-j reopened this Jan 17, 2020
@wolfy-j
Copy link
Member

wolfy-j commented Jan 17, 2020

I would greatly appreciate your PR to Reactor. If not I’ll check next week.

@vvval
Copy link
Contributor

vvval commented Jan 17, 2020

At least it would be great to have a failing test

@mrakolice
Copy link
Author

mrakolice commented Jan 20, 2020

Here example of failing entities.

https://github.com/mrakolice/migrations/tree/error-with-spiral-reactor

my composer.lock:

cycle/orm v1.1.18
spiral/database v2.6.10
spiral/reactor v2.2.2

@mrakolice
Copy link
Author

mrakolice commented Jan 20, 2020

If I try to do

if (is_object($value) && method_exists($value, '__set_state')) {
            return '\\' . var_export($value, true);
}

in spiral/reactor/Serializer.php, then function BaseTest->assertSameAsInDb start working unexpectedly

image

But in database I can see changes (column type change from integer to bigint)

@vvval
Copy link
Contributor

vvval commented Jan 20, 2020

@wolfy-j I assume that the second error in tests is related directly to the migrations package

@vvval
Copy link
Contributor

vvval commented Jan 20, 2020

The reactor has been fixed in the v2.2.3 release

@mrakolice
Copy link
Author

The reactor has been fixed in the v2.2.3 release

Thanks! I am waiting for migrations package fix.

@vvval
Copy link
Contributor

vvval commented Jan 20, 2020

@mrakolice I've added your breaking input as a PR to the cycle/migrations itself

@vvval
Copy link
Contributor

vvval commented Jan 20, 2020

By the way, what is the purpose of changing PK column type? Also, I assume that the correct alter change should contain also primary=true annotation attribute

@mrakolice
Copy link
Author

@vvval yeah, you absolutely right about primary=true, but this solution works only with fresh database, created with CodeFirst. This problem (with sequences) starts when you try to migrate from existing schema, in my case created by another orm(eloquent).

I think, this problem will be exist when altering fields with other sequences, rather than PK, but I don't testing it.

@wolfy-j
Copy link
Member

wolfy-j commented Jan 21, 2020

Val, can you check the default value of that column and see what needs to be written into Column in order to keep the type persistent.

@wolfy-j
Copy link
Member

wolfy-j commented Jan 21, 2020

Would readonly schema help in this case?

@vvval
Copy link
Contributor

vvval commented Jan 24, 2020

@mrakolice see above please

@mrakolice
Copy link
Author

What should I do? Make database schema (in rdbms) readonly or what?

@wolfy-j
Copy link
Member

wolfy-j commented Jan 28, 2020

Check readonlySchema annotation, it won’t generate migration for your table: https://cycle-orm.dev/docs/annotated-entity

@mrakolice
Copy link
Author

This is not my solution, unfortunately.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants