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

cleanup hrefs from external levels #13382

Merged
merged 2 commits into from Feb 22, 2017
Merged

cleanup hrefs from external levels #13382

merged 2 commits into from Feb 22, 2017

Conversation

Bjvanminnen
Copy link
Contributor

Support for hrefs in External levels was removed a while ago (https://github.com/code-dot-org/code-dot-org/pull/3762/files).

However, when creating a new external level, you're still provided with href 'path/to/html/in/asset/folder'

This PR

  • Removes suggestion of href for new external levels
  • Removes support for href from DSL
  • Adds a migration that clears the href from existing External levels

All of our existing external levels have either nil or 'path/to/html/in/asset/folder' as their href. There is one exception that tries to point to curriculum builder, that I assume was JoshC figuring out if that worked (and isn't referenced in any scripts). I'll also check in with him on that level.

class RemoveHrefFromExternal < ActiveRecord::Migration[5.0]
def up
External.all.each{|level| level.update!(properties: level.properties.except('href'))}
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this make the migration irreversible? If so, worth including a no-op down migration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is irreversible.

Is the noop down migration just to make it explicit that this is the case? What would happen if I were to run migrate:down without a noop down migration? (I would have guessed it would be the same behavior)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry, I meant we want to be able to run the migration both ways even though we're only modifying data in the up migration.

Some migrations raise ActiveRecord::IrreversibleMigration if you run them backwards — I wasn't sure if that was also true for migrations with only an up and not a down method.

Copy link
Contributor

@joshlory joshlory left a comment

Choose a reason for hiding this comment

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

Nice cleanup!

@Bjvanminnen Bjvanminnen merged commit d44e7e3 into staging Feb 22, 2017
@Bjvanminnen Bjvanminnen deleted the externalCleanup branch February 22, 2017 23:02
@@ -0,0 +1,9 @@
class RemoveHrefFromExternal < ActiveRecord::Migration[5.0]
def up
External.all.each{|level| level.update!(properties: level.properties.except('href'))}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there are only ~ 1600 of these, it's not a big deal, but for larger sets find_each is preferred over .all.each No need to change this, just FYI

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.

None yet

3 participants