Skip to content
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

initial snapshot does not define collation info #645

Closed
wants to merge 38 commits into from
Closed

initial snapshot does not define collation info #645

wants to merge 38 commits into from

Conversation

rrd108
Copy link
Contributor

@rrd108 rrd108 commented Oct 3, 2023

This PR is intended to fix cakephp/phinx#2225

The added test case passes, so it seems to be fine for me.

However, thi is not a final version as I was not sure about 2 things.

Question 1

The current solution actually execute the migration_snapshot command and creates and writes a new migration file. My guess is that I could do it without creating the file, but I did not find out how.

Question 2

The current test alters the articles table's title field's collation. So I guess I have to alter it back to avoid affecting other tests. Do I have to do it, or the test system will drop the table after each tests?

@rrd108
Copy link
Contributor Author

rrd108 commented Oct 3, 2023

I see, I have to handle the case when the collation is the default. I will get back to it in a few days.

@ndm2
Copy link
Contributor

ndm2 commented Oct 3, 2023

Please compare against the full snapshot like the other snapshot tests do, ideally use runSnapshotTest(), see for example the testSnapshotWithAutoIdCompatibleSignedPrimaryKeys() test.

The comparison file would be tests/comparisons/Migration/test_snapshot_with_non_default_collation.php. And then also please register that comparison file with MigrationsTest::migrationsProvider(), that way it will be tested whether the generated snapshot can be applied without errors.

As can be seen from the failing tests, this would affect diffs too, so encoding defaults and changes would need to be properly tested there too.

Might sound a bit pedantic, but when my recent work on Migrations taught me anything, then that its sloppy testing is one of its worst enemies, and a major source of pain when making changes.

@rrd108
Copy link
Contributor Author

rrd108 commented Oct 5, 2023

I still have to fix what @ndm2 suggested.

@rrd108 rrd108 marked this pull request as draft October 5, 2023 16:33
@rrd108 rrd108 marked this pull request as ready for review October 6, 2023 11:36
@markstory markstory added this to the 3.x (CakePHP 4) milestone Oct 8, 2023
@rrd108
Copy link
Contributor Author

rrd108 commented Oct 10, 2023

Do I have to do anything more on this?

Copy link
Contributor

@LordSimal LordSimal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ndm2 ndm2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add the new snapshot to \Migrations\Test\TestCase\MigrationsTest::migrationsProvider().

@ndm2
Copy link
Contributor

ndm2 commented Oct 10, 2023

So I just realized that \Migrations\Test\TestCase\MigrationsTest::testMigrateSnapshots() is actually still broken and not testing properly. That would also affect this snapshot right here, which as a foreign key for a non-existent table.

I'll try to get that fixed somewhat quickly.

@rrd108
Copy link
Contributor Author

rrd108 commented Oct 11, 2023

Please also add the new snapshot to \Migrations\Test\TestCase\MigrationsTest::migrationsProvider().

added in 9052c29

ndm2 and others added 4 commits October 12, 2023 17:51
Only the first snapshot was being tested, as subsequent calls to
`migrate()` will not re-read the migration files from disk, but use
cached instances from the first call.
4.x - Fix snapshot migration tests.
@rrd108
Copy link
Contributor Author

rrd108 commented Nov 2, 2023

@ndm2 As I see tha failing tests coming from other test, not related to this one.

@ndm2
Copy link
Contributor

ndm2 commented Nov 2, 2023

I'm note sure what exactly you did, but it looks like rebasing somehow went wrong, all the changes here from existing commits should not be seen as new. The test failures might be a result of that.

@rrd108
Copy link
Contributor Author

rrd108 commented Nov 2, 2023

I'm note sure what exactly you did, but it looks like rebasing somehow went wrong, all the changes here from existing commits should not be seen as new. The test failures might be a result of that.

I do not know what did I do wrong.

Anyway I would need some suggestion how to move forward.

I cloned cakephp/migrations to my dev machine and executed vendor/bin/phpunit tests without any changes and I get Tests: 122, Assertions: 396, Errors: 8, Warnings: 1, Skipped: 10

So it seems that is the starting point for now.

Re-adding my changes to this newly cloned repo does not change the number of errors, so I guess my additions are ok, but the checks will certainly fail.

@rrd108
Copy link
Contributor Author

rrd108 commented Nov 2, 2023

anyway it seems no error on the pipeline.

@dereuromark
Copy link
Member

I wonder if this could be squash merged
But it would be safer to squash and rebase Prior to merging

@rrd108 rrd108 closed this by deleting the head repository Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

initial snapshot does not define collation info
6 participants