-
Notifications
You must be signed in to change notification settings - Fork 240
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
feat(sql): add SQL bootstrapper #4376
feat(sql): add SQL bootstrapper #4376
Conversation
...l-bootstrapper/src/main/java/org/eclipse/edc/sql/bootstrapper/SqlSchemaBootstrapperImpl.java
Fixed
Show fixed
Hide fixed
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #4376 +/- ##
==========================================
+ Coverage 71.74% 74.95% +3.21%
==========================================
Files 919 1071 +152
Lines 18457 21468 +3011
Branches 1037 1174 +137
==========================================
+ Hits 13242 16092 +2850
- Misses 4756 4852 +96
- Partials 459 524 +65 ☔ View full report in Codecov by Sentry. |
7e21020
to
6cf3ab8
Compare
...l-bootstrapper/src/main/java/org/eclipse/edc/sql/bootstrapper/SqlSchemaBootstrapperImpl.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
public Result<Void> executeSql() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method should be put in the interface (that will save the explicit cast in the SqlSchemaBootstrapperExtension
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want this method in the interface, for it could entice contributing modules to invoke it, which could potentially cause problems. The cast is ugly, but it should be possible to simply use the variable (as opposed to the getBootstrapper()
method) in the prepare()
phase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I understand it, but this necessity is not explicit (and being misinterpreted, e.g. from a future-me :) ), that could be achieved by keeping only the addStatement
method in the bootstrapper and moving the execution logic to a module-private service, that won't be registered on the runtime, this way the executeSql
will effectively become not callable from other modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats a lot of ceremony for one single method. if executeSql()
is package-private and documented, it should be clear enough what is done.
In addition, I didn't put the interface in an SPI package on purpose, because it is not intended as an extension point anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it, and it looks OK, but I'm not really sure splitting such a trivial task in two classes (and two test classes) is really worth it TBH. LMK what you think.
...l-bootstrapper/src/main/java/org/eclipse/edc/sql/bootstrapper/SqlSchemaBootstrapperImpl.java
Outdated
Show resolved
Hide resolved
@@ -42,18 +42,16 @@ static void createDatabase(String participantName) { | |||
|
|||
var extensionsFolder = TestUtils.findBuildRoot().toPath().resolve("extensions"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point the createDatabase
could just create the database and leave the bootstrapper to create tables and indexes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the E2E tests this will work but the e2e transfer tests, e.g. TransferPushEndToEndTest
, run into a race condition then. I'll give it a shot using @Order(...)
4ea4410
to
6c3ab12
Compare
6c3ab12
to
fd84edf
Compare
What this PR changes/adds
This PR adds the
SqlSchemaBootstrapper
class, which allows sql-related extensions to enqueue DDL statements. In theprepare()
phase, the bootstrapper then executes these commands one after the other.To do that, the schema files (formerly known as
schema.sql
) were renamed and moved to theresources/
folder. The were given individual names to avoid name clashes.In addition, all SQL-store tests were updated to read the schema from the resource rather than
docs/schema.sql
.Why it does that
easy way to create database structures.
Further notes
"edc.sql.schema.autocreate"
isfalse
by defaultLinked Issue(s)
Closes #4356
Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.