-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Document how to initialize the database when using R2DBC #20524
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
Comments
When you're using R2DBC, there's no support in Spring Boot for initialising a database using We should clarify the situation by adding some content to the reference documentation. This commit message summarises the situation quite well. |
OK, thanks, understand it. I just encountered this problem when I created a new project with Spring Boot 2.3.0.M3 today, the former sample projects are based on 2.2.x and the experimental spring data r2dbc starter. So I thought it could be a problem with the change of the dependencies, not realized there are some changes when spring data r2dbc merged into the official Spring Data and Spring Boot train. |
There is a note in the documentation but, reading this again, it's the last paragraph of a quite lengthy section so we should probably reword it. Is that what you have in mind @wilkinsona? |
I missed those two sentences when I went looking for something. Thanks for the pointer. I think we should have a separate section for database initialization with R2DBC and provide some more detailed examples. I also wonder if we should restructure the whole SQL section a bit. We could mention R2DBC in the opening description and then I think we should have separate JDBC and R2DBC subsections. All of the existing content other than the new R2DBC section would move beneath the JDBC section. |
I have the same problem as @hantsy. I switched the Spring Boot Experimental Project to Spring Boot 2.3.M3 and the loading of the schema no longer works. I think, this is probably due to the test autoconfiguration that is also integrated?? But I'm not sure!!
However, there is a workaround for this? Does it make sense to use the It try it client.execute("CREATE TABLE customer (id SERIAL PRIMARY KEY, first_name VARCHAR(255), last_name VARCHAR(255));").then(); but it fails again.
The insert statements can't be executed because of the missing CUSTOMER TABLE? |
Sorry @hantsy workaround is already working :-) So my contribution was not so important!! |
Actually, I already documented that in #20742 but I forgot to link the How-To in the main R2DBC section. I just did that. |
Sorry for PR, but I'd written simple migration library and published it to Maven Central |
@wilkinsona might also be a good idea to update https://spring.io/guides/gs/accessing-data-r2dbc/ |
Thanks for the suggestion. I've opened spring-guides/gs-accessing-data-r2dbc#1. |
In a general web flux application, if added
spring-boot-starter-data-r2dbc
into dependencies, the schema.sql and data.sql in classpath will be executed when the application is started.In my example, I created a RSocket server that serves at TCP/7000, I am using the following stack:
The project dependencies.
The project application.properties.
I have to declare a
ConnectionFactoryInitializer
bean to initialize the schema.sql and data.sql myself.Get the complete sample codes here.
The text was updated successfully, but these errors were encountered: