activegraph icon indicating copy to clipboard operation
activegraph copied to clipboard

How to update v9 migrations to v10 migrations?

Open mhanberg opened this issue 4 years ago • 8 comments

I am updating an app to use v10 to be able to use the seabolt adapter, and am running into a problem trying to deploy to a staging environment.

I think due to the rename, the current migrations are not being found because of the new label on the node.

Is this a bug or is there a way around this that I missed?

Thanks!

mhanberg avatar Apr 13 '20 16:04 mhanberg

@mhanberg : I've managed to get seabolt working with 9.6.2 as discussed here, you may find that easier than updating to 10 (which is still alpha). I find a 20-30% speed bump against http :smile:

ghost avatar Apr 14 '20 09:04 ghost

@jjg-dressipi I tried to set that up, but I ran into an issue with indexes. neo4j-core uses a regex to parse out the labels, properties on the index, and it appears that it can't parse a multi-property index.

I don't have that problem when I use the v10 release.

This is the v10 code that works: https://github.com/neo4jrb/activegraph/blob/95f2f5dfbaa2abe3e86f7a87b387e98afd724004/lib/active_graph/core/schema.rb#L15

This neo4j-core code that v9 uses does not work: https://github.com/neo4jrb/neo4j-core/blob/4b649fca33a1b1dba8705e6f999764ad9fb4d76e/lib/neo4j/core/cypher_session/adaptors/schema.rb#L17

I also saw this problem when using the built-in bolt adapter that v9 provides (the bolt adapter and the "driver" adapter both use the v9 neo4j-core code I shared above)

Offending backtrace
I, [2020-04-14T11:27:28.592213 #92604]  INFO -- : Started GET "/redacted" for ::1 at 2020-04-14 11:27:28 -0400
F, [2020-04-14T11:27:28.776436 #92604] FATAL -- :
F, [2020-04-14T11:27:28.777133 #92604] FATAL -- : NoMethodError (undefined method `[]' for nil:NilClass):
F, [2020-04-14T11:27:28.777340 #92604] FATAL -- :
F, [2020-04-14T11:27:28.777559 #92604] FATAL -- : neo4j-core (9.0.0) lib/neo4j/core/cypher_session/adaptors/schema.rb:17:in `block in indexes'
neo4j-core (9.0.0) lib/neo4j/core/cypher_session/result.rb:21:in `block in each'
neo4j-core (9.0.0) lib/neo4j/core/cypher_session/result.rb:20:in `each'
neo4j-core (9.0.0) lib/neo4j/core/cypher_session/result.rb:20:in `each'
neo4j-core (9.0.0) lib/neo4j/core/cypher_session/adaptors/schema.rb:16:in `map'
neo4j-core (9.0.0) lib/neo4j/core/cypher_session/adaptors/schema.rb:16:in `indexes'
neo4j-core (9.0.0) lib/neo4j/core/cypher_session.rb:33:in `block (2 levels) in '
neo4j (9.6.2) lib/neo4j/model_schema.rb:46:in `model_indexes'
neo4j (9.6.2) lib/neo4j/model_schema.rb:131:in `each_schema_element'
neo4j (9.6.2) lib/neo4j/model_schema.rb:94:in `validate_model_schema!'
neo4j (9.6.2) lib/neo4j/active_base.rb:78:in `validate_model_schema!'
neo4j (9.6.2) lib/neo4j/active_base.rb:50:in `new_query'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy.rb:313:in `_query'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy.rb:298:in `_query_model_as'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy.rb:116:in `base_query'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy.rb:98:in `query_as'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy.rb:87:in `query'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy_enumerable.rb:80:in `pluck'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy_enumerable.rb:95:in `pluck_vars'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy_eager_loading.rb:12:in `pluck_vars'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy_enumerable.rb:22:in `result'
neo4j (9.6.2) lib/neo4j/active_node/query/query_proxy_enumerable.rb:13:in `each'
neo4j (9.6.2) lib/neo4j/migrations/runner.rb:18:in `to_a'
neo4j (9.6.2) lib/neo4j/migrations/runner.rb:18:in `initialize'
neo4j (9.6.2) lib/neo4j/migrations.rb:15:in `new'
neo4j (9.6.2) lib/neo4j/migrations.rb:15:in `check_for_pending_migrations!'
neo4j (9.6.2) lib/neo4j/migrations/check_pending.rb:13:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.4.2) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.4.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.4.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.4.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.4.2) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.4.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.4.2) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.4.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.2) lib/rack/method_override.rb:24:in `call'
rack (2.2.2) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.4.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.4.2) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.2.2) lib/rack/sendfile.rb:110:in `call'
railties (5.2.4.2) lib/rails/engine.rb:524:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

mhanberg avatar Apr 14 '20 15:04 mhanberg

Ah, my schema doesn't seem to touch that issue, hence I get an easier ride ...

ghost avatar Apr 14 '20 15:04 ghost

The index it chokes on is - INDEX ON NODE:User(username, first_name, last_name)

mhanberg avatar Apr 14 '20 15:04 mhanberg

If you are migrating to v10 from v9, following migration should help,

class MigrateMigration < ActiveGraph::Migrations::Base
  def up
    execute('MATCH (n:`Neo4j::Migrations::SchemaMigration`) ' \
            'REMOVE n:`Neo4j::Migrations::SchemaMigration` ' \
            'SET n:`ActiveGraph::Migrations::SchemaMigration`')
  end

  def down
    raise ActiveGraph::IrreversibleMigration
  end
end

amitsuryavanshi avatar Apr 14 '20 16:04 amitsuryavanshi

@amitsuryavanshi

If I add this migration and run bin/rails neo4j:migrate, won't it still run the previous migrations that it doesn't think that it's run?

mhanberg avatar Apr 14 '20 17:04 mhanberg

Should the migration runner look for the legacy migrations in addition so that this migration is not necessary?

mhanberg avatar Apr 14 '20 17:04 mhanberg

I think I plan on going the v9.6.2 route and monkey patching the schema class from neo4j-core with the class from activegraph master (slightly modified to account for the difference in result classes).

That should hold us over until neo4j-core can be updated, or activegraph v10 is officially released.

I attempted to contribute a patch for neo4j-core, but i don't have the time to invest in making sure it works with the versions of neo4j that neo4j-core supports.

@amitsuryavanshi Feel free to close this issue if you feel your answer is an acceptable resolution to this issue.

mhanberg avatar Apr 14 '20 19:04 mhanberg