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

New: Migration Scripts (fixes #158) #159

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

New: Migration Scripts (fixes #158) #159

wants to merge 25 commits into from

Conversation

joe-replin
Copy link

New

Testing

Test using this branch of the Adapt Framework which includes the scripts that handle the migration.
adaptlearning/adapt_framework#3633

@joe-replin joe-replin self-assigned this Jan 15, 2025
describe('adapt-contrib-accordion - v1.0.0 > v2.0.0', async () => {
let accordions;

whereFromPlugin('adapt-contrib-accordion - from v1', { name: 'adapt-contrib-accordion', version: '<=2.0.0' });
Copy link
Contributor

Choose a reason for hiding this comment

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

@joe-replin should this be <2.0.0?

Copy link
Author

Choose a reason for hiding this comment

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

Interesting question. I'm migrating to v2.0.0 so I guess I'm migrating from everything from v1.0.0 and up. I'm guessing I shouldn't be attempting to migrate from below v2.0.0 and my migrations should start at the point in which I am migrating v2.0.0 > v2.0.4? Is that the consensus?

Copy link
Member

Choose a reason for hiding this comment

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

The describe block should not run if already at v2.0.0 hence < instead of <=

Copy link
Author

Choose a reason for hiding this comment

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

I agree. My question is whether we should include describe blocks for changes introduced in v2.0.0, or if we should start our migrations from the first version after v2.0.0. In this case, that would be v2.0.4.

Copy link
Member

Choose a reason for hiding this comment

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

Cool, I don't know. @joe-allen-89 any thoughts?

Copy link
Contributor

@chris-steele chris-steele Jan 31, 2025

Choose a reason for hiding this comment

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

The pattern I've followed in all my scripts so far is as follows.

If there is some v2.a.b to v2.c.d that has an attribute change then that will go in v2.js. So I'd say yes if there is some attribute change from v2.0.0 to v2.x.x then include it in v2.js.

On the other hand if an attribute change occurs between the last release of v2 and, say, v3 then I would put the migration in v3.js because the change happens when you move to v3.

Copy link
Contributor

@joe-allen-89 joe-allen-89 Jan 31, 2025

Choose a reason for hiding this comment

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

Not that I can see many people still on v1 versions but it's probably best we don't try and migrate anything lower than the first script.

I think the best course of action is to create a range rather than just use < for the first script to prevent migrating older versions, the two options would be:

whereFromPlugin('adapt-contrib-accordion - from v1', { name: 'adapt-contrib-accordion', version: '>=1.1.4 <2.0.0' });
or remove the describe for 2.0.0 and change the following whereFromPlugin to
whereFromPlugin('adapt-contrib-accordion - from v1', { name: 'adapt-contrib-accordion', version: '>=2.0.0 <2.0.4' });

As 1.1.4 doesn't have a FW version listed I'd be inclined to go for option 2.

Copy link
Author

Choose a reason for hiding this comment

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

So just to be clear, we shouldn't be supportting v1 FWs. If I went with your option 2, I would remove everything from this from from line 4 - line 108. And then we would start where the migration goes from v2.0.0 > v2.0.4.

migrations/v2.js Outdated
});

checkContent('adapt-contrib-accordion - check accordion._shouldCollapseItems atrribute', async () => {
const isValid = accordions.every(({ _classes }) => _classes !== undefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

copy and paste error - _classes should be _shouldCollapseItems

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

migrations/v5.js Outdated
mutateContent('adapt-contrib-accordion - update accordion._supportedLayout attribute to full-width', async () => {
accordions.forEach(accordion => {
/**
* ? Would this potentially break the layout of any course being migrated?
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say there's a good chance of that. half-width is still a valid layout. Perhaps only set if _supportedLayout does not have a valid value?

Copy link
Author

Choose a reason for hiding this comment

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

Done

migrations/v5.js Outdated
return true;
});

checkContent('adapt-contrib-accordion - check accordion._supportedLayout atrribute is now full-width', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The check should be that _supportedLayout is one of full-width, half-width or both

Copy link
Author

Choose a reason for hiding this comment

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

Appreciated.

migrations/v5.js Outdated
return true;
});

updatePlugin('adapt-contrib-accordion - update to v2.0.4', { name: 'adapt-contrib-accordion', version: '2.0.4', framework: '>=5' });
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs a version tweak

Copy link
Author

Choose a reason for hiding this comment

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

Done.

migrations/v7.js Outdated
@@ -0,0 +1,109 @@
import { describe, whereContent, whereFromPlugin, mutateContent, checkContent, updatePlugin } from 'adapt-migrations';

describe('adapt-contrib-accordion - v5.3.0 > v7.0.0', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

_imageAlignment came in v7.3.0 rather than v7.0.0

Copy link
Author

Choose a reason for hiding this comment

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

Thank you.

migrations/v7.js Outdated
/**
* * Add field to each item in a JSON array and set attribute.
*/
mutateContent('adapt-contrib-accordion - add accordion._items._imageAlignment', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This was done in the previous migration?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. I have deleted the duplicate.

Copy link
Contributor

@chris-steele chris-steele left a comment

Choose a reason for hiding this comment

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

Great start and very useful reference. Just added a few small pointers...

@joe-replin
Copy link
Author

@chris-steele, appreciate the early review. I am requesting another review from you and have officially turned this PR to 'Needs Reviewing'.

migrations/v2.js Outdated Show resolved Hide resolved
migrations/v2.js Outdated Show resolved Hide resolved
migrations/v2.js Outdated Show resolved Hide resolved
migrations/v2.js Outdated Show resolved Hide resolved
migrations/v2.js Outdated Show resolved Hide resolved
migrations/v2.js Outdated Show resolved Hide resolved
migrations/v4.js Outdated Show resolved Hide resolved
migrations/v5.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v7.js Outdated Show resolved Hide resolved
migrations/v2.js Outdated Show resolved Hide resolved
joe-replin and others added 13 commits January 30, 2025 11:13
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
Co-authored-by: joe-allen-89 <[email protected]>
@joe-replin
Copy link
Author

Thank you for the thorough review, @joe-allen-89. Looking to resolutions by @chris-steele and and answer to a question from @oliverfoster: #159 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Reviewing
Development

Successfully merging this pull request may close these issues.

Add Migration Scripts
4 participants