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

OrientDB support #947

Open
StanAccy opened this issue Feb 11, 2015 · 30 comments
Open

OrientDB support #947

StanAccy opened this issue Feb 11, 2015 · 30 comments

Comments

@StanAccy
Copy link

Please could you add support for OrientDB (http://www.orientechnologies.com/download/ - Community Edition).

@axelfontaine axelfontaine changed the title Support for OrientDB OrientDB support Feb 12, 2015
@morphace
Copy link

+1

11 similar comments
@ghost
Copy link

ghost commented Apr 19, 2015

+1

@basdek
Copy link

basdek commented Apr 30, 2015

+1

@amayne
Copy link

amayne commented May 8, 2015

+1

@phillashworth
Copy link

+1

@cristhiank
Copy link

+1

@walisonmoreira
Copy link

+1

@3meeb
Copy link

3meeb commented Jul 1, 2015

+1

@bergeragoston
Copy link

+1

@arnaudbos
Copy link

+1

@OlegAndreych
Copy link

+1

@urosjarc
Copy link

+1

@hohwille
Copy link

hohwille commented Feb 2, 2016

+1

IMHO you would only need to make DbSupportFactory.createDbSupport less static and hardwired but a little bit more pluggable. Maybe you could simply convert the static method into an instance method and allow subclassing DbSupportFactory. Otherwise create a simple new interface (DbSupportBuilder) for the factory with the method:

DbSupport createDbSupport(Connection connection)

Then you could add Flyway.setDbSupportFactory(DbSupportFactory) and allow vendors to implement their own DbSupport and support it via the factory. It could then also be autoconfigurable via the Properties if a non-arg constructor is available.

This way it would be a lot easier to support new databases and flyway core developers would not be a bottleneck to open it for new DBs.

BTW: I am on my way to reimplement flyway from scratch for orientDB. However, this feels wrong to me. Help me stop reinventing the wheel.
Do you like my idea? Should I provide PRs?

@hohwille
Copy link

hohwille commented Feb 2, 2016

BTW: The advantage of rewriting flyway would be that it could be completely decoupled from JDBC and can also work for OrientDBs native java document API. However, if flyway would support it using JDBC for the migration would still be OK and one can still decide to use native java API after migration is performed...

@hohwille
Copy link

hohwille commented Feb 2, 2016

Another tricky part is that for some strange reason OrientDB does not support multiple SQL statements separated by semicolon (except in batch mode of console). To make flyway work with OrientDB it would also be necessary to tweak this. The easiest way would be to fix this in OrientDB SQL engine or in jdbc driver or orientDb. Otherwise if this has to be done without touching OrientDB one would have to also write a custom implementation of FlywayCallback that creates an instance of a custom implementation of JdbcTemplate that overrides all methods, tokenizes/parses the SQL to split into multiple statements and run them sequentially over JDBC.

@luigidellaquila
Copy link

Hi @hohwille

Actually OrientDB supports multiple SQL statements in Document API using OCommandScript

ODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:localhost...");
db.open("user", "pass");
String script = "INSERT INTO Foo SET name = 'foo'; "+
            "INSERT INTO Foo SET name = 'bar'; "+
            "INSERT INTO Foo SET name = 'baz' ";
db.command(new OCommandScript("sql", script)).execute();

Please let me know if you need help on this!

Thanks

Luigi

@hohwille
Copy link

hohwille commented Feb 2, 2016

thanks @luigidellaquila for the feedback. That is good to know. But as Flyway ist completely wired to JDBC we would need this in the orient jdbc driver. According to my simple tests this fails, if I pass multiple semicolon separated statements to statement.executeQuery(sql).

@hohwille
Copy link

hohwille commented Feb 2, 2016

OK. I havent been using low-level JDBC for a while. It seems that it is not a task of JDBC to deal with multiple statements in a single SQL string:
http://stackoverflow.com/questions/18515471/can-i-execute-multiple-queries-separated-by-semicolon-with-mysql-connector-j

Then I have to dig deeper into flyway code and see where this is covered. From my first readings I got the impression that the entire SQL script is send to the JDBCTemplate. I might be wrong and missed something...

@axelfontaine
Copy link
Contributor

Flyway parses a script into statements which are sent individually to the DB.

@luigidellaquila
Copy link

Hi @axelfontaine

What would it need to implement a plugin for OrientDB? We can provide a JavaCC grammar for CRUD statements (it partially covers also schema manipulation statements, it will be completed in short)

Please let me know if I can help here

Thanks

Luigi

@luigidellaquila
Copy link

Probably, to make things easier, it just makes sense to write a statement per row and split the script line by line. Just guessing...

Luigi

@hohwille
Copy link

hohwille commented Feb 2, 2016

What would it need to implement a plugin for OrientDB?

See my first comment:
#947 (comment)

Source-Code to get startet can be found here:
https://github.com/flyway/flyway/tree/master/flyway-core/src/main/java/org/flywaydb/core/internal/dbsupport

@hohwille
Copy link

hohwille commented Feb 2, 2016

Probably, to make things easier, it just makes sense to write a statement per row and split the script line by line. Just guessing...

according to what @axelfontaine wrote, this seems to be already covered. Maybe flyway will also already strip comments from SQLs before sending over to JDBC.

For that part besides comments, multiple statements, semicolon handling, EOL-styles, etc. that are to be covered by flyway it will just send the SQL as is via JDBC. So for that part no specific custom logic or SQL parser is required. You would simply write the SQLs in the native way for OrientDB and IMHO flyway would not bother about new syntax such as "TRAVERSE", "CREATE CLASS", "CREATE PROPERTY", etc.
IMHO this is the major difference to liquibase that tries to make a full DB abstraction. I personally prefer flyway as I like KISS and I do not want an abstraction that is in the way if I want to have a specific DB/SQL feature. The abstraction is cool if you want to support different DBs with the same application code. However, I just prefer to write an app for one DB and ensure it is really working there. If others want to support another DB with flyway you can also just copy all the SQLs to a new location and adjust them and configure the new location instead. There are always pros and cons but that is why I would prefer flyway even though OrientDB is already supported by liquibase:
https://github.com/faizod/orientdb-liquibase-plugin

For DBSupport you only need to write a class that can create the metadata table and insert the records in there. That one should also be quite easy.

@mmacfadden
Copy link

+1

@mmacfadden
Copy link

@hohwille I was wondering if you are still working on this. We have the need to do something similar and are looking home growing our own solution, but would rather not.

@carlspring
Copy link

+1

Has any work been done on this already?

@axelfontaine axelfontaine added this to the Flyway 5.2.0 milestone Nov 26, 2017
@carlspring
Copy link

Any update on when Flyway 5.2.0 will be released?

@fuss86
Copy link

fuss86 commented Feb 21, 2018

+1
Are there any plans to this one ?:)

@fuss86
Copy link

fuss86 commented Feb 22, 2018

Hi guys, go for it ASAP ! :). Your competition has already some unofficial OSS support and release ;-)

@kishykumar
Copy link

+1

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

No branches or pull requests