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

Several issues with migrations #1252

Open
7 of 8 tasks
ProGM opened this issue Aug 2, 2016 · 4 comments · Fixed by #1253
Open
7 of 8 tasks

Several issues with migrations #1252

ProGM opened this issue Aug 2, 2016 · 4 comments · Fixed by #1253
Assignees
Labels
Milestone

Comments

@ProGM
Copy link
Member

ProGM commented Aug 2, 2016

  • Migrations should print the performed queries, like active record does
  • Migrations should print the execution time
  • When making schema and data changes in the same migration, the error should suggest to set disable_transactions! in the migration file.
  • As an alternative: we might just run the migration itself inside the transaction and do a "rollback" outside of the transaction by checking to see if an error was raised and deleting the SchemaMigration node if so
  • When the previous error appears, http connection hangs instead of giving an error.
  • Schema-only migrations should not raise errors

About migrating from neo4j 7.x to 8.x

  • There should be a rails specific generator, to migrate everything at once
  • The neo4j:generate_schema_migration should accept multiple parameters:
rake neo4j:generate_schema_migration[index,Desk,type,name,some,other]

Or also:

rake neo4j:generate_schema_migration[index:Desk:type:name,constraint:Desk:other]

Runtime information:

Neo4j database version: 3.0.3
neo4j gem version: 8.0.0.alpha.1
neo4j-core gem version: 7.0.0.alpha.1

@ProGM ProGM added the bug label Aug 2, 2016
@cheerfulstoic
Copy link
Contributor

👍 on all of the ideas. One potential alternative to number 3 (as I mentioned on Gitter) is that we might just run the migration itself inside the transaction and do a "rollback" outside of the transaction by checking to see if an error was raised and deleting the SchemaMigration node if so

@ProGM ProGM added this to the 8.0.0 milestone Aug 2, 2016
@ProGM
Copy link
Member Author

ProGM commented Aug 2, 2016

@cheerfulstoic @subvertallchris
About this point:

When making schema and data changes in the same migration, the error should suggest to set disable_transactions! in the migration file.

I'm not sure how to handle this.
Currently the migration code and the creation of the SchemaMigration nodes, that keeps the migration state, are inside the same transaction.

This causes all migrations that updates schema to fail, since in neo4j you can't handle schema and data updates in the same transaction. However, if I move the SchemaMigration part outside the transaction, there could be some "incomplete" states.
For example: if the database commits the migration changes, but do not register it in the SchemaMigration for some reason, the next time that migration will be executed again.

I don't think this is a good thing ;(

What do you think?

@cheerfulstoic
Copy link
Contributor

What about creating a new Neo4j::Core::CypherSession object with the same adaptor from Neo4j::ActiveBase.current_session (you should be able to do Neo4j::Core::CypherSession.new(Neo4j::ActiveBase.current_session.adaptor)). You could then have a transaction running for both during the span of the migration and the creation of the SchemaMigration nodes and if an error is raised it would roll both back.

I think that would work ;)

@ProGM
Copy link
Member Author

ProGM commented Aug 3, 2016

Uhm, if it works, it great 👍
Let me try!

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

Successfully merging a pull request may close this issue.

2 participants